From a628d165117824dfffeea4381cc521c3d720c93c Mon Sep 17 00:00:00 2001 From: fengxinyhyl Date: Tue, 19 Mar 2024 21:10:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=AF=8F=E6=97=A5=E5=88=86=E7=BA=A2=E7=82=B9?= =?UTF-8?q?=E5=88=86=E7=BA=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dao/store/order/StoreOrderBaseDao.php | 46 + app/common/dao/system/HuitongDao.php | 42 + app/common/dao/user/UserAssetsDao.php | 10 + .../model/store/order/StoreOrderBase.php | 31 + app/common/model/system/Huitong.php | 31 + .../store/order/StoreOrderBaseRepository.php | 55 ++ .../store/order/StoreOrderRepository.php | 865 +++++++++--------- .../repositories/system/HuitongRepository.php | 37 + .../user/UserAssetsLogRepository.php | 50 +- .../user/UserAssetsRepository.php | 71 +- app/controller/api/Auth.php | 6 +- app/event.php | 2 + crmeb/listens/pay/CustomizeTake.php | 10 + crmeb/listens/task/CustomizeTask.php | 33 + 14 files changed, 842 insertions(+), 447 deletions(-) create mode 100644 app/common/dao/store/order/StoreOrderBaseDao.php create mode 100644 app/common/dao/system/HuitongDao.php create mode 100644 app/common/model/store/order/StoreOrderBase.php create mode 100644 app/common/model/system/Huitong.php create mode 100644 app/common/repositories/store/order/StoreOrderBaseRepository.php create mode 100644 app/common/repositories/system/HuitongRepository.php create mode 100644 crmeb/listens/task/CustomizeTask.php diff --git a/app/common/dao/store/order/StoreOrderBaseDao.php b/app/common/dao/store/order/StoreOrderBaseDao.php new file mode 100644 index 0000000..d12564a --- /dev/null +++ b/app/common/dao/store/order/StoreOrderBaseDao.php @@ -0,0 +1,46 @@ + +// +---------------------------------------------------------------------- + + +namespace app\common\dao\store\order; + + +use app\common\dao\BaseDao; +use app\common\model\store\order\StoreOrderBase; + +/** + * Class StoreOrderDao + * @package app\common\dao\store\order + * @author xaboy + * @day 2020/6/8 + */ +class StoreOrderBaseDao extends BaseDao +{ + /** + * @return string + * @author xaboy + * @day 2020/6/8 + */ + protected function getModel(): string + { + return StoreOrderBase::class; + } + + + public function getTotalBase($day){ + if($day){ + return StoreOrderBase::where('c_date',$day)->sum("base"); + }else{ + return StoreOrderBase::sum("base"); + } + } +} diff --git a/app/common/dao/system/HuitongDao.php b/app/common/dao/system/HuitongDao.php new file mode 100644 index 0000000..97f0024 --- /dev/null +++ b/app/common/dao/system/HuitongDao.php @@ -0,0 +1,42 @@ + +// +---------------------------------------------------------------------- + + +namespace app\common\dao\system; + + +use app\common\dao\BaseDao; +use app\common\model\system\Huitong; + +/** + * Class StoreOrderDao + * @package app\common\dao\store\order + * @author xaboy + * @day 2020/6/8 + */ +class HuitongDao extends BaseDao +{ + /** + * @return string + * @author xaboy + * @day 2020/6/8 + */ + protected function getModel(): string + { + return Huitong::class; + } + + + public function getLastHuitong(){ + return Huitong::order('id desc')->find(); + } +} diff --git a/app/common/dao/user/UserAssetsDao.php b/app/common/dao/user/UserAssetsDao.php index 7d1b750..2480c27 100644 --- a/app/common/dao/user/UserAssetsDao.php +++ b/app/common/dao/user/UserAssetsDao.php @@ -28,4 +28,14 @@ class UserAssetsDao extends BaseDao { $this->create(compact('uid', 'spread_uid', 'admin_id', 'old_spread_uid')); } + + + public function getShareData(){ + $total = UserAssets::sum('share_point'); + $list = UserAssets::where('share_point','>',0)->field("uid, share_point")->select(); + if($total){ + return array('total'=>$total, 'list'=>$list->toArray()); + } + return array('total'=>0, 'list'=>[]); + } } diff --git a/app/common/model/store/order/StoreOrderBase.php b/app/common/model/store/order/StoreOrderBase.php new file mode 100644 index 0000000..ce067f8 --- /dev/null +++ b/app/common/model/store/order/StoreOrderBase.php @@ -0,0 +1,31 @@ + +// +---------------------------------------------------------------------- + + +namespace app\common\model\store\order; + + +use app\common\model\BaseModel; + +class StoreOrderBase extends BaseModel +{ + + public static function tablePk(): ?string + { + return 'id'; + } + + public static function tableName(): string + { + return 'store_order_base'; + } +} diff --git a/app/common/model/system/Huitong.php b/app/common/model/system/Huitong.php new file mode 100644 index 0000000..4ad45b8 --- /dev/null +++ b/app/common/model/system/Huitong.php @@ -0,0 +1,31 @@ + +// +---------------------------------------------------------------------- + + +namespace app\common\model\system; + + +use app\common\model\BaseModel; + +class Huitong extends BaseModel +{ + + public static function tablePk(): ?string + { + return 'id'; + } + + public static function tableName(): string + { + return 'huitong'; + } +} diff --git a/app/common/repositories/store/order/StoreOrderBaseRepository.php b/app/common/repositories/store/order/StoreOrderBaseRepository.php new file mode 100644 index 0000000..270b6f6 --- /dev/null +++ b/app/common/repositories/store/order/StoreOrderBaseRepository.php @@ -0,0 +1,55 @@ + +// +---------------------------------------------------------------------- +namespace app\common\repositories\store\order; + +use app\common\dao\store\order\StoreOrderBaseDao; +use app\common\dao\store\order\StoreOrderDao; +use app\common\repositories\BaseRepository; + + +/** + * Class StoreOrderRepository + * @package app\common\repositories\store\order + * @author xaboy + * @day 2020/6/9 + * @mixin StoreOrderDao + */ +class StoreOrderBaseRepository extends BaseRepository +{ + /** + * StoreOrderRepository constructor. + * @param StoreOrderBaseDao $dao + */ + public function __construct(StoreOrderBaseDao $dao) + { + $this->dao = $dao; + } + + + public function insertBase($list){ + $data = []; + foreach ($list as $item){ + $data[] = array( + 'order_id' => $item['order_id'], + 'base' => $item['base'], + 'c_date' => date('Y-m-d'), + ); + } + $this->dao->insertAll($data); + } + + + public function getTotalBase($day = ''){ + return $this->dao->getTotalBase($day); + } + +} diff --git a/app/common/repositories/store/order/StoreOrderRepository.php b/app/common/repositories/store/order/StoreOrderRepository.php index c54ff5e..78f20c2 100644 --- a/app/common/repositories/store/order/StoreOrderRepository.php +++ b/app/common/repositories/store/order/StoreOrderRepository.php @@ -81,6 +81,7 @@ class StoreOrderRepository extends BaseRepository const TYPE_SN_USER_RECHARGE = 'wxu'; const TYPE_SN_REFUND = 'rwx'; + /** * StoreOrderRepository constructor. * @param StoreOrderDao $dao @@ -140,10 +141,10 @@ class StoreOrderRepository extends BaseRepository $userBillRepository = app()->make(UserBillRepository::class); $userBillRepository->decBill($user['uid'], 'now_money', 'pay_product', [ 'link_id' => $groupOrder['group_order_id'], - 'status' => 1, - 'title' => '购买商品', - 'number' => $groupOrder['pay_price'], - 'mark' => '余额支付支付' . floatval($groupOrder['pay_price']) . '元购买商品', + 'status' => 1, + 'title' => '购买商品', + 'number' => $groupOrder['pay_price'], + 'mark' => '余额支付支付' . floatval($groupOrder['pay_price']) . '元购买商品', 'balance' => $user->now_money ]); $this->paySuccess($groupOrder); @@ -189,29 +190,29 @@ class StoreOrderRepository extends BaseRepository $groupOrder->append(['user']); //修改订单状态 Db::transaction(function () use ($subOrders, $is_combine, $groupOrder) { - $time = date('Y-m-d H:i:s'); - $groupOrder->paid = 1; - $groupOrder->pay_time = $time; + $time = date('Y-m-d H:i:s'); + $groupOrder->paid = 1; + $groupOrder->pay_time = $time; $groupOrder->is_combine = $is_combine; - $orderStatus = []; + $orderStatus = []; $groupOrder->append(['orderList.orderProduct']); - $flag = true; - $finance = []; - $profitsharing = []; - $financialRecordRepository = app()->make(FinancialRecordRepository::class); - $financeSn = $financialRecordRepository->getSn(); - $userMerchantRepository = app()->make(UserMerchantRepository::class); + $flag = true; + $finance = []; + $profitsharing = []; + $financialRecordRepository = app()->make(FinancialRecordRepository::class); + $financeSn = $financialRecordRepository->getSn(); + $userMerchantRepository = app()->make(UserMerchantRepository::class); $storeOrderProfitsharingRepository = app()->make(StoreOrderProfitsharingRepository::class); - $uid = $groupOrder->uid; - $i = 1; - $isVipCoupon = app()->make(StoreGroupOrderRepository::class)->isVipCoupon($groupOrder); + $uid = $groupOrder->uid; + $i = 1; + $isVipCoupon = app()->make(StoreGroupOrderRepository::class)->isVipCoupon($groupOrder); //订单记录 $storeOrderStatusRepository = app()->make(StoreOrderStatusRepository::class); - $svipDiscount = 0; + $svipDiscount = 0; foreach ($groupOrder->orderList as $_k => $order) { - $order->paid = 1; + $order->paid = 1; $order->pay_time = $time; - $svipDiscount = bcadd($order->svip_discount, $svipDiscount, 2); + $svipDiscount = bcadd($order->svip_discount, $svipDiscount, 2); if (isset($subOrders[$order->order_sn])) { $order->transaction_id = $subOrders[$order->order_sn]['transaction_id']; } @@ -221,7 +222,7 @@ class StoreOrderRepository extends BaseRepository $_make = app()->make(ProductPresellSkuRepository::class); if ($order->orderProduct[0]['cart_info']['productPresell']['presell_type'] == 2) { $order->status = 10; - $presell = true; + $presell = true; } else { $_make->incCount($order->orderProduct[0]['activity_id'], $order->orderProduct[0]['product_sku'], 'two_pay'); } @@ -229,7 +230,7 @@ class StoreOrderRepository extends BaseRepository } else if ($order->activity_type == 4) { $order->status = 9; $order->save(); - $group_buying_id = app()->make(ProductGroupBuyingRepository::class)->create( + $group_buying_id = app()->make(ProductGroupBuyingRepository::class)->create( $groupOrder->user, $order->orderProduct[0]['cart_info']['activeSku']['product_group_id'], $order->orderProduct[0]['activity_id'], @@ -245,14 +246,14 @@ class StoreOrderRepository extends BaseRepository $order->verify_code = $this->verifyCode(); $order->save(); $orderStatus[] = [ - 'order_id' => $order->order_id, - 'order_sn' => $order->order_sn, - 'type' => $storeOrderStatusRepository::TYPE_ORDER, + 'order_id' => $order->order_id, + 'order_sn' => $order->order_sn, + 'type' => $storeOrderStatusRepository::TYPE_ORDER, 'change_message' => '订单支付成功', - 'change_type' => $storeOrderStatusRepository::ORDER_STATUS_PAY_SUCCCESS, - 'uid' => $order->uid, - 'nickname' => $order->user->nickname, - 'user_type' => $storeOrderStatusRepository::U_TYPE_USER, + 'change_type' => $storeOrderStatusRepository::ORDER_STATUS_PAY_SUCCCESS, + 'uid' => $order->uid, + 'nickname' => $order->user->nickname, + 'user_type' => $storeOrderStatusRepository::U_TYPE_USER, ]; //TODO 成为推广员 @@ -264,15 +265,15 @@ class StoreOrderRepository extends BaseRepository } $finance[] = [ - 'order_id' => $order->order_id, - 'order_sn' => $order->order_sn, - 'user_info' => $groupOrder->user->nickname, - 'user_id' => $uid, - 'financial_type' => $presell ? 'order_presell' : 'order', - 'financial_pm' => 1, - 'type' => $presell ? 2 : 1, - 'number' => $order->pay_price, - 'mer_id' => $order->mer_id, + 'order_id' => $order->order_id, + 'order_sn' => $order->order_sn, + 'user_info' => $groupOrder->user->nickname, + 'user_id' => $uid, + 'financial_type' => $presell ? 'order_presell' : 'order', + 'financial_pm' => 1, + 'type' => $presell ? 2 : 1, + 'number' => $order->pay_price, + 'mer_id' => $order->mer_id, 'financial_record_sn' => $financeSn . ($i++) ]; @@ -300,72 +301,72 @@ class StoreOrderRepository extends BaseRepository if (!$presell) { if ($order['extension_one'] > 0) { $finance[] = [ - 'order_id' => $order->order_id, - 'order_sn' => $order->order_sn, - 'user_info' => $groupOrder->user->nickname, - 'user_id' => $uid, - 'financial_type' => 'brokerage_one', - 'financial_pm' => 0, - 'type' => 1, - 'number' => $order['extension_one'], - 'mer_id' => $order->mer_id, + 'order_id' => $order->order_id, + 'order_sn' => $order->order_sn, + 'user_info' => $groupOrder->user->nickname, + 'user_id' => $uid, + 'financial_type' => 'brokerage_one', + 'financial_pm' => 0, + 'type' => 1, + 'number' => $order['extension_one'], + 'mer_id' => $order->mer_id, 'financial_record_sn' => $financeSn . ($i++) ]; } if ($order['extension_two'] > 0) { $finance[] = [ - 'order_id' => $order->order_id, - 'order_sn' => $order->order_sn, - 'user_info' => $groupOrder->user->nickname, - 'user_id' => $uid, - 'financial_type' => 'brokerage_two', - 'financial_pm' => 0, - 'type' => 1, - 'number' => $order['extension_two'], - 'mer_id' => $order->mer_id, + 'order_id' => $order->order_id, + 'order_sn' => $order->order_sn, + 'user_info' => $groupOrder->user->nickname, + 'user_id' => $uid, + 'financial_type' => 'brokerage_two', + 'financial_pm' => 0, + 'type' => 1, + 'number' => $order['extension_two'], + 'mer_id' => $order->mer_id, 'financial_record_sn' => $financeSn . ($i++) ]; } if ($order['commission_rate'] > 0) { $finance[] = [ - 'order_id' => $order->order_id, - 'order_sn' => $order->order_sn, - 'user_info' => $groupOrder->user->nickname, - 'user_id' => $uid, - 'financial_type' => 'order_charge', - 'financial_pm' => 0, - 'type' => 1, - 'number' => $_order_rate, - 'mer_id' => $order->mer_id, + 'order_id' => $order->order_id, + 'order_sn' => $order->order_sn, + 'user_info' => $groupOrder->user->nickname, + 'user_id' => $uid, + 'financial_type' => 'order_charge', + 'financial_pm' => 0, + 'type' => 1, + 'number' => $_order_rate, + 'mer_id' => $order->mer_id, 'financial_record_sn' => $financeSn . ($i++) ]; } $finance[] = [ - 'order_id' => $order->order_id, - 'order_sn' => $order->order_sn, - 'user_info' => $groupOrder->user->nickname, - 'user_id' => $uid, - 'financial_type' => 'order_true', - 'financial_pm' => 0, - 'type' => 2, - 'number' => $_payPrice, - 'mer_id' => $order->mer_id, + 'order_id' => $order->order_id, + 'order_sn' => $order->order_sn, + 'user_info' => $groupOrder->user->nickname, + 'user_id' => $uid, + 'financial_type' => 'order_true', + 'financial_pm' => 0, + 'type' => 2, + 'number' => $_payPrice, + 'mer_id' => $order->mer_id, 'financial_record_sn' => $financeSn . ($i++) ]; if ($order->platform_coupon_price > 0) { $finance[] = [ - 'order_id' => $order->order_id, - 'order_sn' => $order->order_sn, - 'user_info' => $groupOrder->user->nickname, - 'user_id' => $uid, - 'financial_type' => $isVipCoupon ? 'order_svip_coupon' : 'order_platform_coupon', - 'financial_pm' => 0, - 'type' => 1, - 'number' => $order->platform_coupon_price, - 'mer_id' => $order->mer_id, + 'order_id' => $order->order_id, + 'order_sn' => $order->order_sn, + 'user_info' => $groupOrder->user->nickname, + 'user_id' => $uid, + 'financial_type' => $isVipCoupon ? 'order_svip_coupon' : 'order_platform_coupon', + 'financial_pm' => 0, + 'type' => 1, + 'number' => $order->platform_coupon_price, + 'mer_id' => $order->mer_id, 'financial_record_sn' => $financeSn . ($i++) ]; $_payPrice = bcadd($_payPrice, $order->platform_coupon_price, 2); @@ -377,22 +378,22 @@ class StoreOrderRepository extends BaseRepository } if ($is_combine) { $profitsharing[] = [ - 'profitsharing_sn' => $storeOrderProfitsharingRepository->getOrderSn(), - 'order_id' => $order->order_id, - 'transaction_id' => $order->transaction_id ?? '', - 'mer_id' => $order->mer_id, - 'profitsharing_price' => $order->pay_price, + 'profitsharing_sn' => $storeOrderProfitsharingRepository->getOrderSn(), + 'order_id' => $order->order_id, + 'transaction_id' => $order->transaction_id ?? '', + 'mer_id' => $order->mer_id, + 'profitsharing_price' => $order->pay_price, 'profitsharing_mer_price' => $_payPrice, - 'type' => $storeOrderProfitsharingRepository::PROFITSHARING_TYPE_ORDER, + 'type' => $storeOrderProfitsharingRepository::PROFITSHARING_TYPE_ORDER, ]; } $userMerchantRepository->updatePayTime($uid, $order->mer_id, $order->pay_price); SwooleTaskService::merchant('notice', [ 'type' => 'new_order', 'data' => [ - 'title' => '新订单', + 'title' => '新订单', 'message' => '您有一个新的订单', - 'id' => $order->order_id + 'id' => $order->order_id ] ], $order->mer_id); //自动打印订单 @@ -403,8 +404,8 @@ class StoreOrderRepository extends BaseRepository Queue::push(UserBrokerageLevelJob::class, ['uid' => $groupOrder->user->spread_uid, 'type' => 'spread_money', 'inc' => $groupOrder->pay_price]); } app()->make(UserRepository::class)->update($groupOrder->uid, [ - 'pay_count' => Db::raw('pay_count+' . count($groupOrder->orderList)), - 'pay_price' => Db::raw('pay_price+' . $groupOrder->pay_price), + 'pay_count' => Db::raw('pay_count+' . count($groupOrder->orderList)), + 'pay_price' => Db::raw('pay_price+' . $groupOrder->pay_price), 'svip_save_money' => Db::raw('svip_save_money+' . $svipDiscount), ]); $this->giveIntegral($groupOrder); @@ -462,7 +463,7 @@ class StoreOrderRepository extends BaseRepository { list($msec, $sec) = explode(' ', microtime()); $msectime = number_format((floatval($msec) + floatval($sec)) * 1000, 0, '', ''); - $orderId = $type . $msectime . mt_rand(10000, max(intval($msec * 10000) + 10000, 98369)); + $orderId = $type . $msectime . mt_rand(10000, max(intval($msec * 10000) + 10000, 98369)); return $orderId; } @@ -474,7 +475,7 @@ class StoreOrderRepository extends BaseRepository */ public function productByTempNumber($cart) { - $type = $cart['product']['temp']['type']; + $type = $cart['product']['temp']['type']; $cartNum = $cart['cart_num']; if (!$type) return $cartNum; @@ -531,15 +532,15 @@ class StoreOrderRepository extends BaseRepository */ public function userOrderNumber(int $uid) { - $noPay = app()->make(StoreGroupOrderRepository::class)->orderNumber($uid); - $noPostage = $this->dao->search(['uid' => $uid, 'status' => 0, 'paid' => 1,'is_user' => 1])->where('StoreOrder.is_del', 0)->count(); - $all = $this->dao->search(['uid' => $uid, 'status' => -2,'is_user' => 1])->where('StoreOrder.is_del', 0)->count(); + $noPay = app()->make(StoreGroupOrderRepository::class)->orderNumber($uid); + $noPostage = $this->dao->search(['uid' => $uid, 'status' => 0, 'paid' => 1, 'is_user' => 1])->where('StoreOrder.is_del', 0)->count(); + $all = $this->dao->search(['uid' => $uid, 'status' => -2, 'is_user' => 1])->where('StoreOrder.is_del', 0)->count(); $noDeliver = $this->dao->search(['uid' => $uid, 'status' => 1, 'paid' => 1])->where('StoreOrder.is_del', 0)->count(); - $noComment = $this->dao->search(['uid' => $uid, 'status' => 2, 'paid' => 1,'is_user' => 1])->where('StoreOrder.is_del', 0)->count(); - $done = $this->dao->search(['uid' => $uid, 'status' => 3, 'paid' => 1,'is_user' => 1])->where('StoreOrder.is_del', 0)->count(); - $refund = app()->make(StoreRefundOrderRepository::class)->getWhereCount(['uid' => $uid, 'status' => [0, 1, 2]]); + $noComment = $this->dao->search(['uid' => $uid, 'status' => 2, 'paid' => 1, 'is_user' => 1])->where('StoreOrder.is_del', 0)->count(); + $done = $this->dao->search(['uid' => $uid, 'status' => 3, 'paid' => 1, 'is_user' => 1])->where('StoreOrder.is_del', 0)->count(); + $refund = app()->make(StoreRefundOrderRepository::class)->getWhereCount(['uid' => $uid, 'status' => [0, 1, 2]]); //$orderPrice = $this->dao->search(['uid' => $uid, 'paid' => 1])->sum('pay_price'); - $orderCount = $this->dao->search(['uid' => $uid, 'paid' => 1,'is_user' => 1])->count(); + $orderCount = $this->dao->search(['uid' => $uid, 'paid' => 1, 'is_user' => 1])->count(); return compact('noComment', 'done', 'refund', 'noDeliver', 'noPay', 'noPostage', 'orderCount', 'all'); } @@ -556,12 +557,12 @@ class StoreOrderRepository extends BaseRepository public function getDetail($id, $uid = null) { $where = []; - $with = [ + $with = [ 'orderProduct', 'merchant' => function ($query) { return $query->field('mer_id,mer_name,service_phone')->append(['services_type']); }, - 'receipt' => function ($query) { + 'receipt' => function ($query) { return $query->field('order_id,order_receipt_id'); }, 'takeOrderList.orderProduct' @@ -613,10 +614,10 @@ class StoreOrderRepository extends BaseRepository if ($groupOrder->give_integral > 0) { app()->make(UserBillRepository::class)->incBill($groupOrder->uid, 'integral', 'lock', [ 'link_id' => $groupOrder['group_order_id'], - 'status' => 0, - 'title' => '下单赠送积分', - 'number' => $groupOrder->give_integral, - 'mark' => '成功消费' . floatval($groupOrder['pay_price']) . '元,赠送积分' . floatval($groupOrder->give_integral), + 'status' => 0, + 'title' => '下单赠送积分', + 'number' => $groupOrder->give_integral, + 'mark' => '成功消费' . floatval($groupOrder['pay_price']) . '元,赠送积分' . floatval($groupOrder->give_integral), 'balance' => $groupOrder->user->integral ]); } @@ -633,22 +634,22 @@ class StoreOrderRepository extends BaseRepository $userBillRepository = app()->make(UserBillRepository::class); if ($order->spread_uid) { $spreadUid = $order->spread_uid; - $topUid = $order->top_uid; + $topUid = $order->top_uid; } else if ($order->is_selfbuy) { $spreadUid = $user->uid; - $topUid = $user->spread_uid; + $topUid = $user->spread_uid; } else { $spreadUid = $user->spread_uid; - $topUid = $user->top_uid; + $topUid = $user->top_uid; } //TODO 添加冻结佣金 if ($order->extension_one > 0 && $spreadUid) { $userBillRepository->incBill($spreadUid, 'brokerage', 'order_one', [ 'link_id' => $order['order_id'], - 'status' => 0, - 'title' => '获得推广佣金', - 'number' => $order->extension_one, - 'mark' => $user['nickname'] . '成功消费' . floatval($order['pay_price']) . '元,奖励推广佣金' . floatval($order->extension_one), + 'status' => 0, + 'title' => '获得推广佣金', + 'number' => $order->extension_one, + 'mark' => $user['nickname'] . '成功消费' . floatval($order['pay_price']) . '元,奖励推广佣金' . floatval($order->extension_one), 'balance' => 0 ]); $userRepository = app()->make(UserRepository::class); @@ -665,10 +666,10 @@ class StoreOrderRepository extends BaseRepository if ($order->extension_two > 0 && $topUid) { $userBillRepository->incBill($topUid, 'brokerage', 'order_two', [ 'link_id' => $order['order_id'], - 'status' => 0, - 'title' => '获得推广佣金', - 'number' => $order->extension_two, - 'mark' => $user['nickname'] . '成功消费' . floatval($order['pay_price']) . '元,奖励推广佣金' . floatval($order->extension_two), + 'status' => 0, + 'title' => '获得推广佣金', + 'number' => $order->extension_two, + 'mark' => $user['nickname'] . '成功消费' . floatval($order['pay_price']) . '元,奖励推广佣金' . floatval($order->extension_two), 'balance' => 0 ]); $userRepository = app()->make(UserRepository::class); @@ -719,7 +720,7 @@ class StoreOrderRepository extends BaseRepository if ($order['status'] != 1 || $order['order_type']) throw new ValidateException('订单状态有误'); $func = 'createUserLog'; - if (!$user){ + if (!$user) { $func = 'createSysLog'; $user = $order->user; } @@ -727,19 +728,19 @@ class StoreOrderRepository extends BaseRepository // // throw new ValidateException('用户不存在'); // } - $order->status = 2; + $order->status = 2; $order->verify_time = date('Y-m-d H:i:s'); event('order.take.before', compact('order')); //订单记录 $storeOrderStatusRepository = app()->make(StoreOrderStatusRepository::class); - $orderStatus = [ - 'order_id' => $order->order_id, - 'order_sn' => $order->order_sn, - 'type' => $storeOrderStatusRepository::TYPE_ORDER, + $orderStatus = [ + 'order_id' => $order->order_id, + 'order_sn' => $order->order_sn, + 'type' => $storeOrderStatusRepository::TYPE_ORDER, 'change_message' => '已收货', - 'change_type' => $storeOrderStatusRepository::ORDER_STATUS_TAKE, + 'change_type' => $storeOrderStatusRepository::ORDER_STATUS_TAKE, ]; - Db::transaction(function () use ($order, $user,$storeOrderStatusRepository,$orderStatus,$func) { + Db::transaction(function () use ($order, $user, $storeOrderStatusRepository, $orderStatus, $func) { $this->takeAfter($order, $user); $order->save(); $storeOrderStatusRepository->{$func}($orderStatus); @@ -758,21 +759,21 @@ class StoreOrderRepository extends BaseRepository */ public function OrderTitleNumber(?int $merId, ?int $orderType) { - $where = []; + $where = []; $sysDel = $merId ? 0 : null; //商户删除 if ($merId) $where['mer_id'] = $merId; //商户订单 if ($orderType === 0) $where['order_type'] = 0; //普通订单 if ($orderType === 1) $where['take_order'] = 1; //已核销订单 //1: 未支付 2: 未发货 3: 待收货 4: 待评价 5: 交易完成 6: 已退款 7: 已删除 - $all = $this->dao->search($where, $sysDel)->where($this->getOrderType(0))->count(); - $statusAll = $all; - $unpaid = $this->dao->search($where, $sysDel)->where($this->getOrderType(1))->count(); - $unshipped = $this->dao->search($where, $sysDel)->where($this->getOrderType(2))->count(); - $untake = $this->dao->search($where, $sysDel)->where($this->getOrderType(3))->count(); + $all = $this->dao->search($where, $sysDel)->where($this->getOrderType(0))->count(); + $statusAll = $all; + $unpaid = $this->dao->search($where, $sysDel)->where($this->getOrderType(1))->count(); + $unshipped = $this->dao->search($where, $sysDel)->where($this->getOrderType(2))->count(); + $untake = $this->dao->search($where, $sysDel)->where($this->getOrderType(3))->count(); $unevaluate = $this->dao->search($where, $sysDel)->where($this->getOrderType(4))->count(); - $complete = $this->dao->search($where, $sysDel)->where($this->getOrderType(5))->count(); - $refund = $this->dao->search($where, $sysDel)->where($this->getOrderType(6))->count(); - $del = $this->dao->search($where, $sysDel)->where($this->getOrderType(7))->count(); + $complete = $this->dao->search($where, $sysDel)->where($this->getOrderType(5))->count(); + $refund = $this->dao->search($where, $sysDel)->where($this->getOrderType(6))->count(); + $del = $this->dao->search($where, $sysDel)->where($this->getOrderType(7))->count(); return compact('all', 'statusAll', 'unpaid', 'unshipped', 'untake', 'unevaluate', 'complete', 'refund', 'del'); } @@ -781,23 +782,23 @@ class StoreOrderRepository extends BaseRepository { return [ [ - 'count' => $this->dao->search($where)->count(), - 'title' => '全部', + 'count' => $this->dao->search($where)->count(), + 'title' => '全部', 'order_type' => -1, ], [ - 'count' => $this->dao->search($where)->where('order_type', 0)->where('is_virtual', 0)->count(), - 'title' => '普通订单', + 'count' => $this->dao->search($where)->where('order_type', 0)->where('is_virtual', 0)->count(), + 'title' => '普通订单', 'order_type' => 0, ], [ - 'count' => $this->dao->search($where)->where('order_type', 1)->count(), - 'title' => '核销订单', + 'count' => $this->dao->search($where)->where('order_type', 1)->count(), + 'title' => '核销订单', 'order_type' => 1, ], [ - 'count' => $this->dao->search($where)->where('is_virtual', 1)->count(), - 'title' => '虚拟商品订单', + 'count' => $this->dao->search($where)->where('is_virtual', 1)->count(), + 'title' => '虚拟商品订单', 'order_type' => 2, ], ]; @@ -816,7 +817,7 @@ class StoreOrderRepository extends BaseRepository $param['paid'] = 0; break; // 未支付 case 2: - $param['paid'] = 1; + $param['paid'] = 1; $param['StoreOrder.status'] = 0; break; // 待发货 case 3: @@ -933,14 +934,14 @@ class StoreOrderRepository extends BaseRepository if ($order->activity_type == 2) { throw new ValidateException('预售订单不支持改价'); } - $extension_total = (float)bcadd($order->extension_one, $order->extension_two, 2); + $extension_total = (float)bcadd($order->extension_one, $order->extension_two, 2); $data['pay_price'] = $this->bcmathPrice($data['total_price'], $order['coupon_price'], $data['pay_postage']); if ($data['pay_price'] < 0) { throw new ValidateException('实际支付金额不能小于0'); } else if ($data['pay_price'] < $extension_total) { throw new ValidateException('实际支付金额不能小于佣金' . $extension_total); } - $make = app()->make(StoreGroupOrderRepository::class); + $make = app()->make(StoreGroupOrderRepository::class); $orderGroup = $make->dao->getWhere(['group_order_id' => $order['group_order_id']]); //总单总价格 @@ -954,17 +955,17 @@ class StoreOrderRepository extends BaseRepository $storeOrderStatusRepository = app()->make(StoreOrderStatusRepository::class); $orderStatus = [ - 'order_id' => $order->order_id, - 'order_sn' => $order->order_sn, - 'type' => $storeOrderStatusRepository::TYPE_ORDER, + 'order_id' => $order->order_id, + 'order_sn' => $order->order_sn, + 'type' => $storeOrderStatusRepository::TYPE_ORDER, 'change_message' => '订单价格修改', - 'change_type' => $storeOrderStatusRepository::ORDER_STATUS_CHANGE, + 'change_type' => $storeOrderStatusRepository::ORDER_STATUS_CHANGE, ]; - Db::transaction(function () use ($id, $data, $orderGroup, $order, $_group,$storeOrderStatusRepository,$orderStatus,$service_id) { - $orderGroup->total_price = $_group['total_price']; - $orderGroup->pay_price = $_group['pay_price']; - $orderGroup->pay_postage = $_group['pay_postage']; + Db::transaction(function () use ($id, $data, $orderGroup, $order, $_group, $storeOrderStatusRepository, $orderStatus, $service_id) { + $orderGroup->total_price = $_group['total_price']; + $orderGroup->pay_price = $_group['pay_price']; + $orderGroup->pay_postage = $_group['pay_postage']; $orderGroup->group_order_sn = $this->getNewOrderId(StoreOrderRepository::TYPE_SN_ORDER) . '0'; $orderGroup->save(); @@ -972,7 +973,7 @@ class StoreOrderRepository extends BaseRepository $this->changOrderProduct($id, $data); if ($service_id) { - $storeOrderStatusRepository->createServiceLog($service_id,$orderStatus); + $storeOrderStatusRepository->createServiceLog($service_id, $orderStatus); } else { $storeOrderStatusRepository->createAdminLog($orderStatus); } @@ -990,10 +991,10 @@ class StoreOrderRepository extends BaseRepository */ public function changOrderProduct(int $orderId, array $data) { - $make = app()->make(StoreOrderProductRepository::class); - $ret = $make->getSearch(['order_id' => $orderId])->field('order_product_id,product_num,product_price')->select(); - $count = $make->getSearch(['order_id' => $orderId])->sum('product_price'); - $_count = (count($ret->toArray()) - 1); + $make = app()->make(StoreOrderProductRepository::class); + $ret = $make->getSearch(['order_id' => $orderId])->field('order_product_id,product_num,product_price')->select(); + $count = $make->getSearch(['order_id' => $orderId])->sum('product_price'); + $_count = (count($ret->toArray()) - 1); $pay_price = $data['total_price']; foreach ($ret as $k => $item) { $_price = 0; @@ -1007,7 +1008,7 @@ class StoreOrderRepository extends BaseRepository if ($k == $_count) { $_price = $pay_price; } else { - $_reta = bcdiv($item->product_price, $count, 3); + $_reta = bcdiv($item->product_price, $count, 3); $_price = bcmul($_reta, $data['total_price'], 2); } @@ -1031,7 +1032,7 @@ class StoreOrderRepository extends BaseRepository { $_bcsub = bcsub($total, $old, 2); $_count = (bccomp($_bcsub, 0, 2) == -1) ? 0 : $_bcsub; - $count = bcadd($_count, $new, 2); + $count = bcadd($_count, $new, 2); return (bccomp($count, 0, 2) == -1) ? 0 : $count; } @@ -1068,7 +1069,7 @@ class StoreOrderRepository extends BaseRepository $where = [ 'order_id' => $id, ]; - $ret = $this->dao->getWhere($where); + $ret = $this->dao->getWhere($where); if ($ret['is_virtual']) throw new ValidateException('虚拟商品只能虚拟发货'); $cargo = ''; $count = 0; @@ -1077,11 +1078,11 @@ class StoreOrderRepository extends BaseRepository $count += $item['product_num']; } - $data['to_name'] = $ret['real_name']; - $data['to_tel'] = $ret['user_phone']; - $data['to_addr'] = $ret['user_address']; - $data['cargo'] = $cargo; - $data['count'] = $count; + $data['to_name'] = $ret['real_name']; + $data['to_tel'] = $ret['user_phone']; + $data['to_addr'] = $ret['user_address']; + $data['cargo'] = $cargo; + $data['count'] = $count; $data['order_sn'] = $ret['order_sn']; return $data; } @@ -1095,42 +1096,42 @@ class StoreOrderRepository extends BaseRepository */ public function batchDelivery(int $merId, array $params) { - $count = count($params['order_id']); + $count = count($params['order_id']); $import = app()->make(StoreImportRepository::class)->create($merId, 'delivery', $params['delivery_type']); - $make = app()->make(StoreImportDeliveryRepository::class); - $data = []; - $num = 0; + $make = app()->make(StoreImportDeliveryRepository::class); + $data = []; + $num = 0; foreach ($params['order_id'] as $item) { $ret = $this->dao->getWhere(['order_id' => $params['order_id']]); $imp = [ - 'order_sn' => $ret['order_sn'] ?? $item, - 'delivery_id' => $params['delivery_id'], + 'order_sn' => $ret['order_sn'] ?? $item, + 'delivery_id' => $params['delivery_id'], 'delivery_type' => $params['delivery_type'], 'delivery_name' => $params['delivery_name'], - 'import_id' => $import['import_id'], - 'mer_id' => $merId + 'import_id' => $import['import_id'], + 'mer_id' => $merId ]; - if (!$ret || $ret['status'] != 1 || $ret['mer_id'] != $merId || $ret['is_del'] != 0 || $ret['paid'] != 1 || $ret['delivery_type'] != 0 ) { + if (!$ret || $ret['status'] != 1 || $ret['mer_id'] != $merId || $ret['is_del'] != 0 || $ret['paid'] != 1 || $ret['delivery_type'] != 0) { $imp['status'] = 0; - $imp['mark'] = '订单信息不存在或状态错误'; + $imp['mark'] = '订单信息不存在或状态错误'; } else { try { if ($params['delivery_type'] == 4) { - $dump = [ - 'temp_id' => $params['temp_id'], - 'from_tel' => $params['from_tel'], - 'from_addr' => $params['from_addr'], - 'from_name' => $params['from_name'], + $dump = [ + 'temp_id' => $params['temp_id'], + 'from_tel' => $params['from_tel'], + 'from_addr' => $params['from_addr'], + 'from_name' => $params['from_name'], 'delivery_name' => $params['delivery_name'], ]; - $dump = $this->orderDumpInfo($item, $dump, $merId); - $ret = $this->dump($item, $merId, $dump); - $imp['delivery_id'] = $ret['delivery_id']; + $dump = $this->orderDumpInfo($item, $dump, $merId); + $ret = $this->dump($item, $merId, $dump); + $imp['delivery_id'] = $ret['delivery_id']; $imp['delivery_name'] = $ret['delivery_name']; } else { - $this->delivery($item, $merId,[ - 'delivery_id' => $params['delivery_id'], + $this->delivery($item, $merId, [ + 'delivery_id' => $params['delivery_id'], 'delivery_type' => $params['delivery_type'], 'delivery_name' => $params['delivery_name'], ]); @@ -1139,7 +1140,7 @@ class StoreOrderRepository extends BaseRepository $imp['status'] = 1; } catch (Exception $exception) { $imp['status'] = 0; - $imp['mark'] = $exception->getMessage(); + $imp['mark'] = $exception->getMessage(); } } $data[] = $imp; @@ -1169,52 +1170,52 @@ class StoreOrderRepository extends BaseRepository $data = $this->orderDumpInfo($id, $data, $merId); $data['com'] = $data['delivery_name']; - $result = app()->make(CrmebServeServices::class)->express()->dump($merId, $data); + $result = app()->make(CrmebServeServices::class)->express()->dump($merId, $data); if (!isset($result['kuaidinum'])) throw new ValidateException('打印失败'); $delivery = [ 'delivery_type' => 4, 'delivery_name' => $data['delivery_name'], - 'delivery_id' => $result['kuaidinum'], - 'remark' => $data['remark'] ?? '', + 'delivery_id' => $result['kuaidinum'], + 'remark' => $data['remark'] ?? '', ]; $dump = [ 'delivery_name' => $delivery['delivery_name'], - 'delivery_id' => $delivery['delivery_id'], - 'from_name' => $data['from_name'], - 'order_sn' => $data['order_sn'], - 'to_name' => $data['to_name'], + 'delivery_id' => $delivery['delivery_id'], + 'from_name' => $data['from_name'], + 'order_sn' => $data['order_sn'], + 'to_name' => $data['to_name'], ]; Db::transaction(function () use ($merId, $id, $delivery, $make, $dump, $service_id) { - $this->delivery($id, $merId, $delivery,$service_id); + $this->delivery($id, $merId, $delivery, $service_id); $arr = [ - 'type' => 'mer_dump', - 'num' => -1, + 'type' => 'mer_dump', + 'num' => -1, 'message' => '电子面单', - 'info' => $dump + 'info' => $dump ]; app()->make(ProductCopyRepository::class)->add($arr, $merId); }); return $delivery; } - public function runDelivery($id, $merId, $data, $split, $method,$service_id = 0) + public function runDelivery($id, $merId, $data, $split, $method, $service_id = 0) { - return Db::transaction(function () use ($id, $merId, $data, $split, $method,$service_id) { + return Db::transaction(function () use ($id, $merId, $data, $split, $method, $service_id) { if ($split['is_split'] && !empty($split['split'])) { foreach ($split['split'] as $v) { $splitData[$v['id']] = $v['num']; } - $order = $this->dao->get($id); - $newOrder = app()->make(StoreOrderSplitRepository::class)->splitOrder($order, $splitData,$service_id); - if ($newOrder){ + $order = $this->dao->get($id); + $newOrder = app()->make(StoreOrderSplitRepository::class)->splitOrder($order, $splitData, $service_id); + if ($newOrder) { $id = $newOrder->order_id; } else { throw new ValidateException('商品不能全部拆单'); } } - return $this->{$method}($id, $merId, $data,$service_id); + return $this->{$method}($id, $merId, $data, $service_id); }); } @@ -1229,7 +1230,7 @@ class StoreOrderRepository extends BaseRepository public function delivery($id, $merId, $data, $service_id = 0) { $data['status'] = 1; - $order = $this->dao->get($id); + $order = $this->dao->get($id); if ($order['is_virtual'] && $data['delivery_type'] != 3) throw new ValidateException('虚拟商品只能虚拟发货'); //订单记录 @@ -1239,18 +1240,18 @@ class StoreOrderRepository extends BaseRepository $exprss = app()->make(ExpressRepository::class)->getWhere(['code' => $data['delivery_name']]); if (!$exprss) throw new ValidateException('快递公司不存在'); $data['delivery_name'] = $exprss['name']; - $change_type = $statusRepository::ORDER_DELIVERY_COURIER; - $change_message = '订单已配送【快递名称】:' . $exprss['name'] . '; 【快递单号】:' . $data['delivery_id']; - $temp_code = 'DELIVER_GOODS_CODE'; + $change_type = $statusRepository::ORDER_DELIVERY_COURIER; + $change_message = '订单已配送【快递名称】:' . $exprss['name'] . '; 【快递单号】:' . $data['delivery_id']; + $temp_code = 'DELIVER_GOODS_CODE'; break; case 2: if (!preg_match("/^1[3456789]{1}\d{9}$/", $data['delivery_id'])) throw new ValidateException('手机号格式错误'); - $change_type = 'delivery_1'; + $change_type = 'delivery_1'; $change_message = '订单已配送【送货人姓名】:' . $data['delivery_name'] . '; 【手机号】:' . $data['delivery_id']; - $temp_code = 'ORDER_DELIVER_SUCCESS'; + $temp_code = 'ORDER_DELIVER_SUCCESS'; break; case 3: - $change_type = $statusRepository::ORDER_DELIVERY_NOTHING; + $change_type = $statusRepository::ORDER_DELIVERY_NOTHING; $change_message = '订单已配送【虚拟发货】'; $data['status'] = 2; break; @@ -1258,9 +1259,9 @@ class StoreOrderRepository extends BaseRepository $exprss = app()->make(ExpressRepository::class)->getWhere(['code' => $data['delivery_name']]); if (!$exprss) throw new ValidateException('快递公司不存在'); $data['delivery_name'] = $exprss['name']; - $change_type = $statusRepository::ORDER_DELIVERY_COURIER; - $change_message = '订单已配送【快递名称】:' . $exprss['name'] . '; 【快递单号】:' . $data['delivery_id']; - $temp_code = 'DELIVER_GOODS_CODE'; + $change_type = $statusRepository::ORDER_DELIVERY_COURIER; + $change_message = '订单已配送【快递名称】:' . $exprss['name'] . '; 【快递单号】:' . $data['delivery_id']; + $temp_code = 'DELIVER_GOODS_CODE'; break; } @@ -1268,32 +1269,34 @@ class StoreOrderRepository extends BaseRepository $this->dao->update($id, $data); $orderStatus = [ - 'order_id' => $order->order_id, - 'order_sn' => $order->order_sn, - 'type' => $statusRepository::TYPE_ORDER, + 'order_id' => $order->order_id, + 'order_sn' => $order->order_sn, + 'type' => $statusRepository::TYPE_ORDER, 'change_message' => $change_message, - 'change_type' => $change_type, + 'change_type' => $change_type, ]; if ($service_id) { - $statusRepository->createServiceLog($service_id,$orderStatus); + $statusRepository->createServiceLog($service_id, $orderStatus); } else { $statusRepository->createAdminLog($orderStatus); } //虚拟发货后用户直接确认收获 - if($data['status'] == 2){ + if ($data['status'] == 2) { $user = app()->make(UserRepository::class)->get($order['uid']); //订单记录 - $this->takeAfter($order,$user); + $this->takeAfter($order, $user); $orderStatus = [ - 'order_id' => $order->order_id, - 'order_sn' => $order->order_sn, - 'type' => $statusRepository::TYPE_ORDER, + 'order_id' => $order->order_id, + 'order_sn' => $order->order_sn, + 'type' => $statusRepository::TYPE_ORDER, 'change_message' => '虚拟发货后', - 'change_type' => $statusRepository::ORDER_STATUS_TAKE, + 'change_type' => $statusRepository::ORDER_STATUS_TAKE, ]; $statusRepository->createSysLog($orderStatus); + // 添加收货记录 + event('order.take', compact('order')); } if (isset($temp_code)) Queue::push(SendSmsJob::class, ['tempId' => $temp_code, 'id' => $order->order_id]); @@ -1312,24 +1315,24 @@ class StoreOrderRepository extends BaseRepository */ public function cityDelivery(int $id, int $merId, array $data, $service_id) { - $make = app()->make(DeliveryOrderRepository::class); + $make = app()->make(DeliveryOrderRepository::class); $order = $this->dao->get($id); if ($order['is_virtual']) throw new ValidateException('虚拟商品只能虚拟发货'); $make->create($id, $merId, $data, $order); //订单记录 $storeOrderStatusRepository = app()->make(StoreOrderStatusRepository::class); - $this->dao->update($id, ['delivery_type' => 5, 'status' => 1,'remark' => $data['remark']]); + $this->dao->update($id, ['delivery_type' => 5, 'status' => 1, 'remark' => $data['remark']]); $orderStatus = [ - 'order_id' => $id, - 'order_sn' => $order->order_sn, - 'type' => $storeOrderStatusRepository::TYPE_ORDER, + 'order_id' => $id, + 'order_sn' => $order->order_sn, + 'type' => $storeOrderStatusRepository::TYPE_ORDER, 'change_message' => '订单配送【同城配送】', - 'change_type' => $storeOrderStatusRepository::ORDER_DELIVERY_SELF, + 'change_type' => $storeOrderStatusRepository::ORDER_DELIVERY_SELF, ]; if ($service_id) { - $storeOrderStatusRepository->createServiceLog($service_id,$orderStatus); + $storeOrderStatusRepository->createServiceLog($service_id, $orderStatus); } else { $storeOrderStatusRepository->createAdminLog($orderStatus); } @@ -1342,24 +1345,24 @@ class StoreOrderRepository extends BaseRepository { $where = [$this->getPk() => $id]; if ($merId) { - $whre['mer_id'] = $merId; + $whre['mer_id'] = $merId; $whre['is_system_del'] = 0; } $res = $this->dao->getWhere($where, '*', [ - 'orderProduct', - 'user' => function ($query) { - $query->field('uid,real_name,nickname,is_svip,svip_endtime,phone'); - }, - 'refundOrder' => function ($query) { - $query->field('order_id,extension_one,extension_two,refund_price,integral')->where('status', 3); - }, - 'finalOrder', - 'TopSpread' => function ($query) { - $query->field('uid,nickname,avatar'); - }, - 'spread' => function ($query) { - $query->field('uid,nickname,avatar'); - }, + 'orderProduct', + 'user' => function ($query) { + $query->field('uid,real_name,nickname,is_svip,svip_endtime,phone'); + }, + 'refundOrder' => function ($query) { + $query->field('order_id,extension_one,extension_two,refund_price,integral')->where('status', 3); + }, + 'finalOrder', + 'TopSpread' => function ($query) { + $query->field('uid,nickname,avatar'); + }, + 'spread' => function ($query) { + $query->field('uid,nickname,avatar'); + }, ] ); if (!$res) throw new ValidateException('数据不存在'); @@ -1405,18 +1408,18 @@ class StoreOrderRepository extends BaseRepository public function adminMerGetList($where, $page, $limit) { $where['paid'] = 1; - $query = $this->dao->search($where, null); - $count = $query->count(); - $list = $query->with([ + $query = $this->dao->search($where, null); + $count = $query->count(); + $list = $query->with([ 'orderProduct', - 'merchant' => function ($query) { + 'merchant' => function ($query) { $query->field('mer_id,mer_name,is_trader'); }, 'groupOrder' => function ($query) { $query->field('group_order_id,group_order_sn'); }, 'finalOrder', - 'user' => function ($query) { + 'user' => function ($query) { $query->field('uid,nickname,avatar'); }, ])->page($page, $limit)->select()->append(['refund_extension_one', 'refund_extension_two']); @@ -1426,18 +1429,18 @@ class StoreOrderRepository extends BaseRepository public function reconList($where, $page, $limit) { - $ids = app()->make(MerchantReconciliationOrderRepository::class)->getIds($where); + $ids = app()->make(MerchantReconciliationOrderRepository::class)->getIds($where); $query = $this->dao->search([], null)->whereIn('order_id', $ids); $count = $query->count(); - $list = $query->with(['orderProduct'])->page($page, $limit)->select()->each(function ($item) { + $list = $query->with(['orderProduct'])->page($page, $limit)->select()->each(function ($item) { //(实付金额 - 一级佣金 - 二级佣金) * 抽成 $commission_rate = ($item['commission_rate'] / 100); //佣金 $_order_extension = bcadd($item['extension_one'], $item['extension_two'], 3); //手续费 = (实付金额 - 一级佣金 - 二级佣金) * 比例 - $_order_rate = bcmul(bcsub($item['pay_price'], $_order_extension, 3), $commission_rate, 3); + $_order_rate = bcmul(bcsub($item['pay_price'], $_order_extension, 3), $commission_rate, 3); $item['order_extension'] = round($_order_extension, 2); - $item['order_rate'] = round($_order_rate, 2); + $item['order_rate'] = round($_order_rate, 2); return $item; }); @@ -1458,7 +1461,7 @@ class StoreOrderRepository extends BaseRepository $query = $this->dao->search($where)->where($this->getOrderType($status)) ->with([ 'orderProduct', - 'merchant' => function ($query) { + 'merchant' => function ($query) { $query->field('mer_id,mer_name'); }, 'verifyService' => function ($query) { @@ -1466,26 +1469,26 @@ class StoreOrderRepository extends BaseRepository }, 'finalOrder', 'groupUser.groupBuying', - 'TopSpread' => function ($query) { + 'TopSpread' => function ($query) { $query->field('uid,nickname,avatar'); }, - 'spread' => function ($query) { + 'spread' => function ($query) { $query->field('uid,nickname,avatar'); }, ]); $count = $query->count(); - $list = $query->page($page, $limit)->select()->append(['refund_extension_one', 'refund_extension_two']) - ->each(function($item){ + $list = $query->page($page, $limit)->select()->append(['refund_extension_one', 'refund_extension_two']) + ->each(function ($item) { // 1:退款中 2:部分退款 3 = 全退 $refunding = 0; if ($item['orderProduct']) { - $is_refund = array_column($item['orderProduct']->toArray(),'is_refund'); + $is_refund = array_column($item['orderProduct']->toArray(), 'is_refund'); $is_refund = array_unique($is_refund); - if (in_array(1,$is_refund)) { + if (in_array(1, $is_refund)) { $refunding = 1; - } else if (in_array(2,$is_refund)) { + } else if (in_array(2, $is_refund)) { $refunding = 2; - } else if (in_array(3,$is_refund)) { + } else if (in_array(3, $is_refund)) { $refunding = 3; } } @@ -1512,29 +1515,29 @@ class StoreOrderRepository extends BaseRepository $query = $this->dao->search($where, null)->where($this->getOrderType($status)) ->with([ 'orderProduct', - 'merchant' => function ($query) { + 'merchant' => function ($query) { return $query->field('mer_id,mer_name,is_trader'); }, 'verifyService' => function ($query) { return $query->field('service_id,nickname'); }, - 'groupOrder' => function ($query) { + 'groupOrder' => function ($query) { $query->field('group_order_id,group_order_sn'); }, 'finalOrder', 'groupUser.groupBuying', - 'TopSpread' => function ($query) { + 'TopSpread' => function ($query) { $query->field('uid,nickname,avatar'); }, - 'spread' => function ($query) { + 'spread' => function ($query) { $query->field('uid,nickname,avatar'); }, - 'user' => function ($query) { + 'user' => function ($query) { $query->field('uid,nickname,avatar'); }, ]); $count = $query->count(); - $list = $query->page($page, $limit)->select()->append(['refund_extension_one', 'refund_extension_two']); + $list = $query->page($page, $limit)->select()->append(['refund_extension_one', 'refund_extension_two']); return compact('count', 'list'); } @@ -1542,7 +1545,7 @@ class StoreOrderRepository extends BaseRepository public function getStat(array $where, $status) { unset($where['status']); - $make = app()->make(StoreRefundOrderRepository::class); + $make = app()->make(StoreRefundOrderRepository::class); $presellOrderRepository = app()->make(PresellOrderRepository::class); //退款订单id @@ -1552,70 +1555,70 @@ class StoreOrderRepository extends BaseRepository //实际支付订单数量 $all = $this->dao->search($where)->where($this->getOrderType($status))->where('paid', 1)->count(); //实际支付订单金额 - $countQuery = $this->dao->search($where)->where($this->getOrderType($status))->where('paid', 1); + $countQuery = $this->dao->search($where)->where($this->getOrderType($status))->where('paid', 1); $countOrderId = $countQuery->column('order_id'); - $countPay1 = $countQuery->sum('StoreOrder.pay_price'); - $countPay2 = $presellOrderRepository->search(['paid' => 1, 'order_ids' => $countOrderId])->sum('pay_price'); - $countPay = bcadd($countPay1, $countPay2, 2); + $countPay1 = $countQuery->sum('StoreOrder.pay_price'); + $countPay2 = $presellOrderRepository->search(['paid' => 1, 'order_ids' => $countOrderId])->sum('pay_price'); + $countPay = bcadd($countPay1, $countPay2, 2); //余额支付 - $banclQuery = $this->dao->search(array_merge($where, ['paid' => 1, 'pay_type' => 0]))->where($this->getOrderType($status)); + $banclQuery = $this->dao->search(array_merge($where, ['paid' => 1, 'pay_type' => 0]))->where($this->getOrderType($status)); $banclOrderId = $banclQuery->column('order_id'); - $banclPay1 = $banclQuery->sum('StoreOrder.pay_price'); - $banclPay2 = $presellOrderRepository->search(['pay_type' => [0], 'paid' => 1, 'order_ids' => $banclOrderId])->sum('pay_price'); - $banclPay = bcadd($banclPay1, $banclPay2, 2); + $banclPay1 = $banclQuery->sum('StoreOrder.pay_price'); + $banclPay2 = $presellOrderRepository->search(['pay_type' => [0], 'paid' => 1, 'order_ids' => $banclOrderId])->sum('pay_price'); + $banclPay = bcadd($banclPay1, $banclPay2, 2); //微信金额 - $wechatQuery = $this->dao->search($where)->where($this->getOrderType($status))->where('paid', 1)->where('pay_type', 'in', [1, 2, 3, 6]); + $wechatQuery = $this->dao->search($where)->where($this->getOrderType($status))->where('paid', 1)->where('pay_type', 'in', [1, 2, 3, 6]); $wechatOrderId = $wechatQuery->column('order_id'); - $wechatPay1 = $wechatQuery->sum('StoreOrder.pay_price'); - $wechatPay2 = $presellOrderRepository->search(['pay_type' => [1, 2, 3, 6], 'paid' => 1, 'order_ids' => $wechatOrderId])->sum('pay_price'); - $wechatPay = bcadd($wechatPay1, $wechatPay2, 2); + $wechatPay1 = $wechatQuery->sum('StoreOrder.pay_price'); + $wechatPay2 = $presellOrderRepository->search(['pay_type' => [1, 2, 3, 6], 'paid' => 1, 'order_ids' => $wechatOrderId])->sum('pay_price'); + $wechatPay = bcadd($wechatPay1, $wechatPay2, 2); //支付宝金额 - $aliQuery = $this->dao->search($where)->where($this->getOrderType($status))->where('paid', 1)->where('pay_type', 'in', [4, 5]); + $aliQuery = $this->dao->search($where)->where($this->getOrderType($status))->where('paid', 1)->where('pay_type', 'in', [4, 5]); $aliOrderId = $aliQuery->column('order_id'); - $aliPay1 = $aliQuery->sum('StoreOrder.pay_price'); - $aliPay2 = $presellOrderRepository->search(['pay_type' => [4, 5], 'paid' => 1, 'order_ids' => $aliOrderId])->sum('pay_price'); - $aliPay = bcadd($aliPay1, $aliPay2, 2); + $aliPay1 = $aliQuery->sum('StoreOrder.pay_price'); + $aliPay2 = $presellOrderRepository->search(['pay_type' => [4, 5], 'paid' => 1, 'order_ids' => $aliOrderId])->sum('pay_price'); + $aliPay = bcadd($aliPay1, $aliPay2, 2); $stat = [ [ 'className' => 'el-icon-s-goods', - 'count' => $all, - 'field' => '件', - 'name' => '已支付订单数量' + 'count' => $all, + 'field' => '件', + 'name' => '已支付订单数量' ], [ 'className' => 'el-icon-s-order', - 'count' => (float)$countPay, - 'field' => '元', - 'name' => '实际支付金额' + 'count' => (float)$countPay, + 'field' => '元', + 'name' => '实际支付金额' ], [ 'className' => 'el-icon-s-cooperation', - 'count' => (float)$orderRefund, - 'field' => '元', - 'name' => '已退款金额' + 'count' => (float)$orderRefund, + 'field' => '元', + 'name' => '已退款金额' ], [ 'className' => 'el-icon-s-cooperation', - 'count' => (float)$wechatPay, - 'field' => '元', - 'name' => '微信支付金额' + 'count' => (float)$wechatPay, + 'field' => '元', + 'name' => '微信支付金额' ], [ 'className' => 'el-icon-s-finance', - 'count' => (float)$banclPay, - 'field' => '元', - 'name' => '余额支付金额' + 'count' => (float)$banclPay, + 'field' => '元', + 'name' => '余额支付金额' ], [ 'className' => 'el-icon-s-cooperation', - 'count' => (float)$aliPay, - 'field' => '元', - 'name' => '支付宝支付金额' + 'count' => (float)$aliPay, + 'field' => '元', + 'name' => '支付宝支付金额' ], ]; return $stat; @@ -1636,14 +1639,14 @@ class StoreOrderRepository extends BaseRepository { $query = $this->dao->search($where)->where('StoreOrder.is_del', 0); $count = $query->count(); - $list = $query->with([ + $list = $query->with([ 'orderProduct', 'presellOrder', 'merchant' => function ($query) { return $query->field('mer_id,mer_name'); }, 'community', - 'receipt' => function ($query) { + 'receipt' => function ($query) { return $query->field('order_id,order_receipt_id'); }, ])->page($page, $limit)->order('pay_time DESC')->append(['refund_status'])->select(); @@ -1661,17 +1664,17 @@ class StoreOrderRepository extends BaseRepository unset($order['takeOrderList']); } - return compact( 'count','list'); + return compact('count', 'list'); } public function userList($uid, $page, $limit) { $query = $this->dao->search([ - 'uid' => $uid, + 'uid' => $uid, 'paid' => 1 ]); $count = $query->count(); - $list = $query->page($page, $limit)->select(); + $list = $query->page($page, $limit)->select(); return compact('count', 'list'); } @@ -1679,12 +1682,12 @@ class StoreOrderRepository extends BaseRepository public function userMerList($uid, $merId, $page, $limit) { $query = $this->dao->search([ - 'uid' => $uid, + 'uid' => $uid, 'mer_id' => $merId, - 'paid' => 1 + 'paid' => 1 ]); $count = $query->count(); - $list = $query->with(['presellOrder'])->page($page, $limit)->select(); + $list = $query->with(['presellOrder'])->page($page, $limit)->select(); foreach ($list as $order) { if ($order->activity_type == 2 && $order->status >= 0 && $order->status < 10 && $order->presellOrder) { $order->pay_price = bcadd($order->pay_price, $order->presellOrder->pay_price, 2); @@ -1707,8 +1710,8 @@ class StoreOrderRepository extends BaseRepository throw new ValidateException('打印功能未开启'); $config = [ 'clientId' => merchantConfig($merId, 'printing_client_id'), - 'apiKey' => merchantConfig($merId, 'printing_api_key'), - 'partner' => merchantConfig($merId, 'develop_id'), + 'apiKey' => merchantConfig($merId, 'printing_api_key'), + 'partner' => merchantConfig($merId, 'develop_id'), 'terminal' => merchantConfig($merId, 'terminal_number') ]; if (!$config['clientId'] || !$config['apiKey'] || !$config['partner'] || !$config['terminal']) @@ -1731,33 +1734,33 @@ class StoreOrderRepository extends BaseRepository }]); foreach ($order['orderProduct'] as $item) { $product[] = [ - 'store_name' => $item['cart_info']['product']['store_name'] . '【' . $item['cart_info']['productAttr']['sku'] . '】', - 'product_num' => $item['product_num'], - 'price' => bcdiv($item['product_price'], $item['product_num'], 2), + 'store_name' => $item['cart_info']['product']['store_name'] . '【' . $item['cart_info']['productAttr']['sku'] . '】', + 'product_num' => $item['product_num'], + 'price' => bcdiv($item['product_price'], $item['product_num'], 2), 'product_price' => $item['product_price'], ]; } - $data = [ - 'order_sn' => $order['order_sn'], - 'pay_time' => $order['pay_time'], - 'real_name' => $order['real_name'], - 'user_phone' => $order['user_phone'], - 'user_address' => $order['user_address'], - 'total_price' => $order['total_price'], - 'coupon_price' => $order['coupon_price'], - 'pay_price' => $order['pay_price'], + $data = [ + 'order_sn' => $order['order_sn'], + 'pay_time' => $order['pay_time'], + 'real_name' => $order['real_name'], + 'user_phone' => $order['user_phone'], + 'user_address' => $order['user_address'], + 'total_price' => $order['total_price'], + 'coupon_price' => $order['coupon_price'], + 'pay_price' => $order['pay_price'], 'total_postage' => $order['total_postage'], - 'pay_postage' => $order['pay_postage'], - 'mark' => $order['mark'], + 'pay_postage' => $order['pay_postage'], + 'mark' => $order['mark'], ]; - $config = $this->checkPrinterConfig($merId); + $config = $this->checkPrinterConfig($merId); $printer = new Printer('yi_lian_yun', $config); event('order.print.before', compact('order')); $res = $printer->setPrinterContent([ - 'name' => $order['merchant']['mer_name'], + 'name' => $order['merchant']['mer_name'], 'orderInfo' => $data, - 'product' => $product + 'product' => $product ])->startPrinter(); event('order.print', compact('order', 'res')); @@ -1773,36 +1776,36 @@ class StoreOrderRepository extends BaseRepository foreach ($order['orderProduct'] as $item) { $product[] = [ - 'store_name' => $item['cart_info']['product']['store_name'] . '【' . $item['cart_info']['productAttr']['sku'] . '】', - 'product_num' => $item['product_num'], - 'price' => bcdiv($item['product_price'], $item['product_num'], 2), + 'store_name' => $item['cart_info']['product']['store_name'] . '【' . $item['cart_info']['productAttr']['sku'] . '】', + 'product_num' => $item['product_num'], + 'price' => bcdiv($item['product_price'], $item['product_num'], 2), 'product_price' => $item['product_price'], ]; } $data = [ - 'order_sn' => $order['order_sn'], - 'order_type' => $order['order_type'], - 'pay_time' => $order['pay_time'], - 'real_name' => $order['real_name'], - 'user_phone' => $order['user_phone'], - 'user_address' => $order['user_address'], - 'total_price' => $order['total_price'], - 'coupon_price' => $order['coupon_price'], - 'pay_price' => $order['pay_price'], + 'order_sn' => $order['order_sn'], + 'order_type' => $order['order_type'], + 'pay_time' => $order['pay_time'], + 'real_name' => $order['real_name'], + 'user_phone' => $order['user_phone'], + 'user_address' => $order['user_address'], + 'total_price' => $order['total_price'], + 'coupon_price' => $order['coupon_price'], + 'pay_price' => $order['pay_price'], 'total_postage' => $order['total_postage'], 'pay_postage' => $order['pay_postage'], - 'mark' => $order['mark'], + 'mark' => $order['mark'], ]; $printer = app()->make(StorePrinterRepository::class)->getPrinter($merId); event('order.print.before', compact('order')); foreach ($printer as $config) { $printer = new Printer('yi_lian_yun', $config); - $res = $printer->setPrinterContent([ - 'name' => $order['merchant']['mer_name'], + $res = $printer->setPrinterContent([ + 'name' => $order['merchant']['mer_name'], 'orderInfo' => $data, - 'product' => $product + 'product' => $product ])->startPrinter(); } @@ -1812,7 +1815,7 @@ class StoreOrderRepository extends BaseRepository public function verifyOrder(int $id, int $merId, array $data, $serviceId = 0) { - $order = $this->dao->getWhere(['order_id' => $id, 'mer_id' => $merId,'verify_code' => $data['verify_code'],'order_type' => 1],'*',['orderProduct']); + $order = $this->dao->getWhere(['order_id' => $id, 'mer_id' => $merId, 'verify_code' => $data['verify_code'], 'order_type' => 1], '*', ['orderProduct']); if (!$order) throw new ValidateException('订单不存在'); if (!$order->paid) throw new ValidateException('订单未支付'); if ($order['status']) throw new ValidateException('订单已全部核销,请勿重复操作'); @@ -1821,24 +1824,24 @@ class StoreOrderRepository extends BaseRepository } $spl = app()->make(StoreOrderSplitRepository::class)->splitOrder($order, $splitData, $serviceId, 1); if ($spl) $order = $spl; - $order->status = 2; - $order->verify_time = date('Y-m-d H:i:s'); + $order->status = 2; + $order->verify_time = date('Y-m-d H:i:s'); $order->verify_service_id = $serviceId; event('order.verify.before', compact('order')); //订单记录 $storeOrderStatusRepository = app()->make(StoreOrderStatusRepository::class); - Db::transaction(function () use ($order,$storeOrderStatusRepository,$serviceId) { + Db::transaction(function () use ($order, $storeOrderStatusRepository, $serviceId) { $this->takeAfter($order, $order->user); $order->save(); $orderStatus = [ - 'order_id' => $order->order_id, - 'order_sn' => $order->order_sn, - 'type' => $storeOrderStatusRepository::TYPE_ORDER, + 'order_id' => $order->order_id, + 'order_sn' => $order->order_sn, + 'type' => $storeOrderStatusRepository::TYPE_ORDER, 'change_message' => '订单已核销', - 'change_type' => $storeOrderStatusRepository::ORDER_STATUS_TAKE, + 'change_type' => $storeOrderStatusRepository::ORDER_STATUS_TAKE, ]; - if ($serviceId){ - $storeOrderStatusRepository->createServiceLog($serviceId,$orderStatus); + if ($serviceId) { + $storeOrderStatusRepository->createServiceLog($serviceId, $orderStatus); } else { $storeOrderStatusRepository->createAdminLog($orderStatus); } @@ -1849,10 +1852,10 @@ class StoreOrderRepository extends BaseRepository public function wxQrcode($orderId, $verify_code) { - $siteUrl = systemConfig('site_url'); - $name = md5('owx' . $orderId . date('Ymd')) . '.jpg'; + $siteUrl = systemConfig('site_url'); + $name = md5('owx' . $orderId . date('Ymd')) . '.jpg'; $attachmentRepository = app()->make(AttachmentRepository::class); - $imageInfo = $attachmentRepository->getWhere(['attachment_name' => $name]); + $imageInfo = $attachmentRepository->getWhere(['attachment_name' => $name]); if (isset($imageInfo['attachment_src']) && strstr($imageInfo['attachment_src'], 'http') !== false && curl_file_exist($imageInfo['attachment_src']) === false) { $imageInfo->delete(); @@ -1867,8 +1870,8 @@ class StoreOrderRepository extends BaseRepository $attachmentRepository->create(systemConfig('upload_type') ?: 1, -2, $orderId, [ 'attachment_category_id' => 0, - 'attachment_name' => $imageInfo['name'], - 'attachment_src' => $imageInfo['dir'] + 'attachment_name' => $imageInfo['name'], + 'attachment_src' => $imageInfo['dir'] ]); $urlCode = $imageInfo['dir']; } else $urlCode = $imageInfo['attachment_src']; @@ -1884,13 +1887,13 @@ class StoreOrderRepository extends BaseRepository */ public function seckillOrderCounut(int $productId) { - $where = [ - 'activity_id' => $productId, + $where = [ + 'activity_id' => $productId, 'product_type' => 1, - 'day' => date('Y-m-d', time()) + 'day' => date('Y-m-d', time()) ]; - $count = $this->dao->getTattendCount($where, null)->count(); - $count_ = $this->dao->getSeckillRefundCount($where, 2); + $count = $this->dao->getTattendCount($where, null)->count(); + $count_ = $this->dao->getSeckillRefundCount($where, 2); $count__ = $this->dao->getSeckillRefundCount($where, 1); return $count - $count_ - $count__; } @@ -1904,13 +1907,13 @@ class StoreOrderRepository extends BaseRepository */ public function seckillSkuOrderCounut(string $sku) { - $where = [ - 'product_sku' => $sku, + $where = [ + 'product_sku' => $sku, 'product_type' => 1, - 'day' => date('Y-m-d', time()) + 'day' => date('Y-m-d', time()) ]; - $count = $this->dao->getTattendCount($where, null)->count(); - $count_ = $this->dao->getSeckillRefundCount($where, 2); + $count = $this->dao->getTattendCount($where, null)->count(); + $count_ = $this->dao->getSeckillRefundCount($where, 2); $count__ = $this->dao->getSeckillRefundCount($where, 1); return $count - $count_ - $count__; } @@ -1924,12 +1927,12 @@ class StoreOrderRepository extends BaseRepository */ public function skuSalesCount(string $sku) { - $where = [ - 'product_sku' => $sku, + $where = [ + 'product_sku' => $sku, 'product_type' => 1, ]; - $count = $this->dao->getTattendSuccessCount($where, null)->count(); - $count_ = $this->dao->getSeckillRefundCount($where, 2); + $count = $this->dao->getTattendSuccessCount($where, null)->count(); + $count_ = $this->dao->getSeckillRefundCount($where, 2); $count__ = $this->dao->getSeckillRefundCount($where, 1); return $count - $count_ - $count__; } @@ -1944,14 +1947,14 @@ class StoreOrderRepository extends BaseRepository */ public function getDayPayCount(int $uid, int $productId) { - $make = app()->make(StoreSeckillActiveRepository::class); + $make = app()->make(StoreSeckillActiveRepository::class); $active = $make->getWhere(['product_id' => $productId]); if ($active['once_pay_count'] == 0) return true; $where = [ - 'activity_id' => $productId, + 'activity_id' => $productId, 'product_type' => 1, - 'day' => date('Y-m-d', time()) + 'day' => date('Y-m-d', time()) ]; $count = $this->dao->getTattendCount($where, $uid)->count(); @@ -1968,13 +1971,13 @@ class StoreOrderRepository extends BaseRepository */ public function getPayCount(int $uid, int $productId) { - $make = app()->make(StoreSeckillActiveRepository::class); + $make = app()->make(StoreSeckillActiveRepository::class); $active = $make->getWhere(['product_id' => $productId]); if ($active['all_pay_count'] == 0) return true; $where = [ - 'activity_id' => $productId, + 'activity_id' => $productId, 'product_type' => 1, - 'day' => date('Y-m-d', time()) + 'day' => date('Y-m-d', time()) ]; $count = $this->dao->getTattendCount($where, $uid)->count(); return ($active['all_pay_count'] > $count); @@ -1990,7 +1993,7 @@ class StoreOrderRepository extends BaseRepository public function checkRefundStatusById(int $orderId, int $refundId) { return Db::transaction(function () use ($orderId, $refundId) { - $res = $this->dao->search(['order_id' => $orderId])->with(['orderProduct'])->find(); + $res = $this->dao->search(['order_id' => $orderId])->with(['orderProduct'])->find(); $refund = app()->make(StoreRefundOrderRepository::class)->getRefundCount($orderId, $refundId); if ($refund) return false; foreach ($res['orderProduct'] as $item) { @@ -2012,7 +2015,7 @@ class StoreOrderRepository extends BaseRepository app()->make(StoreDiscountRepository::class)->incStock($order->orderProduct[0]['activity_id']); } $mainId = $order->main_id ?: $order->order_id; - $count = $this->query([])->where('status', '<>', -1)->where(function ($query) use ($mainId) { + $count = $this->query([])->where('status', '<>', -1)->where(function ($query) use ($mainId) { $query->where('order_id', $mainId)->whereOr('main_id', $mainId); })->count(); //拆单后完全退完 @@ -2038,12 +2041,12 @@ class StoreOrderRepository extends BaseRepository } //订单记录 $storeOrderStatusRepository = app()->make(StoreOrderStatusRepository::class); - $orderStatus = [ - 'order_id' => $order->order_id, - 'order_sn' => $order->order_sn, - 'type' => $storeOrderStatusRepository::TYPE_ORDER, + $orderStatus = [ + 'order_id' => $order->order_id, + 'order_sn' => $order->order_sn, + 'type' => $storeOrderStatusRepository::TYPE_ORDER, 'change_message' => '订单已全部退款', - 'change_type' => $storeOrderStatusRepository::ORDER_STATUS_REFUND_ALL, + 'change_type' => $storeOrderStatusRepository::ORDER_STATUS_REFUND_ALL, ]; $storeOrderStatusRepository->createSysLog($orderStatus); @@ -2073,15 +2076,15 @@ class StoreOrderRepository extends BaseRepository { //订单记录 $storeOrderStatusRepository = app()->make(StoreOrderStatusRepository::class); - $orderStatus = [ - 'order_id' => $order->order_id, - 'order_sn' => $order->order_sn, - 'type' => $storeOrderStatusRepository::TYPE_ORDER, + $orderStatus = [ + 'order_id' => $order->order_id, + 'order_sn' => $order->order_sn, + 'type' => $storeOrderStatusRepository::TYPE_ORDER, 'change_message' => $info, - 'change_type' => $storeOrderStatusRepository::ORDER_STATUS_DELETE, + 'change_type' => $storeOrderStatusRepository::ORDER_STATUS_DELETE, ]; - $productRepository = app()->make(ProductRepository::class); - Db::transaction(function () use ($info, $order, $orderStatus, $storeOrderStatusRepository,$productRepository) { + $productRepository = app()->make(ProductRepository::class); + Db::transaction(function () use ($info, $order, $orderStatus, $storeOrderStatusRepository, $productRepository) { $order->is_del = 1; $order->save(); $storeOrderStatusRepository->createUserLog($orderStatus); @@ -2108,20 +2111,20 @@ class StoreOrderRepository extends BaseRepository public function sendProductForm($id, $data) { $express = app()->make(ExpressRepository::class)->options(); - $form = Elm::createForm(Route::buildUrl('merchantStoreOrderDelivery', ['id' => $id])->build()); + $form = Elm::createForm(Route::buildUrl('merchantStoreOrderDelivery', ['id' => $id])->build()); if (in_array($data['delivery_type'], [1, 2])) { if ($data['delivery_type'] == 1) { $form->setRule([ Elm::hidden('delivery_type', 1), [ - 'type' => 'span', - 'title' => '原快递名称', + 'type' => 'span', + 'title' => '原快递名称', 'children' => [(string)$data['delivery_name']] ], [ - 'type' => 'span', - 'title' => '原快递单号', + 'type' => 'span', + 'title' => '原快递单号', 'children' => [(string)$data['delivery_id']] ], Elm::select('delivery_name', '快递名称')->options(function () use ($express) { @@ -2133,13 +2136,13 @@ class StoreOrderRepository extends BaseRepository $form->setRule([ Elm::hidden('delivery_type', 2), [ - 'type' => 'span', - 'title' => '原送货人姓名', + 'type' => 'span', + 'title' => '原送货人姓名', 'children' => [(string)$data['delivery_name']] ], [ - 'type' => 'span', - 'title' => '原手机号', + 'type' => 'span', + 'title' => '原手机号', 'children' => [(string)$data['delivery_id']] ], Elm::input('delivery_name', '送货人姓名')->required(), @@ -2151,8 +2154,8 @@ class StoreOrderRepository extends BaseRepository $form->setRule([ Elm::hidden('delivery_type', 3), [ - 'type' => 'span', - 'title' => '发货类型', + 'type' => 'span', + 'title' => '发货类型', 'children' => ['无需配送'] ] ]); @@ -2167,7 +2170,7 @@ class StoreOrderRepository extends BaseRepository ])->control([ [ 'value' => 1, - 'rule' => [ + 'rule' => [ Elm::select('delivery_name', '快递名称')->options(function () use ($express) { return $express; }), @@ -2176,14 +2179,14 @@ class StoreOrderRepository extends BaseRepository ], [ 'value' => 2, - 'rule' => [ + 'rule' => [ Elm::input('delivery_name', '送货人姓名')->required(), Elm::input('delivery_id', '手机号')->required(), ] ], [ 'value' => 3, - 'rule' => [] + 'rule' => [] ], ]), @@ -2208,18 +2211,18 @@ class StoreOrderRepository extends BaseRepository $import_id = $arrary['import_id']; Db::transaction(function () use ($data, $merId, $import_id) { $result = []; - $num = 0; - $count = 0; + $num = 0; + $count = 0; $status = 0; foreach ($data as $datum) { $value = []; - $ret = []; + $ret = []; if ($datum['where']) { $count = $count + 1; if (empty($datum['value']['delivery_id'])) { $mark = '发货单号为空'; } else { - $ret = $this->getSearch([]) + $ret = $this->getSearch([]) ->where('status', 0) ->where('paid', 1) ->where('order_type', 0) @@ -2230,23 +2233,23 @@ class StoreOrderRepository extends BaseRepository } if ($ret) { try { - $value = array_merge($datum['value'], ['status' => 1]); + $value = array_merge($datum['value'], ['status' => 1]); $value['delivery_type'] = 1; $this->delivery($ret['order_id'], $merId, $value); $status = 1; - $mark = ''; + $mark = ''; $num = $num + 1; } catch (\Exception $exception) { $mark = $exception->getMessage(); } } - $datum['where']['mark'] = $mark; - $datum['where']['mer_id'] = $merId; - $datum['where']['status'] = $status; + $datum['where']['mark'] = $mark; + $datum['where']['mer_id'] = $merId; + $datum['where']['status'] = $status; $datum['where']['import_id'] = $import_id; - $result[] = array_merge($datum['where'], $datum['value']); + $result[] = array_merge($datum['where'], $datum['value']); } } // 记录入库操作 @@ -2265,17 +2268,17 @@ class StoreOrderRepository extends BaseRepository * @author Qinii * @day 2023/2/22 */ - public function childrenList($id,$merId) + public function childrenList($id, $merId) { - $data = $this->dao->get($id); - $query = $this->dao->getSearch([])->with(['orderProduct'])->where('order_id','<>',$id); - if ($merId) $query->where('mer_id',$merId); + $data = $this->dao->get($id); + $query = $this->dao->getSearch([])->with(['orderProduct'])->where('order_id', '<>', $id); + if ($merId) $query->where('mer_id', $merId); if ($data['main_id']) { - $query->where(function($query) use($data,$id){ - $query->where('main_id',$data['main_id'])->whereOr('order_id',$data['main_id']); + $query->where(function ($query) use ($data, $id) { + $query->where('main_id', $data['main_id'])->whereOr('order_id', $data['main_id']); }); } else { - $query->where('main_id',$id); + $query->where('main_id', $id); } return $query->select(); } diff --git a/app/common/repositories/system/HuitongRepository.php b/app/common/repositories/system/HuitongRepository.php new file mode 100644 index 0000000..b9beb35 --- /dev/null +++ b/app/common/repositories/system/HuitongRepository.php @@ -0,0 +1,37 @@ + +// +---------------------------------------------------------------------- +namespace app\common\repositories\system; + +use app\common\dao\store\order\StoreOrderDao; +use app\common\dao\system\HuitongDao; +use app\common\repositories\BaseRepository; + + +/** + * Class StoreOrderRepository + * @package app\common\repositories\store\order + * @author xaboy + * @day 2020/6/9 + * @mixin StoreOrderDao + */ +class HuitongRepository extends BaseRepository +{ + /** + * StoreOrderRepository constructor. + * @param HuitongDao $dao + */ + public function __construct(HuitongDao $dao) + { + $this->dao = $dao; + } + +} diff --git a/app/common/repositories/user/UserAssetsLogRepository.php b/app/common/repositories/user/UserAssetsLogRepository.php index c51ac46..dfd9247 100644 --- a/app/common/repositories/user/UserAssetsLogRepository.php +++ b/app/common/repositories/user/UserAssetsLogRepository.php @@ -15,6 +15,7 @@ namespace app\common\repositories\user; use app\common\dao\user\UserAssetsLogDao; use app\common\repositories\BaseRepository; +use app\common\repositories\store\order\StoreOrderBaseRepository; use app\common\repositories\store\product\ProductAssistRepository; use app\common\repositories\store\product\ProductRepository; use app\common\repositories\system\groupData\GroupDataRepository; @@ -128,8 +129,9 @@ class UserAssetsLogRepository extends BaseRepository public function userPayEvent($groupOrder) { // 配置信息 - $config = $this->groupDataRepository->getGroupDataLst(0, 100, 1, 100); - $config = array_column($config['list'], "value", 'key'); + $config = $this->userAssetsRepository->getConfig(); + + $baseList = array(); foreach ($groupOrder['orderList'] as $orderItem) { $base = 0; @@ -147,6 +149,7 @@ class UserAssetsLogRepository extends BaseRepository $this->userAssets($orderItem, $config, $base); if ($base) { + $baseList[] = array('order_id' => $orderItem['order_id'], 'base' => $base); // 2. 项目经理资产 $startProjectUid = $this->projectAssets($orderItem, $config, $base); // 3. 培育经理资产 @@ -163,6 +166,9 @@ class UserAssetsLogRepository extends BaseRepository // 6. 商户和平台资产 $this->merchantAndPlatformAssets($orderItem); } + if ($baseList) { + app(StoreOrderBaseRepository::class)->insertBase($baseList); + } } @@ -201,7 +207,7 @@ class UserAssetsLogRepository extends BaseRepository ); } $this->addLog($logList); - $this->userAssetsRepository->orderEvent($user['uid'], self::STATUS_FROZEN, compact('consume', 'welfare', 'huitong', 'contribution')); + $this->userAssetsRepository->changeEvent($user['uid'], self::STATUS_FROZEN, compact('consume', 'welfare', 'huitong', 'contribution')); } @@ -290,7 +296,7 @@ class UserAssetsLogRepository extends BaseRepository $log['ext'] = $ext; $this->addLog([$log]); - $this->userAssetsRepository->orderEvent($user['uid'], self::STATUS_FROZEN, compact('consume', 'welfare', 'huitong', 'contribution')); + $this->userAssetsRepository->changeEvent($user['uid'], self::STATUS_FROZEN, compact('consume', 'welfare', 'huitong', 'contribution')); } /** @@ -333,7 +339,7 @@ class UserAssetsLogRepository extends BaseRepository ); $this->addLog($logList); - $this->userAssetsRepository->orderEvent($user['uid'], self::STATUS_FROZEN, compact('consume', 'welfare', 'huitong', 'contribution')); + $this->userAssetsRepository->changeEvent($user['uid'], self::STATUS_FROZEN, compact('consume', 'welfare', 'huitong', 'contribution')); } @@ -401,7 +407,7 @@ class UserAssetsLogRepository extends BaseRepository 'count' => $contribution, ); $this->addLog($logList); - $this->userAssetsRepository->orderEvent($userProject['uid'], self::STATUS_FROZEN, compact('consume', 'welfare', 'huitong', 'contribution')); + $this->userAssetsRepository->changeEvent($userProject['uid'], self::STATUS_FROZEN, compact('consume', 'welfare', 'huitong', 'contribution')); } @@ -481,7 +487,7 @@ class UserAssetsLogRepository extends BaseRepository 'count' => $contribution, ); $this->addLog($logList); - $this->userAssetsRepository->orderEvent($userProject['uid'], self::STATUS_FROZEN, compact('consume', 'welfare', 'huitong', 'contribution')); + $this->userAssetsRepository->changeEvent($userProject['uid'], self::STATUS_FROZEN, compact('consume', 'welfare', 'huitong', 'contribution')); return $userProject['spread_uid']; } @@ -554,7 +560,7 @@ class UserAssetsLogRepository extends BaseRepository ); } $this->addLog($logList); - $this->userAssetsRepository->orderEvent($orderItem['uid'], self::STATUS_FROZEN, compact('consume', 'welfare', 'huitong', 'contribution')); + $this->userAssetsRepository->changeEvent($orderItem['uid'], self::STATUS_FROZEN, compact('consume', 'welfare', 'huitong', 'contribution')); // 5. 本人使用的福利积分 if ($orderItem['integral']) { @@ -567,15 +573,35 @@ class UserAssetsLogRepository extends BaseRepository 'count' => $orderItem['integral'], ); $this->addLog([$log]); - $this->userAssetsRepository->orderEvent($orderItem['uid'], self::STATUS_USED, compact('consume', 'welfare', 'huitong', 'contribution')); + $this->userAssetsRepository->changeEvent($orderItem['uid'], self::STATUS_USED, compact('consume', 'welfare', 'huitong', 'contribution')); } } - public function userTakeEvent() + /** + * notes 订单收货事件处理 + * @param $orderItem + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException + * @create 2024/3/19 15:03 + * @update 2024/3/19 15:03 + * @author zhangkxiang + * @editor + */ + public function userTakeEvent($orderItem) { + // 订单发送冻结资产发放 + $refundList = $this->_getOrderData($orderItem['order_id'], self::STATUS_FROZEN); + if ($refundList) { + foreach ($refundList as $refund) { + $this->userAssetsRepository->changeEvent($refund['uid'], self::STATUS_SUCCESS, $refund); + } + } + // 更新该订单的所有数据为退款状态 + $this->dao->updateOrderStatus($orderItem['order_id'], self::STATUS_SUCCESS); } /** @@ -595,7 +621,7 @@ class UserAssetsLogRepository extends BaseRepository $refundList = $this->_getOrderData($orderItem['order_id'], self::STATUS_FROZEN); if ($refundList) { foreach ($refundList as $refund) { - $this->userAssetsRepository->orderEvent($refund['uid'], self::STATUS_REFUND, $refund); + $this->userAssetsRepository->changeEvent($refund['uid'], self::STATUS_REFUND, $refund); } } @@ -603,7 +629,7 @@ class UserAssetsLogRepository extends BaseRepository $usedList = $this->_getOrderData($orderItem['order_id'], self::STATUS_USED); if ($usedList) { foreach ($usedList as $used) { - if($used['welfare'] > 0){ + if ($used['welfare'] > 0) { $info = $this->userAssetsRepository->get($used['uid']); $this->userAssetsRepository->update($used['uid'], array('welfare' => $info['welfare'] + $used['welfare'])); } diff --git a/app/common/repositories/user/UserAssetsRepository.php b/app/common/repositories/user/UserAssetsRepository.php index de1762b..ecaf457 100644 --- a/app/common/repositories/user/UserAssetsRepository.php +++ b/app/common/repositories/user/UserAssetsRepository.php @@ -15,6 +15,8 @@ namespace app\common\repositories\user; use app\common\dao\user\UserAssetsDao; use app\common\repositories\BaseRepository; +use app\common\repositories\store\order\StoreOrderBaseRepository; +use app\common\repositories\system\groupData\GroupDataRepository; use think\db\exception\DataNotFoundException; use think\db\exception\DbException; use think\db\exception\ModelNotFoundException; @@ -31,6 +33,16 @@ class UserAssetsRepository extends BaseRepository $this->dao = $dao; } + public function getConfig(){ + // 配置信息 + /** + * @var GroupDataRepository $groupDataRepository + */ + $groupDataRepository = app()->make(GroupDataRepository::class); + $config = $groupDataRepository->getGroupDataLst(0, 100, 1, 100); + return array_column($config['list'], "value", 'key'); + } + /** * notes 获取用户资产 @@ -63,7 +75,7 @@ class UserAssetsRepository extends BaseRepository /** - * notes 订单状态发生变更,影响用户资产 + * notes 用户资产变更 * @param $uid * @param $status * @param $data @@ -75,7 +87,7 @@ class UserAssetsRepository extends BaseRepository * @author zhangkxiang * @editor */ - public function orderEvent($uid, $status, $data = array()) + public function changeEvent($uid, $status, $data = array()) { $assets = array(); $info = $this->dao->get($uid); @@ -129,4 +141,59 @@ class UserAssetsRepository extends BaseRepository $this->dao->create($assets); } } + + + /** + * notes 分红福利积分 + * @throws DataNotFoundException + * @throws DbException + * @throws ModelNotFoundException + * @create 2024/3/19 21:03 + * @update 2024/3/19 21:03 + * @author zhangkxiang + * @editor + */ + public function sharePoint(){ + $config = $this->getConfig(); + /** + * @var StoreOrderBaseRepository $orderBase + */ + $orderBase = app()->make(StoreOrderBaseRepository::class); + $count = $orderBase->getTotalBase(date('Y-m-d', strtotime('-1day'))); + if(empty($count)){ + return ; + } + $shareData = $this->dao->getShareData(); + if(!$shareData['total']){ + return ; + } + + $base = round($config['share_award'] * $count / 100, 2); + if($base < 0.01){ + $base = 0.01; + } + $logList = array(); + foreach ($shareData['list'] as $item){ + $welfare = $base / $shareData['total'] * $item['share_point']; + if($welfare < 0.01){ + $welfare = 0.01; + } + + $logList[] = array( + 'uid' => $item['uid'], + 'asset_type' => UserAssetsLogRepository::ASSET_TYPE_WELFARE, + 'type' => UserAssetsLogRepository::CHANGE_TYPE_SHARE_GET, + 'status' => UserAssetsLogRepository::STATUS_SUCCESS, + 'count' => $welfare, + ); + // 增加福利积分 + $this->changeEvent($item['uid'],UserAssetsLogRepository::STATUS_SUCCESS, array('welfare' => $welfare)); + + } + + // 增加记录 + $logRepository = app()->make(UserAssetsLogRepository::class); + $logRepository->addLog($logList); + + } } diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index e9491a5..c04ab9c 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -58,8 +58,10 @@ class Auth extends BaseController // $json = '{"groupOrder":{"uid":3,"group_order_sn":"wxo1710768193328392661","total_postage":"0.00","total_price":"100.00","total_num":1,"real_name":"\u5f20\u51ef\u7fd4","user_phone":"18362705640","user_address":"\u6c5f\u82cf\u5357\u4eac\u5e02\u6816\u971e\u533a\u5c27\u5316\u8857\u9053\u4e1c\u57ce\u4e16\u5bb6(\u5357\u4eac\u5e02\u6816\u971e\u533a\u5c27\u8fb0\u8def3\u53f7)24\u680b501","pay_price":"100.00","coupon_price":"0.00","pay_postage":"0.00","cost":"0.00","coupon_id":"","pay_type":0,"give_coupon_ids":[],"integral":"0","integral_price":"0.00","give_integral":"100","create_time":"2024-03-18 21:23:13","group_order_id":"32","paid":1,"pay_time":"2024-03-18 21:23:13","is_combine":0,"orderList":[{"order_id":33,"main_id":0,"group_order_id":32,"order_sn":"wxo1710768193328392661","uid":3,"spread_uid":0,"top_uid":1,"district_id":3378,"real_name":"\u5f20\u51ef\u7fd4","user_phone":"18362705640","user_address":"\u6c5f\u82cf\u5357\u4eac\u5e02\u6816\u971e\u533a\u5c27\u5316\u8857\u9053\u4e1c\u57ce\u4e16\u5bb6(\u5357\u4eac\u5e02\u6816\u971e\u533a\u5c27\u8fb0\u8def3\u53f7)24\u680b501","cart_id":"77","total_num":1,"total_price":"100.00","total_postage":"0.00","pay_price":"100.00","pay_postage":"0.00","is_selfbuy":0,"extension_one":"0.00","extension_two":"1.20","commission_rate":"30.0000","integral":0,"integral_price":"0.00","give_integral":100,"coupon_id":"","coupon_price":"0.00","platform_coupon_price":"0.00","svip_discount":"0.00","order_type":0,"paid":1,"pay_time":"2024-03-18 21:23:13","pay_type":0,"create_time":"2024-03-18 21:23:13","status":0,"delivery_type":null,"is_virtual":0,"delivery_name":null,"delivery_id":null,"mark":"","remark":null,"admin_mark":null,"verify_code":null,"verify_time":null,"verify_service_id":null,"transaction_id":null,"activity_type":0,"order_extend":null,"mer_id":6,"reconciliation_id":0,"cost":"0.00","is_del":0,"is_system_del":0,"verify_status":0,"user":{"uid":3,"wechat_user_id":3,"account":"18362705640","pwd":"$2y$10$wYWu1Xc.pUqVwldOM3C\/EenyUPFg8DGlVbZuT.H9cIh.YtANOFmK6","real_name":"","sex":0,"birthday":null,"card_id":"","mark":"","label_id":[],"group_id":0,"agent_district_id":0,"agent_district":"","mer_id":1,"nickname":"\u5fae\u4fe1\u7528\u6237","avatar":"https:\/\/thirdwx.qlogo.cn\/mmopen\/vi_32\/POgEwh4mIHO4nibH0KlMECNjjGxQUq24ZEaGT4poC6icRiccVGKSyXwibcPq4BWmiaIGuG1icwxaQX6grC9VemZoJ8rg\/132","phone":"18362705640","addres":null,"cancel_time":null,"create_time":"2024-03-09 22:48:59","last_time":"2024-03-18 13:24:57","last_ip":"180.98.131.161","now_money":"8020.00","brokerage_price":"0.00","status":1,"spread_uid":2,"spread_time":"2024-03-09 22:48:59","spread_limit":null,"brokerage_level":0,"user_type":"routine","promoter_time":null,"is_promoter":0,"main_uid":0,"pay_count":13,"pay_price":"2060.10","spread_count":0,"spread_pay_count":0,"spread_pay_price":"0.00","integral":2070,"member_level":0,"member_value":0,"count_start":0,"count_fans":0,"is_svip":-1,"svip_endtime":null,"svip_save_money":"0.00"},"orderProduct":[{"order_product_id":33,"order_id":33,"uid":3,"cart_id":77,"product_id":203,"extension_one":"0.00","extension_two":"1.20","integral":0,"integral_price":"0.00","integral_total":0,"coupon_price":"0.00","platform_coupon_price":null,"svip_discount":"0.00","postage_price":"0.00","product_sku":"78c5e599c2a0","is_refund":0,"product_num":1,"product_type":0,"activity_id":203,"refund_num":1,"is_reply":0,"cost":"0.00","product_price":"100.00","total_price":"100.00","cart_info":{"product":{"product_id":203,"cate_id":17,"image":"http:\/\/b2.njrenzhou.com\/uploads\/def\/20240314\/e3c14a605d720c3429b6793abbb74e4b.jpg","store_name":"\u6d4b\u8bd5\u5546\u54c1","is_show":1,"status":1,"is_del":0,"unit_name":"\u7247","price":"100.00","mer_status":1,"temp_id":6,"give_coupon_ids":[],"is_gift_bag":0,"is_used":1,"product_type":0,"old_product_id":0,"integral_rate":-1,"delivery_way":"2","delivery_free":0,"type":0,"extend":"","pay_limit":0,"once_max_count":0,"once_min_count":0,"mer_svip_status":1,"svip_price_type":0,"temp":{"shipping_template_id":6,"name":"\u9ed8\u8ba4\u6a21\u677f","type":1,"appoint":0,"undelivery":0,"mer_id":6,"is_default":0,"sort":0,"create_time":"2022-04-24 15:29:04","info":null,"region":[],"undelives":null,"free":[]}},"productAttr":{"image":"http:\/\/b2.njrenzhou.com\/uploads\/def\/20240314\/e3c14a605d720c3429b6793abbb74e4b.jpg","extension_one":"0.00","extension_two":"0.00","product_id":203,"stock":195,"price":"100.00","unique":"78c5e599c2a0","sku":"","volume":"0.00","weight":"0.00","ot_price":"0.00","cost":"0.00","svip_price":"0.00","show_svip_price":false,"product":{"product_id":203,"mer_id":6,"store_name":"\u6d4b\u8bd5\u5546\u54c1","store_info":"dssssss","keyword":"\u6d4b\u8bd5","bar_code":"","brand_id":120,"is_show":1,"status":1,"is_del":0,"mer_status":1,"cate_id":17,"unit_name":"\u7247","sort":0,"rank":0,"sales":5,"price":"100.00","cost":"0.00","ot_price":"0.00","stock":195,"is_hot":1,"is_benefit":0,"is_best":0,"is_new":0,"is_good":1,"product_type":0,"ficti":0,"browse":0,"code_path":"","video_link":"","temp_id":6,"spec_type":0,"extension_type":0,"refusal":null,"rate":"3.0","reply_count":0,"give_coupon_ids":[],"is_gift_bag":0,"create_time":"2024-03-14 20:48:53","care_count":0,"is_used":1,"old_product_id":0,"image":"http:\/\/b2.njrenzhou.com\/uploads\/def\/20240314\/e3c14a605d720c3429b6793abbb74e4b.jpg","slider_image":["http:\/\/b2.njrenzhou.com\/uploads\/def\/20240314\/e3c14a605d720c3429b6793abbb74e4b.jpg"],"guarantee_template_id":0,"once_max_count":0,"once_min_count":0,"integral_rate":-1,"integral_total":0,"integral_price_total":"0.00","labels":"","delivery_way":"2","delivery_free":0,"type":0,"extend":"","pay_limit":0,"svip_price_type":0,"svip_price":0,"mer_svip_status":1,"param_temp_id":"","cash_rate":100,"base":20},"bc_extension_one":2,"bc_extension_two":1},"product_type":0},"create_time":"2024-03-18 21:23:13"}]}],"user":{"uid":3,"wechat_user_id":3,"account":"18362705640","pwd":"$2y$10$wYWu1Xc.pUqVwldOM3C\/EenyUPFg8DGlVbZuT.H9cIh.YtANOFmK6","real_name":"","sex":0,"birthday":null,"card_id":"","mark":"","label_id":[],"group_id":0,"agent_district_id":0,"agent_district":"","mer_id":1,"nickname":"\u5fae\u4fe1\u7528\u6237","avatar":"https:\/\/thirdwx.qlogo.cn\/mmopen\/vi_32\/POgEwh4mIHO4nibH0KlMECNjjGxQUq24ZEaGT4poC6icRiccVGKSyXwibcPq4BWmiaIGuG1icwxaQX6grC9VemZoJ8rg\/132","phone":"18362705640","addres":null,"cancel_time":null,"create_time":"2024-03-09 22:48:59","last_time":"2024-03-18 13:24:57","last_ip":"180.98.131.161","now_money":"8020.00","brokerage_price":"0.00","status":1,"spread_uid":2,"spread_time":"2024-03-09 22:48:59","spread_limit":null,"brokerage_level":0,"user_type":"routine","promoter_time":null,"is_promoter":0,"main_uid":0,"pay_count":13,"pay_price":"2060.10","spread_count":0,"spread_pay_count":0,"spread_pay_price":"0.00","integral":2070,"member_level":0,"member_value":0,"count_start":0,"count_fans":0,"is_svip":-1,"svip_endtime":null,"svip_save_money":"0.00"}}}'; // event("order.paySuccess", json_decode($json, true)); - $json = '{"order":{"order_id":33,"main_id":0,"group_order_id":27,"order_sn":"wxo1710646722542760291","uid":3,"spread_uid":0,"top_uid":0,"district_id":3378,"real_name":"\u5f20\u51ef\u7fd4","user_phone":"18362705640","user_address":"\u6c5f\u82cf\u5357\u4eac\u5e02\u6816\u971e\u533a\u5c27\u5316\u8857\u9053\u4e1c\u57ce\u4e16\u5bb6(\u5357\u4eac\u5e02\u6816\u971e\u533a\u5c27\u8fb0\u8def3\u53f7)24\u680b501","cart_id":"69","total_num":1,"total_price":"180.00","total_postage":"0.00","pay_price":"180.00","pay_postage":"0.00","is_selfbuy":0,"extension_one":"0.00","extension_two":"0.00","commission_rate":"5.0000","integral":0,"integral_price":"0.00","give_integral":180,"coupon_id":"","coupon_price":"0.00","platform_coupon_price":"0.00","svip_discount":"0.00","order_type":0,"paid":1,"pay_time":"2024-03-17 11:38:42","pay_type":0,"create_time":"2024-03-17 11:38:43","status":-1,"delivery_type":null,"is_virtual":0,"delivery_name":null,"delivery_id":null,"mark":"","remark":null,"admin_mark":null,"verify_code":null,"verify_time":null,"verify_service_id":null,"transaction_id":null,"activity_type":0,"order_extend":null,"mer_id":6,"reconciliation_id":0,"cost":"200.00","is_del":0,"is_system_del":0,"verify_status":0,"orderProduct":[{"order_product_id":28,"order_id":28,"uid":3,"cart_id":69,"product_id":6,"extension_one":"0.00","extension_two":"0.00","integral":0,"integral_price":"0.00","integral_total":0,"coupon_price":"0.00","platform_coupon_price":null,"svip_discount":"0.00","postage_price":"0.00","product_sku":"167ac3990130","is_refund":3,"product_num":1,"product_type":0,"activity_id":6,"refund_num":0,"is_reply":0,"cost":"200.00","product_price":"180.00","total_price":"180.00","cart_info":{"product":{"product_id":6,"cate_id":14,"image":"https:\/\/mer.crmeb.net\/uploads\/attach\/2022\/04\/24\/8113054bdc3753c2f4f479e5b04f11d1.png","store_name":"Prada\/\u666e\u62c9\u8fbe\u5973\u58eb\u53d1\u5939\u5934\u9970","is_show":1,"status":1,"is_del":0,"unit_name":"\u4ef6","price":"180.00","mer_status":1,"temp_id":0,"give_coupon_ids":[],"is_gift_bag":0,"is_used":1,"product_type":0,"old_product_id":0,"integral_rate":0,"delivery_way":"2","delivery_free":1,"type":0,"extend":"","pay_limit":0,"once_max_count":0,"once_min_count":0,"mer_svip_status":1,"svip_price_type":0,"temp":null},"productAttr":{"image":"https:\/\/img.alicdn.com\/imgextra\/i2\/2207289125344\/O1CN010XEeaY1pLbHpe8KwV_!!2-item_pic.png","extension_one":"0.00","extension_two":"0.00","product_id":6,"stock":999,"price":"180.00","unique":"167ac3990130","sku":"\u767e\u5408\u8272","volume":"0.00","weight":"0.00","ot_price":"200.00","cost":"200.00","svip_price":"0.00","show_svip_price":false,"bc_extension_one":3.6,"bc_extension_two":1.8},"product_type":0},"create_time":"2024-03-17 11:38:42"}],"presellOrder":null,"groupOrder":{"group_order_id":27,"group_order_sn":"wxo1710646722542760291","uid":3,"total_postage":"0.00","total_price":"180.00","total_num":1,"integral":0,"integral_price":"0.00","give_integral":180,"coupon_price":"0.00","real_name":"\u5f20\u51ef\u7fd4","user_phone":"18362705640","user_address":"\u6c5f\u82cf\u5357\u4eac\u5e02\u6816\u971e\u533a\u5c27\u5316\u8857\u9053\u4e1c\u57ce\u4e16\u5bb6(\u5357\u4eac\u5e02\u6816\u971e\u533a\u5c27\u8fb0\u8def3\u53f7)24\u680b501","pay_price":"180.00","pay_postage":"0.00","cost":"200.00","coupon_id":"","give_coupon_ids":[],"paid":1,"pay_time":"2024-03-17 11:38:42","pay_type":0,"create_time":"2024-03-17 11:38:43","is_remind":0,"is_del":0,"is_combine":0}}}'; - event("order.refundAll", json_decode($json, true)); + event('order.statistics'); + +// $json = '{"order":{"order_id":33,"main_id":0,"group_order_id":27,"order_sn":"wxo1710646722542760291","uid":3,"spread_uid":0,"top_uid":0,"district_id":3378,"real_name":"\u5f20\u51ef\u7fd4","user_phone":"18362705640","user_address":"\u6c5f\u82cf\u5357\u4eac\u5e02\u6816\u971e\u533a\u5c27\u5316\u8857\u9053\u4e1c\u57ce\u4e16\u5bb6(\u5357\u4eac\u5e02\u6816\u971e\u533a\u5c27\u8fb0\u8def3\u53f7)24\u680b501","cart_id":"69","total_num":1,"total_price":"180.00","total_postage":"0.00","pay_price":"180.00","pay_postage":"0.00","is_selfbuy":0,"extension_one":"0.00","extension_two":"0.00","commission_rate":"5.0000","integral":0,"integral_price":"0.00","give_integral":180,"coupon_id":"","coupon_price":"0.00","platform_coupon_price":"0.00","svip_discount":"0.00","order_type":0,"paid":1,"pay_time":"2024-03-17 11:38:42","pay_type":0,"create_time":"2024-03-17 11:38:43","status":-1,"delivery_type":null,"is_virtual":0,"delivery_name":null,"delivery_id":null,"mark":"","remark":null,"admin_mark":null,"verify_code":null,"verify_time":null,"verify_service_id":null,"transaction_id":null,"activity_type":0,"order_extend":null,"mer_id":6,"reconciliation_id":0,"cost":"200.00","is_del":0,"is_system_del":0,"verify_status":0,"orderProduct":[{"order_product_id":28,"order_id":28,"uid":3,"cart_id":69,"product_id":6,"extension_one":"0.00","extension_two":"0.00","integral":0,"integral_price":"0.00","integral_total":0,"coupon_price":"0.00","platform_coupon_price":null,"svip_discount":"0.00","postage_price":"0.00","product_sku":"167ac3990130","is_refund":3,"product_num":1,"product_type":0,"activity_id":6,"refund_num":0,"is_reply":0,"cost":"200.00","product_price":"180.00","total_price":"180.00","cart_info":{"product":{"product_id":6,"cate_id":14,"image":"https:\/\/mer.crmeb.net\/uploads\/attach\/2022\/04\/24\/8113054bdc3753c2f4f479e5b04f11d1.png","store_name":"Prada\/\u666e\u62c9\u8fbe\u5973\u58eb\u53d1\u5939\u5934\u9970","is_show":1,"status":1,"is_del":0,"unit_name":"\u4ef6","price":"180.00","mer_status":1,"temp_id":0,"give_coupon_ids":[],"is_gift_bag":0,"is_used":1,"product_type":0,"old_product_id":0,"integral_rate":0,"delivery_way":"2","delivery_free":1,"type":0,"extend":"","pay_limit":0,"once_max_count":0,"once_min_count":0,"mer_svip_status":1,"svip_price_type":0,"temp":null},"productAttr":{"image":"https:\/\/img.alicdn.com\/imgextra\/i2\/2207289125344\/O1CN010XEeaY1pLbHpe8KwV_!!2-item_pic.png","extension_one":"0.00","extension_two":"0.00","product_id":6,"stock":999,"price":"180.00","unique":"167ac3990130","sku":"\u767e\u5408\u8272","volume":"0.00","weight":"0.00","ot_price":"200.00","cost":"200.00","svip_price":"0.00","show_svip_price":false,"bc_extension_one":3.6,"bc_extension_two":1.8},"product_type":0},"create_time":"2024-03-17 11:38:42"}],"presellOrder":null,"groupOrder":{"group_order_id":27,"group_order_sn":"wxo1710646722542760291","uid":3,"total_postage":"0.00","total_price":"180.00","total_num":1,"integral":0,"integral_price":"0.00","give_integral":180,"coupon_price":"0.00","real_name":"\u5f20\u51ef\u7fd4","user_phone":"18362705640","user_address":"\u6c5f\u82cf\u5357\u4eac\u5e02\u6816\u971e\u533a\u5c27\u5316\u8857\u9053\u4e1c\u57ce\u4e16\u5bb6(\u5357\u4eac\u5e02\u6816\u971e\u533a\u5c27\u8fb0\u8def3\u53f7)24\u680b501","pay_price":"180.00","pay_postage":"0.00","cost":"200.00","coupon_id":"","give_coupon_ids":[],"paid":1,"pay_time":"2024-03-17 11:38:42","pay_type":0,"create_time":"2024-03-17 11:38:43","is_remind":0,"is_del":0,"is_combine":0}}}'; +// event("order.refundAll", json_decode($json, true)); return app('json')->success(); // $data = [ diff --git a/app/event.php b/app/event.php index 548ac69..ee5b000 100644 --- a/app/event.php +++ b/app/event.php @@ -55,6 +55,7 @@ return [ \crmeb\listens\AuthCancelActivityListen::class, \crmeb\listens\CloseUserSvipListen::class, \crmeb\listens\SendSvipCouponListen::class, +// \crmeb\listens\task\CustomizeTask::class, ] : [], 'pay_success_user_recharge' => [\crmeb\listens\pay\UserRechargeSuccessListen::class], 'pay_success_user_order' => [\crmeb\listens\pay\UserOrderSuccessListen::class], @@ -64,6 +65,7 @@ return [ 'order.paySuccess' => [\crmeb\listens\pay\CustomizePaySuccess::class], 'order.take' => [\crmeb\listens\pay\CustomizeTake::class], 'order.refundAll' => [\crmeb\listens\pay\CustomizeRefundAll::class], + 'order.statistics' => [\crmeb\listens\task\CustomizeTask::class], ], 'subscribe' => [], diff --git a/crmeb/listens/pay/CustomizeTake.php b/crmeb/listens/pay/CustomizeTake.php index c6e7859..7a1a307 100644 --- a/crmeb/listens/pay/CustomizeTake.php +++ b/crmeb/listens/pay/CustomizeTake.php @@ -9,14 +9,24 @@ namespace crmeb\listens\pay; +use app\common\repositories\user\UserAssetsLogRepository; use crmeb\interfaces\ListenerInterface; use think\facade\Log; class CustomizeTake implements ListenerInterface { + // {"order":{"order_id":33,"main_id":0,"group_order_id":32,"order_sn":"wxo1710768193328392661","uid":3,"spread_uid":0,"top_uid":1,"district_id":3378,"real_name":"\u5f20\u51ef\u7fd4","user_phone":"18362705640","user_address":"\u6c5f\u82cf\u5357\u4eac\u5e02\u6816\u971e\u533a\u5c27\u5316\u8857\u9053\u4e1c\u57ce\u4e16\u5bb6(\u5357\u4eac\u5e02\u6816\u971e\u533a\u5c27\u8fb0\u8def3\u53f7)24\u680b501","cart_id":"77","total_num":1,"total_price":"100.00","total_postage":"0.00","pay_price":"100.00","pay_postage":"0.00","is_selfbuy":0,"extension_one":"0.00","extension_two":"1.20","commission_rate":"30.0000","integral":0,"integral_price":"0.00","give_integral":100,"coupon_id":"","coupon_price":"0.00","platform_coupon_price":"0.00","svip_discount":"0.00","order_type":0,"paid":1,"pay_time":"2024-03-18 21:23:13","pay_type":0,"create_time":"2024-03-18 21:23:13","status":2,"delivery_type":"1","is_virtual":0,"delivery_name":"\u97f5\u8fbe\u5feb\u9012","delivery_id":"ewrwe","mark":"","remark":"","admin_mark":null,"verify_code":null,"verify_time":"2024-03-19 14:43:24","verify_service_id":null,"transaction_id":null,"activity_type":0,"order_extend":null,"mer_id":6,"reconciliation_id":0,"cost":"0.00","is_del":0,"is_system_del":0,"verify_status":0,"presellOrder":null}} public function handle($data): void { Log::info('收货' . json_encode($data)); + + if(isset($data['order']) and $data['order']){ + /** + * @var UserAssetsLogRepository $repository + */ + $repository = app()->make(UserAssetsLogRepository::class); + $repository->userTakeEvent($data['order']); + } } } diff --git a/crmeb/listens/task/CustomizeTask.php b/crmeb/listens/task/CustomizeTask.php new file mode 100644 index 0000000..8c7da08 --- /dev/null +++ b/crmeb/listens/task/CustomizeTask.php @@ -0,0 +1,33 @@ +tick(1000 * 60 , function () { +// Log::info("aaaa3333"); +// }); + + /** + * @var UserAssetsRepository $userAssets + */ + $userAssets = app()->make(UserAssetsRepository::class); + $userAssets->sharePoint(); + } +}