lqmac 8 months ago
commit 5746acdc62
  1. 17
      app/admin/controller/Wxserve.php
  2. 5
      app/api/model/OrderRefund.php
  3. 26
      app/common/library/wxserver/Server.php
  4. 2
      app/common/model/Order.php
  5. 11
      app/store/controller/order/Refund.php
  6. 42
      app/store/model/OrderRefund.php

@ -223,6 +223,23 @@ 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') {
$result = $obj->submitAuditOne($appid);
if ($result['status']) {
return $this->renderSuccess('success');
} else {
return $this->renderError($result['msg']);
}
} else {
return $this->renderError('隐私接口错误');
}
}
/**
* @notes:发布正式版前检查
* @return Json

@ -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;
}
@ -169,7 +172,7 @@ class OrderRefund extends OrderRefundModel
public function delivery(array $data): bool
{
if (
$this['type'] != RefundTypeEnum::RETURN
!in_array($this['type'],[RefundTypeEnum::RETURN,RefundTypeEnum::EXCHANGE])
|| $this['audit_status'] != AuditStatusEnum::REVIEWED
|| $this['is_user_send'] != 0
) {

@ -698,6 +698,32 @@ class Server
return 0;
}
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);

@ -182,7 +182,7 @@ class Order extends BaseModel
if ($data['receipt_status'] == ReceiptStatusEnum::NOT_RECEIVED) {
return '待收货';
}
return $value;
return empty($value)?'':$value;
}
/**

@ -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() ?: '操作失败');
}

@ -13,7 +13,10 @@ 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\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;
@ -22,6 +25,8 @@ 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;
use app\store\model\OrderGoods as OrderGoodsMOdel;
/**
* 售后单模型
@ -199,7 +204,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);
// 同意售后申请, 记录退货地址
@ -261,6 +266,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;
@ -290,7 +296,41 @@ 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)->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, // 售后单信息
'order_no' => $order['order_no'], // 订单信息
], $this['store_id']);
});
return true;
}
/**
* 获取待处理售后单数量
* @return int

Loading…
Cancel
Save