Merge pull request 'fix(order): 修复订单相关问题' (#324) from dev into main

Reviewed-on: #324
This commit is contained in:
mkm 2024-11-11 15:34:28 +08:00
commit 1160bbadab
3 changed files with 10 additions and 5 deletions

View File

@ -311,10 +311,12 @@ class BeforehandOrderLogic extends BaseLogic
try {
$find=BeforehandOrder::where('id', $params['id'])->find();
$other_data=$find['other_data'];
$other_data['arrival_time']=strtotime($params['arrival_time']);
$find->update([
if(!empty($params['other_data']['arrival_time'])){
$other_data->arrival_time=$params['other_data']['arrival_time'];
}
$find->save([
'other_data'=>json_encode($other_data, true),
'image' => $params['image'],
'file' => $params['file'],
'mark' => $params['mark']
]);
Db::commit();
@ -607,6 +609,9 @@ class BeforehandOrderLogic extends BaseLogic
$order = BeforehandOrder::where('id', $params['id'])->find();
$order['admin_name'] = Admin::where('id', $order['admin_id'])->value('name');
$data = BeforehandOrderCartInfo::where('bhoid', $params['id'])->select()->each(function ($item) {
if($item['total_price']==0 || $item['cart_num']==0){
throw new BusinessException('数量或金额不能为0');
}
$find = StoreProduct::where('id', $item['product_id'])->field('top_cate_id,store_name,unit')->find();
$item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name');
$item['store_name'] = $find['store_name'];

View File

@ -55,7 +55,7 @@ class IndexController extends BaseApiController
{
d(1);
$arr=StoreOrder::where('store_id',3)->where('paid',1)->field('id,pay_price,deduction_price,refund_price')->select()->toArray();
$arr=StoreOrder::where('store_id',8)->where('paid',1)->field('id,pay_price,deduction_price,refund_price')->select()->toArray();
$data=[];
foreach ($arr as $k => $v) {
$total_price=StoreOrderCartInfo::where('oid', $v['id'])->sum('total_price');

View File

@ -357,7 +357,7 @@ class StoreOrderLogic extends BaseLogic
*/
public function storeOrderSumByDate($start, $end, $extra = [], $field = 'pay_price')
{
return StoreOrder::where($extra)->whereBetweenTime('create_time', $start, $end)->sum($field);
return StoreOrder::where($extra)->whereBetweenTime('pay_time', $start, $end)->sum($field);
}
/**