|
@@ -7,6 +7,7 @@ use app\admin\validate\coupon\CouponValidate;
|
|
use app\admin\validate\device\DeviceValidate;
|
|
use app\admin\validate\device\DeviceValidate;
|
|
use app\admin\validate\order\OrderExpressValidate;
|
|
use app\admin\validate\order\OrderExpressValidate;
|
|
use app\admin\validate\order\OrderValidate;
|
|
use app\admin\validate\order\OrderValidate;
|
|
|
|
+use app\common\payment\AppUtil;
|
|
use app\common\payment\Tlpay;
|
|
use app\common\payment\Tlpay;
|
|
use app\controller\Curd;
|
|
use app\controller\Curd;
|
|
use app\model\Appointment;
|
|
use app\model\Appointment;
|
|
@@ -309,7 +310,6 @@ class WholeController extends Curd
|
|
}
|
|
}
|
|
|
|
|
|
$payDetail = PayDetail::where('join_pay_order_id', $order->order_groupby)->first();
|
|
$payDetail = PayDetail::where('join_pay_order_id', $order->order_groupby)->first();
|
|
- dump($payDetail);
|
|
|
|
if ($payDetail->pay_category == 'CASH') {
|
|
if ($payDetail->pay_category == 'CASH') {
|
|
$memberAccount = MemberAccount::where('join_account_member_id', $payDetail->join_pay_member_id)
|
|
$memberAccount = MemberAccount::where('join_account_member_id', $payDetail->join_pay_member_id)
|
|
->where('member_account_classify', 'CASH')
|
|
->where('member_account_classify', 'CASH')
|
|
@@ -952,6 +952,10 @@ class WholeController extends Curd
|
|
if (!$order) {
|
|
if (!$order) {
|
|
return json_fail("订单异常");
|
|
return json_fail("订单异常");
|
|
}
|
|
}
|
|
|
|
+ if ($order->order_is_complete == 'Y' || $order->order_is_complete == 'R'){
|
|
|
|
+
|
|
|
|
+ return json_fail('订单已完成,无法退款');
|
|
|
|
+ }
|
|
if ($amount > $order->order_amount_pay) {
|
|
if ($amount > $order->order_amount_pay) {
|
|
return json_fail('退款金额不能超过订单金额');
|
|
return json_fail('退款金额不能超过订单金额');
|
|
}
|
|
}
|
|
@@ -978,22 +982,50 @@ class WholeController extends Curd
|
|
|
|
|
|
try {
|
|
try {
|
|
Db::beginTransaction();
|
|
Db::beginTransaction();
|
|
|
|
+ // 订单主表
|
|
|
|
+ Order::where('order_id', $return->join_return_order_id)->update(['order_is_complete' => 'R']);
|
|
|
|
+ // return 表
|
|
|
|
+ $return->order_return_status = 'DONE';
|
|
|
|
+ $return->save();
|
|
|
|
+
|
|
$tlpay = new Tlpay();
|
|
$tlpay = new Tlpay();
|
|
- $return = $tlpay->refund($data);
|
|
|
|
|
|
+ $res = $tlpay->refund($data);
|
|
|
|
+
|
|
|
|
+ // 生成payDetail
|
|
|
|
+ $payDetailData = [
|
|
|
|
+ 'join_pay_member_id' => $order->join_order_member_id,
|
|
|
|
+ 'join_pay_order_id' => $order->order_groupby,
|
|
|
|
+ 'pay_status' => 'SUCCESS',
|
|
|
|
+ 'pay_category' => 'REFUND',
|
|
|
|
+ 'pay_amount' => $amount,
|
|
|
|
+ 'pay_paytimes' => date('Y-m-d H:i:s'),
|
|
|
|
+ 'pay_json_request' => json_encode($data),
|
|
|
|
+ 'pay_json_response' => $res,
|
|
|
|
+ 'pay_prepayid' => 0,
|
|
|
|
+ 'pay_addtimes' => time()
|
|
|
|
+ ];
|
|
|
|
+ PayDetail::insert($payDetailData);
|
|
|
|
+
|
|
|
|
+ $resArray = json_decode($res, true);
|
|
|
|
+ if (AppUtil::validSign($resArray)) {
|
|
|
|
+ if ($resArray['retcode'] != 'SUCCESS' || $resArray['trxstatus'] != '0000') {
|
|
|
|
+// throw new PayException('退款失败,原因:' . $resArray['errmsg']);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
Db::commit();
|
|
Db::commit();
|
|
|
|
|
|
- _syslog("退款", "发起退款", $return, $data);
|
|
|
|
|
|
+ _syslog("退款", "发起退款", $resArray, $data);
|
|
return json_success("退款成功");
|
|
return json_success("退款成功");
|
|
} catch (PayException $e) {
|
|
} catch (PayException $e) {
|
|
Db::rollBack();
|
|
Db::rollBack();
|
|
|
|
|
|
- _syslog("退款", "发起退款", $e->getMessage(), $data);
|
|
|
|
- return json_fail("发起退款失败");
|
|
|
|
|
|
+ _syslog("退款", "发起退款", $resArray ?? $e->getMessage(), $data);
|
|
|
|
+ return json_fail($e->getMessage());
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
Db::rollBack();
|
|
Db::rollBack();
|
|
|
|
|
|
- _syslog("退款", "发起退款", $e->getMessage(), $data);
|
|
|
|
|
|
+ _syslog("退款", "发起退款", $resArray ?? $e->getMessage(), $data);
|
|
return json_fail("数据更新失败");
|
|
return json_fail("数据更新失败");
|
|
}
|
|
}
|
|
}
|
|
}
|