|
|
@@ -10,8 +10,10 @@ use bizHd\member\classes\MemberWealClass;
|
|
|
use bizHd\order\classes\OrderClass;
|
|
|
use bizHd\order\classes\SettleClass;
|
|
|
use bizHd\shop\classes\MainClass;
|
|
|
+use bizHd\wx\classes\WxOpenClass;
|
|
|
use common\components\arrayUtil;
|
|
|
use common\components\dict;
|
|
|
+use common\components\lakala\Lakala;
|
|
|
use common\components\noticeUtil;
|
|
|
use common\components\util;
|
|
|
use Yii;
|
|
|
@@ -24,6 +26,67 @@ class RechargeClass extends BaseClass
|
|
|
|
|
|
public static function addRecharge($data)
|
|
|
{
|
|
|
+ //创建充值单时,要把过去的充值单和结账单取消掉
|
|
|
+ $customId = $data['customId'] ?? 0;
|
|
|
+ if (empty($customId)) {
|
|
|
+ util::fail('没有客户信息');
|
|
|
+ }
|
|
|
+ $shopId = $data['shopId'] ?? 0;
|
|
|
+ $hasList = self::getAllByCondition(['customId' => $customId, 'status' => 0], null, '*', null, true);
|
|
|
+ if (!empty($hasList)) {
|
|
|
+ $shop = \bizHd\merchant\classes\ShopClass::getById($shopId, true);
|
|
|
+ if (empty($shop)) {
|
|
|
+ util::fail('没有找到门店');
|
|
|
+ }
|
|
|
+ foreach ($hasList as $k => $recharge) {
|
|
|
+ $payRequest = $recharge->payRequest ?? 0;
|
|
|
+ if ($payRequest == 0) {
|
|
|
+ $recharge->status = 2;
|
|
|
+ $recharge->save();
|
|
|
+ } else {
|
|
|
+ $closeOrderSn = $recharge->orderSn;
|
|
|
+ $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);
|
|
|
+ $closeParams = ['orderSn' => $closeOrderSn];
|
|
|
+ if ($payRequest == 1) {
|
|
|
+ //聚合支付
|
|
|
+ $response = $laResource->close($closeParams);
|
|
|
+ if (!isset($response['code']) || $response['code'] != 'BBS00000') {
|
|
|
+ $msg = $response['msg'] ?? '';
|
|
|
+ noticeUtil::push('重点注意,充值换单号没有成功,单号:' . $closeOrderSn . ',关单没有成功,编号966558,' . $msg, '15280215347');
|
|
|
+ util::fail('老订单取消失败,请联系管理员');
|
|
|
+ } else {
|
|
|
+ noticeUtil::push('充值,聚合支付关单成功,编号636996,', '15280215347');
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //收银台支付
|
|
|
+ $response = $laResource->cashClose($closeParams);
|
|
|
+ if (!isset($response['code']) || $response['code'] != '000000') {
|
|
|
+ $msg = $response['msg'] ?? '';
|
|
|
+ noticeUtil::push('重点注意,充值换单,收银台的单号:' . $closeOrderSn . ',关单没有成功,编号66996,' . $msg, '15280215347');
|
|
|
+ util::fail('旧订单取消失败,请联系管理员');
|
|
|
+ } else {
|
|
|
+ noticeUtil::push('充值,收银台关单成功,编号665996,', '15280215347');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $settleId = $recharge->settleId ?? 0;
|
|
|
+ $settle = SettleClass::getById($settleId, true);
|
|
|
+ if (!empty($settle)) {
|
|
|
+ $settle->status = 3;
|
|
|
+ $settle->save();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
return self::add($data, true);
|
|
|
}
|
|
|
|
|
|
@@ -116,8 +179,8 @@ class RechargeClass extends BaseClass
|
|
|
'style' => 0,
|
|
|
'rechargeAmount' => floatval($amount),
|
|
|
'onlinePay' => $onlinePay,
|
|
|
- 'staffId'=>$staffId,
|
|
|
- 'staffName'=>$staffName,
|
|
|
+ 'staffId' => $staffId,
|
|
|
+ 'staffName' => $staffName,
|
|
|
];
|
|
|
if ($newLevel > $oldLevel) {
|
|
|
CustomClass::levelChange($oldLevel, $newLevel, $shop, $custom, $hd, $params);
|