修复订单已结算查询

This commit is contained in:
mkm 2023-11-27 11:36:28 +08:00
parent cab9448700
commit af3c2bae70
2 changed files with 157 additions and 148 deletions

View File

@ -440,10 +440,19 @@ class StoreOrderDao extends BaseDao
{
return StoreOrder::getDB()->when(isset($where['dateRange']), function ($query) use ($where) {
getModelTime($query, date('Y/m/d 00:00:00', $where['dateRange']['start']) . '-' . date('Y/m/d 00:00:00', $where['dateRange']['stop']), 'pay_time');
})->field(Db::raw('sum(pay_price) as pay_price,count(*) as total,count(distinct uid) as user,pay_time,from_unixtime(unix_timestamp(pay_time),\'%m-%d\') as `day`'))
})->field(
Db::raw('status,sum(pay_price) as pay_price,count(*) as total,count(distinct uid) as user,pay_time,from_unixtime(unix_timestamp(pay_time),\'%m-%d\') as `day`')
)
->where('paid', 1)->when($merId, function ($query, $merId) {
$query->where('mer_id', $merId);
})->order('pay_time DESC')->page($page, $limit)->group('day')->select();
})->order('pay_time DESC')->page($page, $limit)->group('day')->select()->each(function ($item) use ($merId) {
$pay_time = explode(' ', $item['pay_time']);
$item->settlement_price = Db::name('store_order')
->whereIn('status', [2, 3])
->where('mer_id', $merId)
->whereDay('pay_time', $pay_time[0])
->sum('pay_price');
});
}
public function dayOrderPriceGroup($date, $merId = null)
@ -570,8 +579,7 @@ class StoreOrderDao extends BaseDao
if ($uid) $query->where('uid', $uid);
});
$query->where('activity_type', $data['product_type']);
switch($data['product_type'])
{
switch ($data['product_type']) {
case 0:
$query->where(function ($query) {
$query->where(function ($query) {
@ -674,8 +682,7 @@ class StoreOrderDao extends BaseDao
});
$query->where('activity_type', $data['product_type'])->where('paid', 1);
switch($data['product_type'])
{
switch ($data['product_type']) {
case 1: //秒杀
$query->where(function ($query) {
$query->where(function ($query) {
@ -749,7 +756,6 @@ class StoreOrderDao extends BaseDao
$query->where('is_del', 0)->whereOr(function ($query) {
$query->where('is_del', 1)->where('paid', 1);
});
})->where('StoreOrder.uid',$uid)->count()
;
})->where('StoreOrder.uid', $uid)->count();
}
}

View File

@ -49,6 +49,8 @@ class ProductCreate
return false;
}
//添加到云仓
$find = Db::name('cloud_product')->where('product_id', $product_id)->find();
if (!$find) {
$datas = [
'product_id' => $product_id,
'mer_id' => $merchant['mer_id'],
@ -63,3 +65,4 @@ class ProductCreate
Db::name('cloud_product')->insert($datas);
}
}
}