| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace bizHd\refund\classes;
- use biz\shop\classes\ShopExtClass;
- use common\components\noticeUtil;
- use common\components\orderSn;
- use Yii;
- use bizHd\base\classes\BaseClass;
- use common\components\lakala\Lakala;
- class HdRefundClass extends BaseClass
- {
- public static $baseFile = '\bizHd\refund\models\HdRefund';
- const REFUND_TYPE_MONEY_GOOD = 1; //退款退货
- const REFUND_TYPE_MONEY = 2; // 仅退款
- const STATUS_UN_COMPLETE = 0; //退款处理中
- const STATUS_COMPLETE = 1; //已完成
- public static function onlyRefundAmount($shop, $order)
- {
- $refundSn = orderSn::getHdRefundSn();
- $xsOrderSn = $order['orderSn'] ?? '';
- $refundPrice = $order['actPrice'] ?? 0;
- $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 = '';
- $orderSn = '';
- $thirdNo = $order['thirdNo'] ?? '';
- //竟然会出现thirdNo为空的情况,好像客户付款时有优惠金额时
- if (empty($thirdNo)) {
- $orderSn = $order['orderSn'] ?? '';
- }
- $backParams = [
- 'refundSn' => $refundSn,
- 'thirdNo' => $thirdNo,
- 'orderSn' => $orderSn,
- 'refundAmount' => $refundFee,
- 'refundReason' => $refundReason,
- ];
- $response = $laResource->refund($backParams);
- if (!isset($response['code']) || $response['code'] != 'BBS00000') {
- $errMsg = $response['msg'] ?? '';
- noticeUtil::push("钱没有退回 {$xsOrderSn} {$errMsg}", '15280215347');
- return ['status' => 0, 'msg' => $errMsg];
- } else {
- $shopId = $shop->id;
- ShopExtClass::orderCancelBackMoneyReport($shopId);
- $sjName = $shop->merchantName;
- $shopName = $shop->shopName;
- $name = $shopName == '首店' ? $sjName : $sjName . '-' . $shopName;
- noticeUtil::push("钱已经原路退回 success {$xsOrderSn} {$name}", '15280215347');
- return ['status' => 1, 'msg' => '退款成功'];
- }
- }
- // 订单列表
- public static function getOrderList($where)
- {
- $data = self::getList('*', $where, 'addTime DESC');
- $list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
- if (empty($list)) {
- return $data;
- }
- $data['list'] = $list;
- return $data;
- }
- //验证信息 ssh 20220401
- public static function valid($refund, $mainId)
- {
- if (empty($refund)) {
- util::fail('没有找到退款信息');
- }
- if (isset($refund->mainId) == false || $refund->mainId != $mainId) {
- util::fail('无法操作');
- }
- return true;
- }
- }
|