Merge branch 'v5.0.0dev' of https://gitee.com/ZhongBangKeJi/CRMEB into v5.0.0dev

This commit is contained in:
From-wh 2023-04-03 18:24:31 +08:00
commit ceefd45641
3 changed files with 16 additions and 34 deletions

View File

@ -47,6 +47,7 @@ abstract class BaseDao
* 读取数据条数
* @param array $where
* @return int
* @throws \ReflectionException
*/
public function count(array $where = [])
{
@ -59,8 +60,10 @@ abstract class BaseDao
* @param string $field
* @param int $page
* @param int $limit
* @param string $order
* @param bool $search
* @return \think\Collection
* @throws \ReflectionException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
@ -310,7 +313,7 @@ abstract class BaseDao
if ($responses->hasMethod($method)) {
$with[] = $key;
} else {
if (!in_array($key, ['timeKey', 'store_stock','start_status'])) {
if (!in_array($key, ['timeKey', 'store_stock', 'integral_time'])) {
$otherWhere[] = is_array($value) ? $value : [$key, '=', $value];
}
}
@ -380,6 +383,9 @@ abstract class BaseDao
* @param string|null $keyField
* @param int $acc
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function bcInc($key, string $incField, string $inc, string $keyField = null, int $acc = 2)
{
@ -394,6 +400,9 @@ abstract class BaseDao
* @param string|null $keyField
* @param int $acc
* @return bool
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public function bcDec($key, string $decField, string $dec, string $keyField = null, int $acc = 2)
{
@ -460,18 +469,6 @@ abstract class BaseDao
})->dec($stock, $num)->inc($sales, $num)->update();
}
return false;
// $field = $isQuota ? [$stock, $sales, 'quota'] : [$stock, $sales];
// $info = $this->getModel()->where($where)->field($field)->find();
// if ($info) {
// if ($isQuota) {
// $info->quota = (int)$info->quota - $num;
// }
// $info->stock = (int)$info->stock - $num;
// $info->sales = (int)$info->sales + $num;
// return $info->save();
// } else {
// return false;
// }
}
/**
@ -502,22 +499,6 @@ abstract class BaseDao
})->inc($stock, $num)->dec($sales, $salesNum)->update();
}
return true;
// $field = $isQuota ? [$stock, $sales, 'quota'] : [$stock, $sales];
// $info = $this->getModel()->where($where)->field($field)->find();
// if ($info) {
// if ($isQuota) {
// $info->quota = (int)$info->quota + $num;
// }
// $info->stock = (int)$info->stock + $num;
// if ((int)$info->sales > $num) {
// $info->sales = (int)$info->sales - $num;
// } else {
// $info->sales = 0;
// }
// return $info->save();
// } else {
// return false;
// }
}
/**

View File

@ -63,7 +63,9 @@ class StoreProductDao extends BaseDao
* @param array $where
* @param int $page
* @param int $limit
* @param string $order
* @return array
* @throws \ReflectionException
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
@ -71,7 +73,7 @@ class StoreProductDao extends BaseDao
public function getList(array $where, int $page = 0, int $limit = 0, string $order = '')
{
$prefix = Config::get('database.connections.' . Config::get('database.default') . '.prefix');
return $this->search($where)->order(($order ? $order . ' ,' : '') . 'sort desc,id desc')
return $this->search($where, false)->order(($order ? $order . ' ,' : '') . 'sort desc,id desc')
->when($page != 0 && $limit != 0, function ($query) use ($page, $limit) {
$query->page($page, $limit);
})->field([
@ -79,7 +81,6 @@ class StoreProductDao extends BaseDao
'(SELECT count(*) FROM `' . $prefix . 'store_product_relation` WHERE `product_id` = `' . $prefix . 'store_product`.`id` AND `type` = \'collect\') as collect',
'(SELECT count(*) FROM `' . $prefix . 'store_product_relation` WHERE `product_id` = `' . $prefix . 'store_product`.`id` AND `type` = \'like\') as likes',
'(SELECT SUM(stock) FROM `' . $prefix . 'store_product_attr_value` WHERE `product_id` = `' . $prefix . 'store_product`.`id` AND `type` = 0) as stock',
// '(SELECT SUM(sales) FROM `' . $prefix . 'store_product_attr_value` WHERE `product_id` = `' . $prefix . 'store_product`.`id` AND `type` = 0) as sales',
'(SELECT count(*) FROM `' . $prefix . 'store_visit` WHERE `product_id` = `' . $prefix . 'store_product`.`id` AND `product_type` = \'product\') as visitor',
])->select()->toArray();
}

View File

@ -120,7 +120,7 @@ class StoreServiceLogServices extends BaseServices
foreach ($list as &$item) {
$item['_add_time'] = $item['add_time'];
$item['add_time'] = strtotime($item['_add_time']);
$item['productInfo'] = $item['orderInfo'] = [];
$item['productInfo'] = $item['orderInfo'] = null;
if ($item['msn_type'] == self::MSN_TYPE_GOODS && $item['msn']) {
$productIds[] = $item['msn'];
} elseif ($item['msn_type'] == self::MSN_TYPE_ORDER && $item['msn']) {
@ -155,7 +155,7 @@ class StoreServiceLogServices extends BaseServices
foreach ($list as &$item) {
if ($item['msn_type'] == self::MSN_TYPE_GOODS && $item['msn']) {
$item['productInfo'] = $productList[$item['msn']] ?? [];
$item['productInfo'] = $productList[$item['msn']] ?? null;
} elseif ($item['msn_type'] == self::MSN_TYPE_ORDER && $item['msn']) {
$order = $orderInfo[$item['msn']] ?? null;
if ($order) {
@ -164,7 +164,7 @@ class StoreServiceLogServices extends BaseServices
$order['add_time_h'] = date('H:i:s', $order['add_time']);
$item['orderInfo'] = $order;
} else {
$item['orderInfo'] = [];
$item['orderInfo'] = null;
}
}
$item['msn_type'] = (int)$item['msn_type'];