From 6eaf74a04a226d1d52d41526e745512eb7af3146 Mon Sep 17 00:00:00 2001 From: wang hou sheng <76928547+wanghousheng@users.noreply.github.com> Date: Thu, 16 May 2024 12:17:49 +0800 Subject: [PATCH 01/18] 1 --- app/admin/controller/Wxserve.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/app/admin/controller/Wxserve.php b/app/admin/controller/Wxserve.php index ec802f44..a4c8b430 100644 --- a/app/admin/controller/Wxserve.php +++ b/app/admin/controller/Wxserve.php @@ -223,6 +223,22 @@ class Wxserve extends Controller return $this->renderError('操作失败'); } + public function auditOne(): Json + { + $appid = $this->request->get('appid'); + $obj = new Server(); + $res = $obj->privacyInfo($appid); + if ($res == 'ok') { + if ($obj->submitAudit($appid)) { + return $this->renderSuccess('success'); + } else { + return $this->renderError('发布失败'); + } + } else { + return $this->renderError('隐私接口错误'); + } + } + /** * @notes:发布正式版前检查 * @return Json From 0b32855f2f8544401b64a98af1d60fd0c9202538 Mon Sep 17 00:00:00 2001 From: wang hou sheng <76928547+wanghousheng@users.noreply.github.com> Date: Thu, 16 May 2024 12:25:21 +0800 Subject: [PATCH 02/18] 1 --- app/admin/controller/Wxserve.php | 12 +++++++----- app/common/library/wxserver/Server.php | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/app/admin/controller/Wxserve.php b/app/admin/controller/Wxserve.php index a4c8b430..ff2d5f42 100644 --- a/app/admin/controller/Wxserve.php +++ b/app/admin/controller/Wxserve.php @@ -229,11 +229,13 @@ class Wxserve extends Controller $obj = new Server(); $res = $obj->privacyInfo($appid); if ($res == 'ok') { - if ($obj->submitAudit($appid)) { - return $this->renderSuccess('success'); - } else { - return $this->renderError('发布失败'); - } + $result = $obj->submitAudit($appid); + return $this->renderSuccess([$result]); +// if ($result) { +// return $this->renderSuccess('success'); +// } else { +// return $this->renderSuccess([]) +// } } else { return $this->renderError('隐私接口错误'); } diff --git a/app/common/library/wxserver/Server.php b/app/common/library/wxserver/Server.php index 0f13aa3a..3d56e087 100644 --- a/app/common/library/wxserver/Server.php +++ b/app/common/library/wxserver/Server.php @@ -698,7 +698,7 @@ class Server return 0; } - public function submitAudit($appid): bool + public function submitAudit($appid) { $access_token = $this->authorizerAccessToken($appid); if ($access_token) { @@ -711,6 +711,7 @@ class Server } $result = $this->curlPost($url, $data); $result = json_decode($result, true); + return $result; if (!empty($result) && intval($result['errcode']) == 0 && !empty($result['auditid'])) { $model = new WxserverAccount(); $up['audit_status'] = 1; From 15cc0a40dcea1586abc2e1b979f223fa28cd22c3 Mon Sep 17 00:00:00 2001 From: wang hou sheng <76928547+wanghousheng@users.noreply.github.com> Date: Thu, 16 May 2024 12:29:08 +0800 Subject: [PATCH 03/18] 1 --- app/admin/controller/Wxserve.php | 13 ++++++------ app/common/library/wxserver/Server.php | 29 ++++++++++++++++++++++++-- 2 files changed, 33 insertions(+), 9 deletions(-) diff --git a/app/admin/controller/Wxserve.php b/app/admin/controller/Wxserve.php index ff2d5f42..bffaeaeb 100644 --- a/app/admin/controller/Wxserve.php +++ b/app/admin/controller/Wxserve.php @@ -229,13 +229,12 @@ class Wxserve extends Controller $obj = new Server(); $res = $obj->privacyInfo($appid); if ($res == 'ok') { - $result = $obj->submitAudit($appid); - return $this->renderSuccess([$result]); -// if ($result) { -// return $this->renderSuccess('success'); -// } else { -// return $this->renderSuccess([]) -// } + $result = $obj->submitAuditOne($appid); + if ($result['status']) { + return $this->renderSuccess('success'); + } else { + return $this->renderError($result['msg']); + } } else { return $this->renderError('隐私接口错误'); } diff --git a/app/common/library/wxserver/Server.php b/app/common/library/wxserver/Server.php index 3d56e087..830ee6d2 100644 --- a/app/common/library/wxserver/Server.php +++ b/app/common/library/wxserver/Server.php @@ -698,7 +698,33 @@ class Server return 0; } - public function submitAudit($appid) + public function submitAuditOne($appid): array + { + $access_token = $this->authorizerAccessToken($appid); + if ($access_token) { + $url = 'https://api.weixin.qq.com/wxa/submit_audit?access_token=' . $access_token; + $data['item_list'] = $this->getAllCategory($appid); + if (!empty($data['item_list'])) { + $data = '{}'; + } else { + $data = json_encode($data); + } + $result = $this->curlPost($url, $data); + $result = json_decode($result, true); + if (!empty($result) && intval($result['errcode']) == 0 && !empty($result['auditid'])) { + $model = new WxserverAccount(); + $up['audit_status'] = 1; + $up['audit_reason'] = ''; + $up['audit_time'] = date('Y-m-d H:i:s'); + $up['auditid'] = $result['auditid']; + $model->update($up, ['appid' => $appid]); + return ['status' => true, 'msg' => 'success']; + } + } + return ['status' => false, 'msg' => !empty($result['errmsg']) ? $result['errmsg'] : '位置错误']; + } + + public function submitAudit($appid): bool { $access_token = $this->authorizerAccessToken($appid); if ($access_token) { @@ -711,7 +737,6 @@ class Server } $result = $this->curlPost($url, $data); $result = json_decode($result, true); - return $result; if (!empty($result) && intval($result['errcode']) == 0 && !empty($result['auditid'])) { $model = new WxserverAccount(); $up['audit_status'] = 1; From 7436445ada72db0b6a91fcafc02bd1e27f761525 Mon Sep 17 00:00:00 2001 From: wang hou sheng <76928547+wanghousheng@users.noreply.github.com> Date: Thu, 16 May 2024 12:48:31 +0800 Subject: [PATCH 04/18] 1 --- app/admin/controller/Wxserve.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/admin/controller/Wxserve.php b/app/admin/controller/Wxserve.php index bffaeaeb..a30d6337 100644 --- a/app/admin/controller/Wxserve.php +++ b/app/admin/controller/Wxserve.php @@ -227,8 +227,8 @@ class Wxserve extends Controller { $appid = $this->request->get('appid'); $obj = new Server(); - $res = $obj->privacyInfo($appid); - if ($res == 'ok') { + $res = $obj->getPrivacySetting($appid); + if ($res) { $result = $obj->submitAuditOne($appid); if ($result['status']) { return $this->renderSuccess('success'); From 667a15fd8e312865647205bf43a5afc2b02b8f48 Mon Sep 17 00:00:00 2001 From: wang hou sheng <76928547+wanghousheng@users.noreply.github.com> Date: Thu, 16 May 2024 12:49:30 +0800 Subject: [PATCH 05/18] 1 --- app/admin/controller/Wxserve.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/admin/controller/Wxserve.php b/app/admin/controller/Wxserve.php index a30d6337..bffaeaeb 100644 --- a/app/admin/controller/Wxserve.php +++ b/app/admin/controller/Wxserve.php @@ -227,8 +227,8 @@ class Wxserve extends Controller { $appid = $this->request->get('appid'); $obj = new Server(); - $res = $obj->getPrivacySetting($appid); - if ($res) { + $res = $obj->privacyInfo($appid); + if ($res == 'ok') { $result = $obj->submitAuditOne($appid); if ($result['status']) { return $this->renderSuccess('success'); From 8ec27cdc45c8a5f11ddf824c54355401bbbe13cd Mon Sep 17 00:00:00 2001 From: wang hou sheng <76928547+wanghousheng@users.noreply.github.com> Date: Thu, 16 May 2024 12:53:41 +0800 Subject: [PATCH 06/18] 1 --- app/common/library/wxserver/Server.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/common/library/wxserver/Server.php b/app/common/library/wxserver/Server.php index 830ee6d2..8583203f 100644 --- a/app/common/library/wxserver/Server.php +++ b/app/common/library/wxserver/Server.php @@ -538,13 +538,13 @@ class Server if ($token) { $url = "https://api.weixin.qq.com/cgi-bin/component/setprivacysetting?access_token=$token"; $setting_list = [ - ['privacy_key' => 'PhoneNumber', 'privacy_text' => '用于用户一键登录'], +// ['privacy_key' => 'PhoneNumber', 'privacy_text' => '用于用户一键登录'], ['privacy_key' => 'Location', 'privacy_text' => '用于用户选择自提点'], - ['privacy_key' => 'AlbumWriteOnly', 'privacy_text' => '用于用户保存海报'], - ['privacy_key' => 'Address', 'privacy_text' => '用于用户快速获取微信地址'], - ['privacy_key' => 'Invoice', 'privacy_text' => '用于用户申请开票'], - ['privacy_key' => 'Album', 'privacy_text' => '用于用户上传图片'], - ['privacy_key' => 'Clipboard', 'privacy_text' => '用于用户复制粘贴'], +// ['privacy_key' => 'AlbumWriteOnly', 'privacy_text' => '用于用户保存海报'], +// ['privacy_key' => 'Address', 'privacy_text' => '用于用户快速获取微信地址'], +// ['privacy_key' => 'Invoice', 'privacy_text' => '用于用户申请开票'], +// ['privacy_key' => 'Album', 'privacy_text' => '用于用户上传图片'], +// ['privacy_key' => 'Clipboard', 'privacy_text' => '用于用户复制粘贴'], ]; $data['setting_list'] = $setting_list; $data['owner_setting']['contact_qq'] = '527264601'; From bea4d52894fde9296008c917b1cf54e13941debd Mon Sep 17 00:00:00 2001 From: wang hou sheng <76928547+wanghousheng@users.noreply.github.com> Date: Thu, 16 May 2024 12:54:33 +0800 Subject: [PATCH 07/18] 1 --- app/admin/controller/Wxserve.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/admin/controller/Wxserve.php b/app/admin/controller/Wxserve.php index bffaeaeb..a30d6337 100644 --- a/app/admin/controller/Wxserve.php +++ b/app/admin/controller/Wxserve.php @@ -227,8 +227,8 @@ class Wxserve extends Controller { $appid = $this->request->get('appid'); $obj = new Server(); - $res = $obj->privacyInfo($appid); - if ($res == 'ok') { + $res = $obj->getPrivacySetting($appid); + if ($res) { $result = $obj->submitAuditOne($appid); if ($result['status']) { return $this->renderSuccess('success'); From a58b0474bd1b13391171281fe5ec69a32993f1df Mon Sep 17 00:00:00 2001 From: wang hou sheng <76928547+wanghousheng@users.noreply.github.com> Date: Thu, 16 May 2024 13:00:34 +0800 Subject: [PATCH 08/18] 1 --- app/admin/controller/Wxserve.php | 4 ++-- app/common/library/wxserver/Server.php | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/admin/controller/Wxserve.php b/app/admin/controller/Wxserve.php index a30d6337..bffaeaeb 100644 --- a/app/admin/controller/Wxserve.php +++ b/app/admin/controller/Wxserve.php @@ -227,8 +227,8 @@ class Wxserve extends Controller { $appid = $this->request->get('appid'); $obj = new Server(); - $res = $obj->getPrivacySetting($appid); - if ($res) { + $res = $obj->privacyInfo($appid); + if ($res == 'ok') { $result = $obj->submitAuditOne($appid); if ($result['status']) { return $this->renderSuccess('success'); diff --git a/app/common/library/wxserver/Server.php b/app/common/library/wxserver/Server.php index 8583203f..830ee6d2 100644 --- a/app/common/library/wxserver/Server.php +++ b/app/common/library/wxserver/Server.php @@ -538,13 +538,13 @@ class Server if ($token) { $url = "https://api.weixin.qq.com/cgi-bin/component/setprivacysetting?access_token=$token"; $setting_list = [ -// ['privacy_key' => 'PhoneNumber', 'privacy_text' => '用于用户一键登录'], + ['privacy_key' => 'PhoneNumber', 'privacy_text' => '用于用户一键登录'], ['privacy_key' => 'Location', 'privacy_text' => '用于用户选择自提点'], -// ['privacy_key' => 'AlbumWriteOnly', 'privacy_text' => '用于用户保存海报'], -// ['privacy_key' => 'Address', 'privacy_text' => '用于用户快速获取微信地址'], -// ['privacy_key' => 'Invoice', 'privacy_text' => '用于用户申请开票'], -// ['privacy_key' => 'Album', 'privacy_text' => '用于用户上传图片'], -// ['privacy_key' => 'Clipboard', 'privacy_text' => '用于用户复制粘贴'], + ['privacy_key' => 'AlbumWriteOnly', 'privacy_text' => '用于用户保存海报'], + ['privacy_key' => 'Address', 'privacy_text' => '用于用户快速获取微信地址'], + ['privacy_key' => 'Invoice', 'privacy_text' => '用于用户申请开票'], + ['privacy_key' => 'Album', 'privacy_text' => '用于用户上传图片'], + ['privacy_key' => 'Clipboard', 'privacy_text' => '用于用户复制粘贴'], ]; $data['setting_list'] = $setting_list; $data['owner_setting']['contact_qq'] = '527264601'; From 7d9fe7448952b2033c5468b4111349626c408c25 Mon Sep 17 00:00:00 2001 From: "yangsai@163.com" <2624183217@qq.com> Date: Thu, 16 May 2024 14:07:49 +0800 Subject: [PATCH 09/18] =?UTF-8?q?YS:=E6=8D=A2=E8=B4=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/model/OrderRefund.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/store/model/OrderRefund.php b/app/store/model/OrderRefund.php index 4e1ed2da..2fe78103 100644 --- a/app/store/model/OrderRefund.php +++ b/app/store/model/OrderRefund.php @@ -203,9 +203,9 @@ class OrderRefund extends OrderRefundModel // 更新售后单状态 $this->save($data); // 同意售后申请, 记录退货地址 - if ($data['audit_status'] == AuditStatusEnum::REVIEWED) { - (new OrderRefundAddress)->add((int)$this['order_refund_id'], (int)($data['address_id'] ?? 0)); - } +// if ($data['audit_status'] == AuditStatusEnum::REVIEWED) { +// (new OrderRefundAddress)->add((int)$this['order_refund_id'], (int)($data['address_id'] ?? 0)); +// } // 订单详情 $order = Order::detail($this['order_id']); // 发送消息通知 From 6f8b676336d8ec0d44156bb8e84b0921ad7a5572 Mon Sep 17 00:00:00 2001 From: "yangsai@163.com" <2624183217@qq.com> Date: Thu, 16 May 2024 14:10:09 +0800 Subject: [PATCH 10/18] =?UTF-8?q?YS:=E6=8D=A2=E8=B4=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/model/OrderRefund.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/store/model/OrderRefund.php b/app/store/model/OrderRefund.php index 2fe78103..4e1ed2da 100644 --- a/app/store/model/OrderRefund.php +++ b/app/store/model/OrderRefund.php @@ -203,9 +203,9 @@ class OrderRefund extends OrderRefundModel // 更新售后单状态 $this->save($data); // 同意售后申请, 记录退货地址 -// if ($data['audit_status'] == AuditStatusEnum::REVIEWED) { -// (new OrderRefundAddress)->add((int)$this['order_refund_id'], (int)($data['address_id'] ?? 0)); -// } + if ($data['audit_status'] == AuditStatusEnum::REVIEWED) { + (new OrderRefundAddress)->add((int)$this['order_refund_id'], (int)($data['address_id'] ?? 0)); + } // 订单详情 $order = Order::detail($this['order_id']); // 发送消息通知 From 99c50e394edbc87874d7ed66abca977178723586 Mon Sep 17 00:00:00 2001 From: "yangsai@163.com" <2624183217@qq.com> Date: Thu, 16 May 2024 17:28:45 +0800 Subject: [PATCH 11/18] =?UTF-8?q?YS:=E6=8D=A2=E8=B4=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/model/OrderRefund.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/api/model/OrderRefund.php b/app/api/model/OrderRefund.php index 60ea8b93..a63da476 100644 --- a/app/api/model/OrderRefund.php +++ b/app/api/model/OrderRefund.php @@ -80,6 +80,9 @@ class OrderRefund extends OrderRefundModel if ($data['type'] == RefundTypeEnum::RETURN) { return $data['is_user_send'] ? '已发货,待平台确认' : '已同意退货,请及时发货'; } + if ($data['type'] == RefundTypeEnum::EXCHANGE) { + return $data['is_user_send'] ? '已发货,待平台确认' : '已同意换货,请及时发货'; + } } return $value; } From 333f2d8f6d05e1e892e5685406edb823ee2e4f78 Mon Sep 17 00:00:00 2001 From: "yangsai@163.com" <2624183217@qq.com> Date: Thu, 16 May 2024 17:51:35 +0800 Subject: [PATCH 12/18] YS --- app/api/model/OrderRefund.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/model/OrderRefund.php b/app/api/model/OrderRefund.php index a63da476..0bae7fa6 100644 --- a/app/api/model/OrderRefund.php +++ b/app/api/model/OrderRefund.php @@ -172,7 +172,7 @@ class OrderRefund extends OrderRefundModel public function delivery(array $data): bool { if ( - $this['type'] != RefundTypeEnum::RETURN + ($this['type'] != RefundTypeEnum::RETURN || $this['type'] != RefundTypeEnum::EXCHANGE) || $this['audit_status'] != AuditStatusEnum::REVIEWED || $this['is_user_send'] != 0 ) { From 03b30a256958f8b8ea6a319daa19b7f93a6f9d53 Mon Sep 17 00:00:00 2001 From: "yangsai@163.com" <2624183217@qq.com> Date: Thu, 16 May 2024 17:55:21 +0800 Subject: [PATCH 13/18] YS --- app/api/model/OrderRefund.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/api/model/OrderRefund.php b/app/api/model/OrderRefund.php index 0bae7fa6..f2de8a6c 100644 --- a/app/api/model/OrderRefund.php +++ b/app/api/model/OrderRefund.php @@ -172,7 +172,7 @@ class OrderRefund extends OrderRefundModel public function delivery(array $data): bool { if ( - ($this['type'] != RefundTypeEnum::RETURN || $this['type'] != RefundTypeEnum::EXCHANGE) + !in_array($this['type'],[RefundTypeEnum::RETURN,RefundTypeEnum::EXCHANGE]) || $this['audit_status'] != AuditStatusEnum::REVIEWED || $this['is_user_send'] != 0 ) { From 7e90bd19a795d2951a89b6a550fa5fa61b63731e Mon Sep 17 00:00:00 2001 From: "yangsai@163.com" <2624183217@qq.com> Date: Thu, 16 May 2024 18:20:48 +0800 Subject: [PATCH 14/18] YS --- app/store/model/OrderRefund.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/store/model/OrderRefund.php b/app/store/model/OrderRefund.php index 4e1ed2da..6c097863 100644 --- a/app/store/model/OrderRefund.php +++ b/app/store/model/OrderRefund.php @@ -261,6 +261,7 @@ class OrderRefund extends OrderRefundModel { // 订单详情 $order = Order::detail($this['order_id']); + $data['refund_money'] = empty($data['refund_money'])?0:$data['refund_money']; if ($data['refund_money'] > min($order['pay_price'], $this['orderGoods']['total_pay_price'])) { $this->error = '退款金额不能大于商品实付款金额'; return false; From 93551f4dfc5d08c3c26d706db366a0e8e3f7d232 Mon Sep 17 00:00:00 2001 From: "yangsai@163.com" <2624183217@qq.com> Date: Thu, 16 May 2024 19:02:04 +0800 Subject: [PATCH 15/18] =?UTF-8?q?YS:=E6=8D=A2=E8=B4=A7=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/Refund.php | 11 ++++++++-- app/store/model/OrderRefund.php | 38 ++++++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 3 deletions(-) diff --git a/app/api/controller/Refund.php b/app/api/controller/Refund.php index e343474f..2f873005 100644 --- a/app/api/controller/Refund.php +++ b/app/api/controller/Refund.php @@ -12,6 +12,7 @@ declare (strict_types=1); namespace app\api\controller; +use app\common\enum\order\refund\RefundType as RefundTypeEnum; use think\response\Json; use app\api\model\OrderRefund as OrderRefundModel; @@ -91,8 +92,14 @@ class Refund extends Controller { // 售后单详情 $model = OrderRefundModel::getDetail($orderRefundId, false); - if ($model->delivery($this->postForm())) { - return $this->renderSuccess([], '操作成功'); + if($model['type']==RefundTypeEnum::EXCHANGE){ + if ($model->huanhuo($this->postForm())) { + return $this->renderSuccess([], '操作成功'); + } + }else{ + if ($model->delivery($this->postForm())) { + return $this->renderSuccess([], '操作成功'); + } } return $this->renderError($model->getError() ?: '提交失败'); } diff --git a/app/store/model/OrderRefund.php b/app/store/model/OrderRefund.php index 6c097863..4853810e 100644 --- a/app/store/model/OrderRefund.php +++ b/app/store/model/OrderRefund.php @@ -13,7 +13,9 @@ declare (strict_types=1); namespace app\store\model; use app\api\service\User as UserService; +use app\common\enum\order\DeliveryStatus as DeliveryStatusEnum; use app\common\enum\order\DeliveryType; +use app\common\enum\order\OrderStatus as OrderStatusEnum; use app\common\enum\order\refund\AuditStatus as AuditStatusEnum; use app\common\enum\order\refund\RefundStatus as RefundStatusEnum; use app\common\enum\order\refund\RefundType as RefundTypeEnum; @@ -22,6 +24,7 @@ use app\common\model\OrderRefund as OrderRefundModel; use app\common\service\Message as MessageService; use app\common\service\order\Refund as RefundService; use app\store\model\User as UserModel; +use app\store\model\Order as OrderModel; /** * 售后单模型 @@ -199,7 +202,7 @@ class OrderRefund extends OrderRefundModel // 拒绝申请, 标记售后单状态为已拒绝 $data['audit_status'] == AuditStatusEnum::REJECTED && $data['status'] = RefundStatusEnum::REJECTED; // 同意换货申请, 标记售后单状态为已完成 - $data['audit_status'] == AuditStatusEnum::REVIEWED && $this['type'] == RefundTypeEnum::EXCHANGE && $data['status'] = RefundStatusEnum::COMPLETED; + // $data['audit_status'] == AuditStatusEnum::REVIEWED && $this['type'] == RefundTypeEnum::EXCHANGE && $data['status'] = RefundStatusEnum::COMPLETED; // 更新售后单状态 $this->save($data); // 同意售后申请, 记录退货地址 @@ -291,7 +294,40 @@ class OrderRefund extends OrderRefundModel }); return true; } + /** + * 确认收货并更改换货状态 + * @param array $data + * @return bool + */ + public function huanhuo(array $data): bool + { + // 订单详情 + $order = Order::detail($this['order_id']); + $data['refund_money'] = empty($data['refund_money'])?0:$data['refund_money']; + // 事务处理 + $this->transaction(function () use ($order, $data) { + + // 更新售后单状态 + $this->save([ + 'refund_money' => $data['refund_money'], + 'is_receipt' => 1, + 'status' => RefundStatusEnum::COMPLETED + ]); + // 条件:判断订单是否已结算 + if ($order['is_settled']) { + (new UserModel)->setDecUserExpend($order['user_id'], $data['refund_money']); + } + // 更新主订单状态为未发货 + (new OrderModel)->save(['order_status'=>OrderStatusEnum::NORMAL,'delivery_status'=>DeliveryStatusEnum::NOT_DELIVERED,'order_id'=>$order['order_id']]); + // 发送消息通知 + MessageService::send('order.refund', [ + 'refund' => $this, // 售后单信息 + 'order_no' => $order['order_no'], // 订单信息 + ], $this['store_id']); + }); + return true; + } /** * 获取待处理售后单数量 * @return int From 51d1bb96ba4fbdbb38f344a25ced89951ee67dbf Mon Sep 17 00:00:00 2001 From: "yangsai@163.com" <2624183217@qq.com> Date: Thu, 16 May 2024 19:05:58 +0800 Subject: [PATCH 16/18] =?UTF-8?q?YS=E6=8D=A2=E8=B4=A7=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/controller/Refund.php | 11 ++--------- app/store/controller/order/Refund.php | 11 +++++++++-- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/app/api/controller/Refund.php b/app/api/controller/Refund.php index 2f873005..e343474f 100644 --- a/app/api/controller/Refund.php +++ b/app/api/controller/Refund.php @@ -12,7 +12,6 @@ declare (strict_types=1); namespace app\api\controller; -use app\common\enum\order\refund\RefundType as RefundTypeEnum; use think\response\Json; use app\api\model\OrderRefund as OrderRefundModel; @@ -92,14 +91,8 @@ class Refund extends Controller { // 售后单详情 $model = OrderRefundModel::getDetail($orderRefundId, false); - if($model['type']==RefundTypeEnum::EXCHANGE){ - if ($model->huanhuo($this->postForm())) { - return $this->renderSuccess([], '操作成功'); - } - }else{ - if ($model->delivery($this->postForm())) { - return $this->renderSuccess([], '操作成功'); - } + if ($model->delivery($this->postForm())) { + return $this->renderSuccess([], '操作成功'); } return $this->renderError($model->getError() ?: '提交失败'); } diff --git a/app/store/controller/order/Refund.php b/app/store/controller/order/Refund.php index 34655b9f..eb239ea6 100644 --- a/app/store/controller/order/Refund.php +++ b/app/store/controller/order/Refund.php @@ -12,6 +12,7 @@ declare (strict_types=1); namespace app\store\controller\order; +use app\common\enum\order\refund\RefundType as RefundTypeEnum; use think\response\Json; use app\store\controller\Controller; use app\store\model\OrderRefund as OrderRefundModel; @@ -77,8 +78,14 @@ class Refund extends Controller // 售后单详情 $model = OrderRefundModel::detail($orderRefundId); // 确认收货并退款 - if ($model->receipt($this->postForm())) { - return $this->renderSuccess('操作成功'); + if($model['type']==RefundTypeEnum::EXCHANGE){ + if ($model->huanhuo($this->postForm())) { + return $this->renderSuccess([], '操作成功'); + } + }else{ + if ($model->receipt($this->postForm())) { + return $this->renderSuccess('操作成功'); + } } return $this->renderError($model->getError() ?: '操作失败'); } From 89d155c217b323ac82debe8f69274a14f5b8758c Mon Sep 17 00:00:00 2001 From: "yangsai@163.com" <2624183217@qq.com> Date: Thu, 16 May 2024 19:14:14 +0800 Subject: [PATCH 17/18] =?UTF-8?q?YS=20:=E6=8D=A2=E8=B4=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/store/model/OrderRefund.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/store/model/OrderRefund.php b/app/store/model/OrderRefund.php index 4853810e..a31a4586 100644 --- a/app/store/model/OrderRefund.php +++ b/app/store/model/OrderRefund.php @@ -319,7 +319,7 @@ class OrderRefund extends OrderRefundModel (new UserModel)->setDecUserExpend($order['user_id'], $data['refund_money']); } // 更新主订单状态为未发货 - (new OrderModel)->save(['order_status'=>OrderStatusEnum::NORMAL,'delivery_status'=>DeliveryStatusEnum::NOT_DELIVERED,'order_id'=>$order['order_id']]); + (new OrderModel)->update(['order_status'=>OrderStatusEnum::NORMAL,'delivery_status'=>DeliveryStatusEnum::NOT_DELIVERED],['order_id'=>$order['order_id']]); // 发送消息通知 MessageService::send('order.refund', [ 'refund' => $this, // 售后单信息 From 77c0943e69e526bb970ed166b65abf7d9509a8ed Mon Sep 17 00:00:00 2001 From: "yangsai@163.com" <2624183217@qq.com> Date: Thu, 16 May 2024 20:02:11 +0800 Subject: [PATCH 18/18] YS --- app/common/model/Order.php | 2 +- app/store/model/OrderRefund.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/app/common/model/Order.php b/app/common/model/Order.php index 288fd7c7..11ec7e96 100644 --- a/app/common/model/Order.php +++ b/app/common/model/Order.php @@ -182,7 +182,7 @@ class Order extends BaseModel if ($data['receipt_status'] == ReceiptStatusEnum::NOT_RECEIVED) { return '待收货'; } - return $value; + return empty($value)?'':$value; } /** diff --git a/app/store/model/OrderRefund.php b/app/store/model/OrderRefund.php index a31a4586..d49a768e 100644 --- a/app/store/model/OrderRefund.php +++ b/app/store/model/OrderRefund.php @@ -16,6 +16,7 @@ use app\api\service\User as UserService; use app\common\enum\order\DeliveryStatus as DeliveryStatusEnum; use app\common\enum\order\DeliveryType; use app\common\enum\order\OrderStatus as OrderStatusEnum; +use app\common\enum\order\ReceiptStatus; use app\common\enum\order\refund\AuditStatus as AuditStatusEnum; use app\common\enum\order\refund\RefundStatus as RefundStatusEnum; use app\common\enum\order\refund\RefundType as RefundTypeEnum; @@ -25,6 +26,7 @@ use app\common\service\Message as MessageService; use app\common\service\order\Refund as RefundService; use app\store\model\User as UserModel; use app\store\model\Order as OrderModel; +use app\store\model\OrderGoods as OrderGoodsMOdel; /** * 售后单模型 @@ -320,6 +322,7 @@ class OrderRefund extends OrderRefundModel } // 更新主订单状态为未发货 (new OrderModel)->update(['order_status'=>OrderStatusEnum::NORMAL,'delivery_status'=>DeliveryStatusEnum::NOT_DELIVERED],['order_id'=>$order['order_id']]); + (new OrderGoodsModel)->update(['delivery_status'=>DeliveryStatusEnum::NOT_DELIVERED],['order_id'=>$order['order_id']]); // 发送消息通知 MessageService::send('order.refund', [ 'refund' => $this, // 售后单信息