|
|
@ -13,7 +13,13 @@ declare (strict_types=1); |
|
|
|
namespace app\store\model\recharge; |
|
|
|
namespace app\store\model\recharge; |
|
|
|
|
|
|
|
|
|
|
|
use app\common\model\recharge\Order as OrderModel; |
|
|
|
use app\common\model\recharge\Order as OrderModel; |
|
|
|
|
|
|
|
use app\common\enum\order\refund\AuditStatus as AuditStatusEnum; |
|
|
|
|
|
|
|
use app\common\enum\payment\Method as PaymentMethodEnum; |
|
|
|
|
|
|
|
use app\common\enum\recharge\order\PayStatus as PayStatusEnum; |
|
|
|
|
|
|
|
use app\api\model\User as UserModel; |
|
|
|
|
|
|
|
use app\common\enum\user\balanceLog\Scene as SceneEnum; |
|
|
|
|
|
|
|
use app\api\model\user\BalanceLog as BalanceLogModel; |
|
|
|
|
|
|
|
use app\common\model\UploadFile; |
|
|
|
/** |
|
|
|
/** |
|
|
|
* 用户充值订单模型 |
|
|
|
* 用户充值订单模型 |
|
|
|
* Class Order |
|
|
|
* Class Order |
|
|
@ -74,4 +80,70 @@ class Order extends OrderModel |
|
|
|
} |
|
|
|
} |
|
|
|
return $filter; |
|
|
|
return $filter; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 获取售后单详情 |
|
|
|
|
|
|
|
* @param int $rechargeOrderId |
|
|
|
|
|
|
|
* @return OrderRefund|false|null |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function getDetail(int $rechargeOrderId) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$detail = static::detail($rechargeOrderId, [ |
|
|
|
|
|
|
|
'user','orderPlan', |
|
|
|
|
|
|
|
]) ?: false; |
|
|
|
|
|
|
|
if (!$detail) { |
|
|
|
|
|
|
|
return $detail; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if ($detail->upload_images) { |
|
|
|
|
|
|
|
$img_ids = json_decode($detail->upload_images, true); |
|
|
|
|
|
|
|
$files = UploadFile::getFileList($img_ids); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$detail->upload_images = !$files->isEmpty() ? $files->toArray() : []; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return $detail; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 商家审核 |
|
|
|
|
|
|
|
* @param array $data |
|
|
|
|
|
|
|
* @return bool |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function audit(int $rechargeOrderId, array $data): bool |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if ($data['audit_status'] == AuditStatusEnum::REJECTED && empty($data['refuse_desc'])) { |
|
|
|
|
|
|
|
$this->error = '请输入拒绝原因'; |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->transaction(function () use ($data, $rechargeOrderId) { |
|
|
|
|
|
|
|
if ($data['audit_status'] == AuditStatusEnum::REJECTED) { |
|
|
|
|
|
|
|
$data['pay_status'] = PayStatusEnum::PENDING; |
|
|
|
|
|
|
|
} elseif ($data['audit_status'] == AuditStatusEnum::REVIEWED) { |
|
|
|
|
|
|
|
$data['pay_status'] = PayStatusEnum::SUCCESS; |
|
|
|
|
|
|
|
$data['pay_method'] = PaymentMethodEnum::VOUCHER; |
|
|
|
|
|
|
|
$data['pay_time'] = time(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// var_dump($data); |
|
|
|
|
|
|
|
// exit(); |
|
|
|
|
|
|
|
// 更新售后单状态 |
|
|
|
|
|
|
|
$this->save($data); |
|
|
|
|
|
|
|
// 同意售后申请, 记录退货地址 |
|
|
|
|
|
|
|
if ($data['audit_status'] == AuditStatusEnum::REVIEWED) { |
|
|
|
|
|
|
|
$orderInfo = self::detail($rechargeOrderId); |
|
|
|
|
|
|
|
//新增用户充值记录和给用户加余额 |
|
|
|
|
|
|
|
// 累积用户余额 |
|
|
|
|
|
|
|
UserModel::setIncBalance((int)$orderInfo['user_id'], (float)$orderInfo['actual_money']); |
|
|
|
|
|
|
|
// 用户余额变动明细 |
|
|
|
|
|
|
|
BalanceLogModel::add(SceneEnum::RECHARGE, [ |
|
|
|
|
|
|
|
'user_id' => $orderInfo['user_id'], |
|
|
|
|
|
|
|
'money' => $orderInfo['actual_money'], |
|
|
|
|
|
|
|
'store_id' => empty($orderInfo['store_id'])?$this->getStoreId():$orderInfo['store_id'], |
|
|
|
|
|
|
|
], ['order_no' => $orderInfo['order_no']],$orderInfo['store_id']); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|