From 8a54e68d8a996ebeef1e8ce9d2545e04a046502a Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Wed, 12 Jun 2024 15:11:32 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/product/ProductLists.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/api/lists/product/ProductLists.php b/app/api/lists/product/ProductLists.php index bc82f94b4..f965cd7d6 100644 --- a/app/api/lists/product/ProductLists.php +++ b/app/api/lists/product/ProductLists.php @@ -30,18 +30,18 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface,Li */ public function setSearch(): array { - $name=$this->request->get('name',''); + $name=$this->request->get('store_name',''); // $where['%pipe_like%'] =['name'=>'store_name|bar_code']; if($name){ if(preg_match('/[\x{4e00}-\x{9fff}]+/u', $name)==1){ - $where['%like%']=['store_name']; +// $where['%like%']=['name'=>'store_name']; + $where['%like%']=['store_name'=>'store_name']; }else{ $where['=']=['bar_code','cate_id']; } }else{ $where['=']=['store_id','bar_code','cate_id']; } - return $where; } /** From a75d9fb64e64260a450854f7fb25b09590cbf08b Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 25 Jun 2024 09:54:34 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=9C=B0=E5=9D=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/logic/user/AddressLogic.php | 12 +++++++++--- app/store/controller/user/AddressController.php | 2 +- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/api/logic/user/AddressLogic.php b/app/api/logic/user/AddressLogic.php index c2393319b..75f7003c6 100644 --- a/app/api/logic/user/AddressLogic.php +++ b/app/api/logic/user/AddressLogic.php @@ -59,14 +59,15 @@ class AddressLogic extends BaseLogic { Db::startTrans(); try { - if($params['is_default']==1){ + $is_default = $params['is_default']??0; + if($is_default){ UserAddress::where('uid',$params['uid'])->update(['is_default'=>0]); } $data = [ 'real_name' => $params['real_name'], 'phone' => $params['phone'], - 'detail' => $params['detail'], - 'is_default' => $params['is_default'], + 'detail' => $params['detail']??'', + 'is_default' => $params['is_default']??0, 'province' => $params['province'], 'city' => $params['city'], 'area' => $params['area'], @@ -109,4 +110,9 @@ class AddressLogic extends BaseLogic { return UserAddress::field('id,real_name,phone,province,city,area,street,village,brigade,detail,is_default')->where('id',$params['address_id'])->findOrEmpty()->toArray(); } + + public static function info($params): array + { + return UserAddress::field('id,real_name,phone,province,city,area,street,village,brigade,detail,is_default')->where($params)->findOrEmpty()->toArray(); + } } diff --git a/app/store/controller/user/AddressController.php b/app/store/controller/user/AddressController.php index b3a74cf8b..5563dc142 100644 --- a/app/store/controller/user/AddressController.php +++ b/app/store/controller/user/AddressController.php @@ -44,6 +44,6 @@ class AddressController extends BaseAdminController if($uid){ $params = ['uid' => $uid]; } - return $this->success('获取成功',AddressLogic::detail($params)); + return $this->success('获取成功',AddressLogic::info($params)); } } From da38902072f625a6cea6592e08aa4248333ae855 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 25 Jun 2024 14:26:55 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E5=A4=84=E7=90=86=E6=90=9C=E7=B4=A2?= =?UTF-8?q?=E7=9A=84=E5=88=86=E7=B1=BB=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/product/ProductLists.php | 29 ++------------------------ 1 file changed, 2 insertions(+), 27 deletions(-) diff --git a/app/api/lists/product/ProductLists.php b/app/api/lists/product/ProductLists.php index f8e219939..5ad85ef03 100644 --- a/app/api/lists/product/ProductLists.php +++ b/app/api/lists/product/ProductLists.php @@ -35,6 +35,7 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L if ($name) { if (preg_match('/[\x{4e00}-\x{9fff}]+/u', $name) == 1) { $where['%like%'] = ['store_name' => 'store_name']; + $where['='] = ['store_id', 'bar_code', 'cate_id']; } else { $where['='] = ['bar_code', 'cate_id']; } @@ -77,20 +78,6 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L */ public function lists(): array { - - $found = false; - if ($this->searchWhere) { - foreach ($this->searchWhere as $subArray) { - if (in_array('store_id', $subArray)) { - $found = true; - break; // 找到后退出循环 - } - } - } - if (!$found) { - $store_id = DictType::where('type', 'store')->value('remark') ?? 5; - $this->searchWhere[] = ['store_id', '=', $store_id]; - } $class_all = $this->request->get('class_all'); if ($class_all) { //查3级别的 @@ -124,19 +111,7 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L */ public function count(): int { - $found = false; - if ($this->searchWhere) { - foreach ($this->searchWhere as $subArray) { - if (in_array('store_id', $subArray)) { - $found = true; - break; // 找到后退出循环 - } - } - } - if (!$found) { - $store_id = DictType::where('type', 'store')->value('remark') ?? 5; - $this->searchWhere[] = ['store_id', '=', $store_id]; - } + $class_all = $this->request->get('class_all'); if ($class_all) { //查3级别的 From bcef6451d69c22843e4a82f6f9aa3e0c6f30981f Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 25 Jun 2024 14:36:58 +0800 Subject: [PATCH 4/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=95=86=E5=93=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/product/ProductLists.php | 33 ++++---------------------- 1 file changed, 4 insertions(+), 29 deletions(-) diff --git a/app/api/lists/product/ProductLists.php b/app/api/lists/product/ProductLists.php index 5ad85ef03..357cedda3 100644 --- a/app/api/lists/product/ProductLists.php +++ b/app/api/lists/product/ProductLists.php @@ -30,20 +30,10 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L */ public function setSearch(): array { - $name = $this->request->get('store_name', ''); - // $where['%pipe_like%'] =['name'=>'store_name|bar_code']; - if ($name) { - if (preg_match('/[\x{4e00}-\x{9fff}]+/u', $name) == 1) { - $where['%like%'] = ['store_name' => 'store_name']; - $where['='] = ['store_id', 'bar_code', 'cate_id']; - } else { - $where['='] = ['bar_code', 'cate_id']; - } - } else { - $where['='] = ['store_id', 'bar_code', 'cate_id']; - } - - return $where; + return [ + '=' => ['store_id', 'cate_id'], + '%pipe_like%' => ['store_name' => 'store_name|bar_code'], + ]; } /** * @notes 设置支持排序字段 @@ -111,21 +101,6 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L */ public function count(): int { - - $class_all = $this->request->get('class_all'); - if ($class_all) { - //查3级别的 - $arr = Cate::where('pid', $class_all)->column('id'); - if ($arr) { - $arr2 = Cate::where('pid', 'in', $arr)->column('id'); - $this->searchWhere[] = ['cate_id', 'in', array_merge($arr, $arr2)]; - }else{ - $this->searchWhere[] = ['cate_id','=',$class_all]; - } - } - - $this->searchWhere[] = ['status', '=', 1]; - $this->searchWhere[] = ['stock', '>', 0]; return StoreBranchProduct::where($this->searchWhere) ->count(); } From 596ce9d66dad43b8efb6814c32b7334cdc6ec007 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Tue, 25 Jun 2024 16:11:20 +0800 Subject: [PATCH 5/7] =?UTF-8?q?feat:=20=E4=BF=AE=E6=94=B9=E5=95=86?= =?UTF-8?q?=E5=93=81=E8=AE=A2=E5=8D=95=E7=9B=B8=E5=85=B3=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/lists/order/CartList.php | 24 +++++++++---------- app/api/lists/product/ProductLists.php | 2 +- app/api/logic/order/OrderLogic.php | 28 +++++++++++----------- app/common/logic/PayNotifyLogic.php | 33 +++++++++++++++++++------- 4 files changed, 52 insertions(+), 35 deletions(-) diff --git a/app/api/lists/order/CartList.php b/app/api/lists/order/CartList.php index 652c9eedf..c10cff8de 100644 --- a/app/api/lists/order/CartList.php +++ b/app/api/lists/order/CartList.php @@ -65,22 +65,22 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists foreach ($list as $key => &$item) { $find = StoreBranchProduct::where(['product_id' => $item['product_id'],'store_id' => $item['store_id']]) - ->field('product_id,image,price,cost,store_name,unit,delete_time,vip_price') + ->field('product_id,image,cost price,cost,store_name,unit,delete_time,vip_price') ->withTrashed() ->find(); if ($find) { - if ($user && $user['user_ship'] == 1) { - //更新 会员为1的时候原价减去会员价 - $deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$item['cart_num'],2); - $this->activity_price = bcadd($this->activity_price, $deduction_price_count, 2); - }elseif ($user && $user['user_ship'] == 4) { - //更新 为4商户的时候减去商户价格 - $deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$item['cart_num'],2); - $this->activity_price = bcadd( $this->activity_price, $deduction_price_count, 2); - }else{ - $this->activity_price =0; - } + // if ($user && $user['user_ship'] == 1) { + // //更新 会员为1的时候原价减去会员价 + // $deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$item['cart_num'],2); + // $this->activity_price = bcadd($this->activity_price, $deduction_price_count, 2); + // }elseif ($user && $user['user_ship'] == 4) { + // //更新 为4商户的时候减去商户价格 + // $deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$item['cart_num'],2); + // $this->activity_price = bcadd( $this->activity_price, $deduction_price_count, 2); + // }else{ + // $this->activity_price =0; + // } $item['goods_total_price'] = bcmul($item['cart_num'], $find['price'], 2); $this->total_price = bcadd($this->total_price, $item['goods_total_price'], 2); $item['imgs'] = $find['image']; diff --git a/app/api/lists/product/ProductLists.php b/app/api/lists/product/ProductLists.php index 357cedda3..10e8c6912 100644 --- a/app/api/lists/product/ProductLists.php +++ b/app/api/lists/product/ProductLists.php @@ -83,7 +83,7 @@ class ProductLists extends BaseAdminDataLists implements ListsSearchInterface, L $this->searchWhere[] = ['status', '=', 1]; $this->searchWhere[] = ['stock', '>', 0]; return StoreBranchProduct::where($this->searchWhere) - ->field(['id', 'product_id', 'cate_id', 'store_name', 'cost', 'store_id','vip_price','purchase', 'price', 'bar_code', 'image', 'sales', 'store_info', 'delete_time', 'unit', 'batch']) + ->field(['id', 'product_id', 'cate_id', 'store_name', 'cost', 'store_id','vip_price','purchase', 'cost price', 'bar_code', 'image', 'sales', 'store_info', 'delete_time', 'unit', 'batch']) ->with(['className', 'unitName']) ->limit($this->limitOffset, $this->limitLength) ->order($this->sortOrder) diff --git a/app/api/logic/order/OrderLogic.php b/app/api/logic/order/OrderLogic.php index 398f97321..14654eab6 100644 --- a/app/api/logic/order/OrderLogic.php +++ b/app/api/logic/order/OrderLogic.php @@ -74,7 +74,7 @@ class OrderLogic extends BaseLogic /** 计算价格 */ foreach ($cart_select as $k => $v) { - $find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field('id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase,product_id')->withTrashed()->find(); + $find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field('id branch_product_id,store_name,image,unit,cost price,vip_price,cost,purchase,product_id')->withTrashed()->find(); if (!$find) { continue; } @@ -85,19 +85,19 @@ class OrderLogic extends BaseLogic $cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价 $cart_select[$k]['deduction_price'] =self::$activity_price;//抵扣金额 $cart_select[$k]['vip'] = 0; - if ($user && $user['user_ship'] == 1) { - //更新 会员为1的时候原价减去会员价 - $deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$v['cart_num'],2); - $cart_select[$k]['deduction_price'] =$deduction_price_count; - self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2); - $cart_select[$k]['vip'] =1; - } - if ($user && $user['user_ship'] == 4) { - //更新 为4商户的时候减去商户价格 - $deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$v['cart_num'],2); - $cart_select[$k]['deduction_price'] =$deduction_price_count; - self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2); - } + // if ($user && $user['user_ship'] == 1) { + // //更新 会员为1的时候原价减去会员价 + // $deduction_price_count=bcmul(bcsub($find['price'], $find['vip_price'], 2),$v['cart_num'],2); + // $cart_select[$k]['deduction_price'] =$deduction_price_count; + // self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2); + // $cart_select[$k]['vip'] =1; + // } + // if ($user && $user['user_ship'] == 4) { + // //更新 为4商户的时候减去商户价格 + // $deduction_price_count=bcmul(bcsub($find['price'], $find['cost'], 2),$v['cart_num'],2); + // $cart_select[$k]['deduction_price'] =$deduction_price_count; + // self::$activity_price = bcadd(self::$activity_price, $deduction_price_count, 2); + // } //利润 // $cart_select[$k]['profit'] = bcmul($v['cart_num'], $onePrice, 2); //利润 diff --git a/app/common/logic/PayNotifyLogic.php b/app/common/logic/PayNotifyLogic.php index bde01d353..e1f2b3f37 100644 --- a/app/common/logic/PayNotifyLogic.php +++ b/app/common/logic/PayNotifyLogic.php @@ -272,8 +272,8 @@ class PayNotifyLogic extends BaseLogic $user = User::where('id', $order['uid'])->findOrEmpty(); $capitalFlowDao = new CapitalFlowLogic($user); $deal_money = bcdiv($extra['amount']['refund'], 100, 2); - if (in_array($order['pay_type'],[PayEnum::BALANCE_PAY,PayEnum::PURCHASE_FUNDS])){ - if($order['pay_type'] == PayEnum::BALANCE_PAY){//用户余额 + if (in_array($order['pay_type'], [PayEnum::BALANCE_PAY, PayEnum::PURCHASE_FUNDS])) { + if ($order['pay_type'] == PayEnum::BALANCE_PAY) { //用户余额 $user->now_money = bcadd($user->now_money, $deal_money, 2); $user->save(); //增加数量 @@ -281,7 +281,7 @@ class PayNotifyLogic extends BaseLogic //退款 $capitalFlowDao->userIncome('system_balance_back', 'system_back', $order['id'], $deal_money); } - if($order['pay_type'] == PayEnum::PURCHASE_FUNDS){//采购款 + if ($order['pay_type'] == PayEnum::PURCHASE_FUNDS) { //采购款 $user->purchase_funds = bcadd($user->purchase_funds, $deal_money, 2); $user->save(); //增加数量 @@ -289,11 +289,10 @@ class PayNotifyLogic extends BaseLogic //退款 $capitalFlowDao->userIncome('system_purchase_back', 'system_back', $order['id'], $deal_money); } - } //微信日志 user_order_refund - $capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $deal_money,'',1); - self::addStock($order['id']);//微信 + $capitalFlowDao->userIncome('user_order_refund', 'system_back', $order['id'], $deal_money, '', 1); + self::addStock($order['id']); //微信 // self::afterPay($order,$extra['transaction_id']); } @@ -320,7 +319,7 @@ class PayNotifyLogic extends BaseLogic $order->save(); //日志记录 $model = new StoreCashFinanceFlow(); - $model->store_id = $order['store_id']??0; + $model->store_id = $order['store_id'] ?? 0; $model->cash_price = $order->pay_price; $model->receivable = $order->pay_price; $model->remark = '退款'; @@ -454,6 +453,24 @@ class PayNotifyLogic extends BaseLogic { $financeLogic = new StoreFinanceFlowLogic(); $user_sing = new UserSign(); + //-----活动价结算更改 + $financeLogic->order = $order; + $financeLogic->user = ['uid' => $order['uid']]; + $financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::USER_ORDER_PAY, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); //用户订单支付 + $financeLogic->in($transaction_id, $order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], 0, 0, $order['pay_type']); + $financeLogic->out($transaction_id, $order['pay_price'], OrderEnum::SUPPLIER_ORDER_OBTAINS, $order['store_id'], $order['staff_id'], 0, $order['pay_type']); + if ($order['uid'] > 0) { + $user_number = bcmul($order['pay_price'], '0.10', 2); + $sing = [ + 'uid' => $order['uid'], + 'order_id' => $order['order_id'], + 'title' => '购买商品获得兑换券', + 'store_id' => $order['store_id'], + 'number' => $user_number, + ]; + $user_sing->save($sing); + } + return false; $vipFen = 0; if ($order['uid'] > 0) { // 结算金额 要支付的钱减去冻结得钱去走后面得逻辑 发得兑换券也要去减去 @@ -834,7 +851,7 @@ class PayNotifyLogic extends BaseLogic $updateData[] = [ 'id' => $StoreBranchProduct['id'], 'stock' => $StoreBranchProduct['stock'] + $v['cart_num'], -// 'sales' => ['inc', $v['cart_num']] + // 'sales' => ['inc', $v['cart_num']] ]; } } From b7218e96e63c5261ded9333dcd0a9756fe1b188b Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 25 Jun 2024 17:11:35 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=97=A8=E5=BA=97?= =?UTF-8?q?=E6=94=B6=E6=AC=BE=E7=9A=84=E5=95=86=E6=88=B7=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E7=9A=84=E7=BB=9F=E8=AE=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/logic/WorkbenchLogic.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/store/logic/WorkbenchLogic.php b/app/store/logic/WorkbenchLogic.php index 20fa8a024..6c44a1cc4 100644 --- a/app/store/logic/WorkbenchLogic.php +++ b/app/store/logic/WorkbenchLogic.php @@ -35,6 +35,7 @@ use app\common\model\system_store\SystemStore; use app\common\model\user_recharge\UserRecharge; use app\common\service\ConfigService; use app\common\service\FileService; +use app\statistics\logic\OrderLogic; /** @@ -82,7 +83,9 @@ class WorkbenchLogic extends BaseLogic //门店收益金额 $data['income_amount'] = StoreFinanceFlow::where($storeFinanceWhere)->whereBetweenTime('create_time', $startTime, $endTime)->sum('number'); //门店收款金额 - $data['receipt_amount'] = UserRecharge::where($userRechargeWhere)->whereBetweenTime('create_time', $startTime, $endTime)->sum('price'); + $all_where['paid'] = 1; + $data['receipt_amount'] = OrderLogic::dayPayPrice($all_where); +// $data['receipt_amount'] = UserRecharge::where($userRechargeWhere)->whereBetweenTime('create_time', $startTime, $endTime)->sum('price'); //保证金金额 $data['deposit_amount'] = StoreFinanceFlow::where($storeFinanceWhereTwo)->whereBetweenTime('create_time', $startTime, $endTime)->sum('number'); //门店成交用户数 From 5433c2fbde26e14f1b92253239790aa8032e8121 Mon Sep 17 00:00:00 2001 From: liu <1873441552@qq.com> Date: Tue, 25 Jun 2024 18:16:52 +0800 Subject: [PATCH 7/7] =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E5=9B=BE=E8=A1=A8?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/logic/WorkbenchLogic.php | 50 ++++++++++++++++++++++++------ 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/app/store/logic/WorkbenchLogic.php b/app/store/logic/WorkbenchLogic.php index 6c44a1cc4..7cd18e6d7 100644 --- a/app/store/logic/WorkbenchLogic.php +++ b/app/store/logic/WorkbenchLogic.php @@ -101,6 +101,7 @@ class WorkbenchLogic extends BaseLogic $i++; } $field = 'from_unixtime(pay_time,"%H") as pay_time,sum(pay_price) as pay_price'; + $recharge_field = 'from_unixtime(pay_time,"%H") as pay_time,sum(price) as pay_price'; } elseif ($dateDiff->days <= 31) { $group = 'DAY(pay_time)'; $i = 0; @@ -109,6 +110,7 @@ class WorkbenchLogic extends BaseLogic $i++; } $field = 'from_unixtime(pay_time,"%m-%d") as pay_time,sum(pay_price) as pay_price'; + $recharge_field = 'from_unixtime(pay_time,"%m-%d") as pay_time,sum(price) as pay_price'; } else { $group = 'MONTH(pay_time)'; $i = 0; @@ -127,7 +129,27 @@ class WorkbenchLogic extends BaseLogic $i++; } $field = 'from_unixtime(pay_time,"%Y-%m") as pay_time,sum(pay_price) as pay_price'; + $recharge_field = 'from_unixtime(pay_time,"%Y-%m") as pay_time,sum(price) as pay_price'; } + $data['order_list'] = StoreOrder::with('user')->where($where) + ->whereBetweenTime('pay_time', $startTime, $endTime) + ->order('pay_time', 'desc') + ->limit(6) + ->select()->each(function($item){ + $item->pay_time=$item->pay_time>0?date('Y-m-d H:i:s',$item->pay_time):''; + }) + ->toArray(); + + //取消单个店铺搜索 + unset($where['store_id']); + + $rechargeList = UserRecharge::field($recharge_field) + ->where(['paid'=>1]) + ->whereBetweenTime('pay_time', $startTime, $endTime) + ->group($group) + ->select() + ->toArray(); + $orderList = StoreOrder::field($field) ->where($where) ->whereBetweenTime('pay_time', $startTime, $endTime) @@ -145,6 +167,7 @@ class WorkbenchLogic extends BaseLogic $orderListTmp = []; $userListTmp = []; $range = []; + $mergedListTmp = []; foreach ($timeRange as $item) { $range[] = $item; if (!isset($orderList[$item])) { @@ -157,22 +180,29 @@ class WorkbenchLogic extends BaseLogic } else { $userListTmp[$item] = $userList[$item]['user_num']; } + + // 处理 $rechargeList 和 $orderList 的相加 + $mergedListTmp[$item] = 0; + foreach ($rechargeList as $recharge) { + if ($recharge['pay_time'] == $item) { + $mergedListTmp[$item] += $recharge['pay_price']; + } + } + foreach ($orderList as $order) { + if ($order['pay_time'] == $item) { + $mergedListTmp[$item] += $order['pay_price']; + } + } } $data['statistics'] = [ 'range' => $range, 'data' => [ - 'order_amount' => array_values($orderListTmp), - 'user_number' => array_values($userListTmp) +// 'order_amount' => array_values($orderListTmp), + 'user_number' => array_values($userListTmp), + 'order_amount' => array_values($mergedListTmp) ] ]; - $data['order_list'] = StoreOrder::with('user')->where($where) - ->whereBetweenTime('pay_time', $startTime, $endTime) - ->order('pay_time', 'desc') - ->limit(6) - ->select()->each(function($item){ - $item->pay_time=$item->pay_time>0?date('Y-m-d H:i:s',$item->pay_time):''; - }) - ->toArray(); + $data['pay_type'] = [ ['name' => '线上收银订单', 'value' => bcsub($data['order_amount'], bcadd($data['verify_amount'], $data['cash_amount'], 2), 2)], ['name' => '核销订单', 'value' => $data['verify_amount']],