退款
This commit is contained in:
parent
06bdfacbe5
commit
8299b9b428
@ -11,6 +11,9 @@ use app\common\model\store_order_cart_info\StoreOrderCartInfo;
|
|||||||
use app\common\model\store_product\StoreProduct;
|
use app\common\model\store_product\StoreProduct;
|
||||||
use app\common\model\store_product_unit\StoreProductUnit;
|
use app\common\model\store_product_unit\StoreProductUnit;
|
||||||
use app\common\model\user\UserAddress;
|
use app\common\model\user\UserAddress;
|
||||||
|
use app\common\service\pay\PayService;
|
||||||
|
use Exception;
|
||||||
|
use support\Cache;
|
||||||
use think\facade\Db;
|
use think\facade\Db;
|
||||||
|
|
||||||
class StoreOrderLogic extends BaseLogic
|
class StoreOrderLogic extends BaseLogic
|
||||||
@ -165,4 +168,47 @@ class StoreOrderLogic extends BaseLogic
|
|||||||
return StoreOrder::where($where)->sum('pay_price');
|
return StoreOrder::where($where)->sum('pay_price');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 退款
|
||||||
|
* @param $order_sn
|
||||||
|
* @param $refund_money
|
||||||
|
* @param $total
|
||||||
|
* @return bool
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public function refund($order_sn,$refund_money,$total)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
$wechat = new PayService(1);
|
||||||
|
$time = time();
|
||||||
|
$order = [
|
||||||
|
'out_trade_no' => $order_sn,
|
||||||
|
'out_refund_no' => 'BO'.$time,
|
||||||
|
'amount' => [
|
||||||
|
'refund' => $refund_money,
|
||||||
|
'total' => $total,
|
||||||
|
'currency' => 'CNY',
|
||||||
|
],
|
||||||
|
// '_action' => 'jsapi', // jsapi 退款,默认
|
||||||
|
// '_action' => 'app', // app 退款
|
||||||
|
// '_action' => 'combine', // 合单退款
|
||||||
|
// '_action' => 'h5', // h5 退款
|
||||||
|
// '_action' => 'miniapp', // 小程序退款
|
||||||
|
// '_action' => 'native', // native 退款
|
||||||
|
|
||||||
|
];
|
||||||
|
|
||||||
|
$res = $wechat->wechat->refund($order);
|
||||||
|
if($res['status'] == 'PROCESSING'){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
} catch (Exception $e) {
|
||||||
|
\support\Log::info($e->extra['message']?? $e->getMessage());
|
||||||
|
throw new \Exception($e->extra['message']?? $e->getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user