...
|
...
|
@@ -13,6 +13,7 @@ use think\Hook; |
|
|
use EasyWeChat\Foundation\Application;
|
|
|
use think\Db;
|
|
|
use app\common\model\Attachment;
|
|
|
use think\Log;
|
|
|
use think\process\exception\Timeout;
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -480,6 +481,10 @@ class Common extends Api |
|
|
*/
|
|
|
public function TuikuanOperation()
|
|
|
{
|
|
|
Log::init([
|
|
|
'path' => LOG_PATH . 'tuikuanLog',
|
|
|
'type' => 'file'
|
|
|
]);
|
|
|
$UserId = $this->IsToken($this->request->header());
|
|
|
$params = $this->request->param();
|
|
|
$IsSeller = Db::name('agreement')
|
...
|
...
|
@@ -506,6 +511,10 @@ class Common extends Api |
|
|
$PayOrderInfo = Db::name('pay_order')->where('OrderSn', $OrderSn['OrderSn'])->where('type', 1)->select();
|
|
|
// $TuiMoney = $OrderSn['UpMoney'] + $OrderSn['Money'];
|
|
|
$TuiMoney = round(($OrderSn['UpMoney'] * $params['bili'] + $OrderSn['Money']), 2);
|
|
|
log::write('押金' . $params['UpMoney']);
|
|
|
log::write('剩余租金' . $params['Money']);
|
|
|
log::write('比例' . $params['bili']);
|
|
|
log::write('应退金额' . $TuiMoney);
|
|
|
//配置
|
|
|
$config = [
|
|
|
'app_id' => 'wx6a9080f20326f817',
|
...
|
...
|
@@ -524,6 +533,7 @@ class Common extends Api |
|
|
// Db::name('pay_order')->where('OrderSn', $OrderSn['OrderSn'])->where('PayOrder', $PayOrderInfo['PayOrder'])->update(['type' => 0]);
|
|
|
|
|
|
foreach ($PayOrderInfo as $k => $v) {
|
|
|
log::write('循环次数' . $k . '剩余应退金额' . $TuiMoney);
|
|
|
$result = $payment->refundByTransactionId($v['WeChatOrder'], $v['PayOrder'], $v['money'] * 100, (($TuiMoney > $v['money']) ? $v['money'] : $TuiMoney) * 100); // 总金额 100, 退款 80,操作员:商户号
|
|
|
//更改订单状态为已退款
|
|
|
Db::name('pay_order')->where('OrderSn', $OrderSn['OrderSn'])->where('PayOrder', $v['PayOrder'])->update(['type' => 0]);
|
...
|
...
|
@@ -531,7 +541,8 @@ class Common extends Api |
|
|
$this->error('退款失败', 0);
|
|
|
die;
|
|
|
}
|
|
|
$TuiMoney = ($TuiMoney > $v['money']) ? $TuiMoney - $v['money'] : 0;
|
|
|
$TuiMoney = ($TuiMoney > $v['money']) ? ($TuiMoney - $v['money']) : 0;
|
|
|
log::write('循环次数' . $k . '退款后剩余应退金额' . $TuiMoney);
|
|
|
if ($TuiMoney == 0) {
|
|
|
break;
|
|
|
}
|
...
|
...
|
|