|
|
@@ -15,9 +15,11 @@ use bizGhs\shop\classes\ShopMoneyClass;
|
|
|
use bizHd\purchase\classes\PurchaseClass;
|
|
|
use bizHd\purchase\classes\PurchaseClearClass;
|
|
|
use common\components\dict;
|
|
|
+use common\components\noticeUtil;
|
|
|
use common\components\orderSn;
|
|
|
use common\components\util;
|
|
|
use Yii;
|
|
|
+use common\components\lakala\Lakala;
|
|
|
|
|
|
class ClearClass extends BaseClass
|
|
|
{
|
|
|
@@ -28,6 +30,43 @@ class ClearClass extends BaseClass
|
|
|
const STATUS_HAS_PAY = 2;
|
|
|
const STATUS_EXPIRE = 3;
|
|
|
|
|
|
+ public static function refundMoney($shop, $clear)
|
|
|
+ {
|
|
|
+ $refundOrderSn = orderSn::getClearRefundSn();
|
|
|
+ $refundPrice = $clear->actPrice ?? 0;
|
|
|
+ $orderSn = $clear->orderSn ?? '';
|
|
|
+ $refundFee = bcmul($refundPrice, 100);
|
|
|
+ $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
|
|
|
+ $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
|
|
|
+ $params = [
|
|
|
+ 'appid' => 'OP00002119',
|
|
|
+ 'serial_no' => '018b08cfddbd',
|
|
|
+ 'merchant_no' => $shop->lklSjNo,
|
|
|
+ 'term_no' => $shop->lklScanTermNo,
|
|
|
+ 'merchantPrivateKeyPath' => $merchantPrivateKeyPath,
|
|
|
+ 'lklCertificatePath' => $lklCertificatePath,
|
|
|
+ ];
|
|
|
+ $laResource = new Lakala($params);
|
|
|
+ $refundReason = '';
|
|
|
+ $aliParams = [
|
|
|
+ 'refundSn' => $refundOrderSn,
|
|
|
+ 'orderSn' => $orderSn,
|
|
|
+ 'refundAmount' => $refundFee,
|
|
|
+ 'refundReason' => $refundReason,
|
|
|
+ ];
|
|
|
+ $response = $laResource->refund($aliParams);
|
|
|
+ if (!isset($response['code']) || $response['code'] != 'BBS00000') {
|
|
|
+ $errMsg = $response['msg'] ?? '';
|
|
|
+ return ['status' => 0, 'msg' => $errMsg];
|
|
|
+ } else {
|
|
|
+ $sjName = $shop->merchantName;
|
|
|
+ $shopName = $shop->shopName;
|
|
|
+ $name = $shopName == '首店' ? $sjName : $sjName . '-' . $shopName;
|
|
|
+ noticeUtil::push("结帐单取消了,客户付的钱也原路退回 success {$orderSn} {$name}", '15280215347');
|
|
|
+ return ['status' => 1, 'msg' => '退款成功'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
public static function addOrder($data)
|
|
|
{
|
|
|
$orderSn = orderSn::getPurchaseClearSn();
|
|
|
@@ -152,11 +191,11 @@ class ClearClass extends BaseClass
|
|
|
'ptStyle' => 2,
|
|
|
'capitalType' => $capitalType,
|
|
|
'amount' => $order->prePrice,
|
|
|
- 'staffId'=>$order->customShopAdminId,
|
|
|
- 'staffName'=>$order->customShopAdminName,
|
|
|
+ 'staffId' => $order->customShopAdminId,
|
|
|
+ 'staffName' => $order->customShopAdminName,
|
|
|
'balance' => $ghs->debtAmount,
|
|
|
'io' => 0,
|
|
|
- 'event' => '采购单结账 ' .$order->orderSn ,
|
|
|
+ 'event' => '采购单结账 ' . $order->orderSn,
|
|
|
'sjId' => $order->sjId,
|
|
|
'shopId' => $order->shopId,
|
|
|
];
|