作者 耿培杰

修改退款接口

... ... @@ -1246,7 +1246,7 @@ class Order extends Api
}
$order = $this->orderModel->where(['id' => $param['order_id']])->find();
if (!$order) $this->error('订单不存在');
if ($order['status'] == 2) $this->error('订单已支付');
if ($order['status'] == 10) $this->error('订单已支付');
if ($order['status'] == -1) $this->error('订单已取消');
//判断积分
if ($order['score'] > $this->user['score']) $this->error('积分不足');
... ... @@ -1608,12 +1608,19 @@ class Order extends Api
//10分钟内直接全额退款
$pay = new Pay();
$userModel = new \app\api\model\User();
//查询是否有其他商品没退款的
$last = $this->orderInfoModel->where(['order_id'=>$order_id,'id'=>['<>',$order_info_id],'status'=>1])->count();
//已退款的金额
$refunded_money = $this->orderInfoModel->where(['order_id'=>$order_id,'id'=>['<>',$order_info_id],'status'=>3])->sum('goods_total');
if ($last) $refund_money = $orderInfo['goods_total'];
else $refund_money = $order['pay_total'] - $refunded_money;
if ($orderInfo['pay_type'] == 1){
//微信退款
$result = $pay->refundGoods($order['order_num'],$orderInfo['pay_total'],$orderInfo['id'],$refund_note,$orderInfo['goods_total']);
$result = $pay->refundGoods($order['order_num'],$orderInfo['pay_total'],$orderInfo['id'],$refund_note,$refund_money);
}else{
//余额退款
$result = $userModel->refundGoods($orderInfo['user_id'],$orderInfo['goods_total'],$orderInfo['id'],$refund_note);
$result = $userModel->refundGoods($orderInfo['user_id'],$refund_money,$orderInfo['id'],$refund_note);
}
$msg = '退款';
}else{
... ...