From 2cca063da137371be1081abc20bea8c7c17eca17 Mon Sep 17 00:00:00 2001 From: fengxinyhyl Date: Tue, 19 Mar 2024 11:15:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=80=80=E6=AC=BE=E5=A4=84?= =?UTF-8?q?=E7=90=86=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/common/dao/user/UserAssetsLogDao.php | 13 +- .../user/UserAssetsLogRepository.php | 122 +++++++++++++++--- .../user/UserAssetsRepository.php | 58 +++++---- app/controller/api/Auth.php | 8 +- app/event.php | 1 + crmeb/listens/pay/CustomizeRefundAll.php | 12 +- crmeb/listens/pay/CustomizeTake.php | 22 ++++ 7 files changed, 191 insertions(+), 45 deletions(-) create mode 100644 crmeb/listens/pay/CustomizeTake.php diff --git a/app/common/dao/user/UserAssetsLogDao.php b/app/common/dao/user/UserAssetsLogDao.php index 9a3aa6e..5d2dc6f 100644 --- a/app/common/dao/user/UserAssetsLogDao.php +++ b/app/common/dao/user/UserAssetsLogDao.php @@ -37,10 +37,21 @@ class UserAssetsLogDao extends BaseDao } - public function search(int $uid, array $where){ + public function search(int $uid, array $where) + { $query = UserAssetsLog::getDB()->where('uid', $uid)->where($where); return $query; } + public function orderData(int $orderId, array $where) + { + return UserAssetsLog::getDB()->where('order_id', $orderId)->where($where)->group('uid, asset_type')->field('uid,asset_type, sum(count) as count')->select(); + } + + + public function updateOrderStatus($orderId, $status){ + return UserAssetsLog::where('order_id', $orderId)->update(array('status' => $status)); + } + } diff --git a/app/common/repositories/user/UserAssetsLogRepository.php b/app/common/repositories/user/UserAssetsLogRepository.php index 65ec01f..c51ac46 100644 --- a/app/common/repositories/user/UserAssetsLogRepository.php +++ b/app/common/repositories/user/UserAssetsLogRepository.php @@ -50,6 +50,7 @@ class UserAssetsLogRepository extends BaseRepository const STATUS_FROZEN = 0; // 冻结 const STATUS_SUCCESS = 1; // 成功 const STATUS_REFUND = 2; // 退款 + const STATUS_USED = 3; // 使用积分 public function __construct(UserAssetsLogDao $dao, UserAssetsRepository $userAssetsRepository, ProductRepository $productRepository, GroupDataRepository $groupRepository) { @@ -173,10 +174,10 @@ class UserAssetsLogRepository extends BaseRepository $userRepository = app(UserRepository::class); $user = $userRepository->searchOne(['mer_id' => $orderItem['mer_id']]); if ($user) { - $logList = array(); - $welfare = $consume = $huitong = $contribution = 0; - $consume = round($orderItem['total_price'] * $orderItem['commission_rate'] / 100, 2); - $consume = $this->_getValue($consume); + $logList = array(); + $welfare = $consume = $huitong = $contribution = 0; + $consume = round($orderItem['total_price'] * $orderItem['commission_rate'] / 100, 2); + $consume = $this->_getValue($consume); $logList[] = array( 'uid' => $user['uid'], 'asset_type' => self::ASSET_TYPE_CONSUME, @@ -186,9 +187,9 @@ class UserAssetsLogRepository extends BaseRepository 'count' => $consume, 'mer_id' => $orderItem['mer_id'], ); - if($orderItem['integral']){ - $welfare = round($orderItem['integral'] * (100 - $orderItem['commission_rate']) / 100, 2); - $welfare = $this->_getValue($welfare); + if ($orderItem['integral']) { + $welfare = round($orderItem['integral'] * (100 - $orderItem['commission_rate']) / 100, 2); + $welfare = $this->_getValue($welfare); $logList[] = array( 'uid' => $user['uid'], 'asset_type' => self::ASSET_TYPE_WELFARE, @@ -204,10 +205,10 @@ class UserAssetsLogRepository extends BaseRepository } - if($orderItem['integral']){ + if ($orderItem['integral']) { $welfare = round($orderItem['integral'] * $orderItem['commission_rate'] / 100, 2); $welfare = $this->_getValue($welfare); - $log = array( + $log = array( 'uid' => 0, 'asset_type' => self::ASSET_TYPE_WELFARE, 'type' => self::CHANGE_TYPE_ORDER, @@ -554,6 +555,101 @@ class UserAssetsLogRepository extends BaseRepository } $this->addLog($logList); $this->userAssetsRepository->orderEvent($orderItem['uid'], self::STATUS_FROZEN, compact('consume', 'welfare', 'huitong', 'contribution')); + + // 5. 本人使用的福利积分 + if ($orderItem['integral']) { + $consume = $welfare = $huitong = $contribution = 0; + $log = array('uid' => $orderItem['uid'], + 'asset_type' => self::ASSET_TYPE_WELFARE, + 'type' => self::CHANGE_TYPE_ORDER, + 'status' => self::STATUS_USED, + 'order_id' => $orderItem['order_id'], + 'count' => $orderItem['integral'], + ); + $this->addLog([$log]); + $this->userAssetsRepository->orderEvent($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 11:01 + * @update 2024/3/19 11:01 + * @author zhangkxiang + * @editor + */ + public function userRefundEvent($orderItem) + { + // 订单发送冻结资产收回 + $refundList = $this->_getOrderData($orderItem['order_id'], self::STATUS_FROZEN); + if ($refundList) { + foreach ($refundList as $refund) { + $this->userAssetsRepository->orderEvent($refund['uid'], self::STATUS_REFUND, $refund); + } + } + + // 返回用户支付的福利积分 + $usedList = $this->_getOrderData($orderItem['order_id'], self::STATUS_USED); + if ($usedList) { + foreach ($usedList as $used) { + if($used['welfare'] > 0){ + $info = $this->userAssetsRepository->get($used['uid']); + $this->userAssetsRepository->update($used['uid'], array('welfare' => $info['welfare'] + $used['welfare'])); + } + } + } + + // 更新该订单的所有数据为退款状态 + $this->dao->updateOrderStatus($orderItem['order_id'], self::STATUS_REFUND); + } + + + private function _getOrderData($orderId, $status) + { + $data = $this->dao->orderData($orderId, ['status' => $status]); + // 订单发送冻结资产收回 + if (!$data->isEmpty()) { + $list = array(); + foreach ($data as $item) { + if (!isset($list[$item['uid']])) { + $list[$item['uid']] = array( + 'uid' => $item['uid'], + 'consume' => 0, + 'welfare' => 0, + 'huitong' => 0, + 'contribution' => 0, + ); + } + + switch ($item['asset_type']) { + case self::ASSET_TYPE_CONSUME: + $list[$item['uid']]['consume'] += $item['count']; + break; + case self::ASSET_TYPE_WELFARE: + $list[$item['uid']]['welfare'] += $item['count']; + break; + case self::ASSET_TYPE_HUITONG: + $list[$item['uid']]['huitong'] += $item['count']; + break; + case self::ASSET_TYPE_CONTRIBUTION: + $list[$item['uid']]['contribution'] += $item['count']; + break; + } + } + return $list; + } + return array(); } @@ -602,7 +698,7 @@ class UserAssetsLogRepository extends BaseRepository { $query = $this->dao->search($uid, $where); $count = $query->count(); - $data = $query->page($page, $limit)->select(); + $data = $query->page($page, $limit)->order('id desc')->select(); $list = array(); $changeType = $this->getChangeType(); foreach ($data as $item) { @@ -611,10 +707,4 @@ class UserAssetsLogRepository extends BaseRepository } return compact('count', 'list'); } - - - public function userRefund() - { - - } } diff --git a/app/common/repositories/user/UserAssetsRepository.php b/app/common/repositories/user/UserAssetsRepository.php index bb4b58c..de1762b 100644 --- a/app/common/repositories/user/UserAssetsRepository.php +++ b/app/common/repositories/user/UserAssetsRepository.php @@ -44,19 +44,19 @@ class UserAssetsRepository extends BaseRepository public function assets($uid) { $item = $this->dao->get($uid); - if($item){ + if ($item) { return $item->toArray(); } return array( - 'uid' => 0, - 'consume' => 0.00, - 'consume_frozen' => 0.00, - 'share_point' => 0.00, - 'welfare' => 0.00, - 'welfare_frozen' => 0.00, - 'huitong' => 0.00, - 'huitong_frozen' => 0.00, - 'contribution' => 0.00, + 'uid' => 0, + 'consume' => 0.00, + 'consume_frozen' => 0.00, + 'share_point' => 0.00, + 'welfare' => 0.00, + 'welfare_frozen' => 0.00, + 'huitong' => 0.00, + 'huitong_frozen' => 0.00, + 'contribution' => 0.00, 'contribution_frozen' => 0.00, ); } @@ -78,42 +78,52 @@ class UserAssetsRepository extends BaseRepository public function orderEvent($uid, $status, $data = array()) { $assets = array(); - $info = $this->dao->get($uid); - if($info){ + $info = $this->dao->get($uid); + + $data['consume'] = $data['consume'] ?? 0; + $data['welfare'] = $data['welfare'] ?? 0; + $data['huitong'] = $data['huitong'] ?? 0; + $data['contribution'] = $data['contribution'] ?? 0; + + if ($info) { // 购买订单获得冻结资产 - if($status == UserAssetsLogRepository::STATUS_FROZEN) { + if ($status == UserAssetsLogRepository::STATUS_FROZEN) { $assets = array( 'consume_frozen' => $info['consume_frozen'] + $data['consume'], 'welfare_frozen' => $info['welfare_frozen'] + $data['welfare'], 'huitong_frozen' => $info['huitong_frozen'] + $data['huitong'], 'contribution_frozen' => $info['contribution_frozen'] + $data['contribution'], ); - }elseif ($status == UserAssetsLogRepository::STATUS_SUCCESS){ + } elseif ($status == UserAssetsLogRepository::STATUS_SUCCESS) { $assets = array( - 'consume' => $info['consume'] + $data['consume'], - 'welfare' => $info['welfare'] + $data['welfare'], - 'huitong' => $info['huitong'] + $data['huitong'], - 'contribution' => $info['contribution'] + $data['contribution'], + 'consume' => $info['consume'] + $data['consume'], + 'welfare' => $info['welfare'] + $data['welfare'], + 'huitong' => $info['huitong'] + $data['huitong'], + 'contribution' => $info['contribution'] + $data['contribution'], 'consume_frozen' => $info['consume_frozen'] - $data['consume'], 'welfare_frozen' => $info['welfare_frozen'] - $data['welfare'], 'huitong_frozen' => $info['huitong_frozen'] - $data['huitong'], 'contribution_frozen' => $info['contribution_frozen'] - $data['contribution'], ); - }elseif ($status == UserAssetsLogRepository::STATUS_REFUND){ + } elseif ($status == UserAssetsLogRepository::STATUS_REFUND) { $assets = array( 'consume_frozen' => $info['consume_frozen'] - $data['consume'], 'welfare_frozen' => $info['welfare_frozen'] - $data['welfare'], 'huitong_frozen' => $info['huitong_frozen'] - $data['huitong'], 'contribution_frozen' => $info['contribution_frozen'] - $data['contribution'], ); + } elseif ($status == UserAssetsLogRepository::STATUS_USED) { + $assets = array( + 'welfare' => $info['welfare'] - $data['welfare'], + ); } $this->dao->update($uid, $assets); - }else{ + } else { $assets = array( - 'uid' => $uid, - 'consume_frozen' => $data['consume'] ?? 0, - 'welfare_frozen' => $data['welfare'] ?? 0, - 'huitong_frozen' => $data['huitong'] ?? 0, + 'uid' => $uid, + 'consume_frozen' => $data['consume'] ?? 0, + 'welfare_frozen' => $data['welfare'] ?? 0, + 'huitong_frozen' => $data['huitong'] ?? 0, 'contribution_frozen' => $data['contribution'] ?? 0, ); $this->dao->create($assets); diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index ea6fb00..e9491a5 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -55,8 +55,12 @@ class Auth extends BaseController { public function test() { - $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 = '{"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)); + return app('json')->success(); // $data = [ // 'tempId' => '', diff --git a/app/event.php b/app/event.php index 71f5444..548ac69 100644 --- a/app/event.php +++ b/app/event.php @@ -62,6 +62,7 @@ return [ 'pay_success_presell' => [\crmeb\listens\pay\PresellPaySuccessListen::class], 'pay_success_meal' => [\crmeb\listens\pay\MealSuccessListen::class], 'order.paySuccess' => [\crmeb\listens\pay\CustomizePaySuccess::class], + 'order.take' => [\crmeb\listens\pay\CustomizeTake::class], 'order.refundAll' => [\crmeb\listens\pay\CustomizeRefundAll::class], ], diff --git a/crmeb/listens/pay/CustomizeRefundAll.php b/crmeb/listens/pay/CustomizeRefundAll.php index 70652ac..5993e9c 100644 --- a/crmeb/listens/pay/CustomizeRefundAll.php +++ b/crmeb/listens/pay/CustomizeRefundAll.php @@ -9,16 +9,24 @@ namespace crmeb\listens\pay; -use app\common\repositories\store\order\StoreGroupOrderRepository; -use app\common\repositories\store\order\StoreOrderRepository; +use app\common\repositories\user\UserAssetsLogRepository; use crmeb\interfaces\ListenerInterface; use think\facade\Log; class CustomizeRefundAll implements ListenerInterface { + // {"order":{"order_id":28,"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}}} 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->userRefundEvent($data['order']); + } } } diff --git a/crmeb/listens/pay/CustomizeTake.php b/crmeb/listens/pay/CustomizeTake.php new file mode 100644 index 0000000..c6e7859 --- /dev/null +++ b/crmeb/listens/pay/CustomizeTake.php @@ -0,0 +1,22 @@ +