|
|
@@ -9,6 +9,7 @@ use bizGhs\ghs\classes\GhsClass;
|
|
|
use bizGhs\order\classes\OrderItemClass;
|
|
|
use bizGhs\order\classes\RefundOrderClass;
|
|
|
use bizHd\purchase\classes\PurchaseClass;
|
|
|
+use bizHd\purchase\classes\PurchaseItemClass;
|
|
|
use bizHd\purchase\services\PurchaseService;
|
|
|
use bizHd\wx\classes\WxOpenClass;
|
|
|
use bizGhs\custom\classes\CustomClass;
|
|
|
@@ -23,8 +24,10 @@ use common\components\dirUtil;
|
|
|
use common\components\freight;
|
|
|
use common\components\httpUtil;
|
|
|
use common\components\noticeUtil;
|
|
|
+use common\components\orderSn;
|
|
|
use common\components\oss;
|
|
|
use common\components\payUtil;
|
|
|
+use common\components\printUtil;
|
|
|
use common\components\qrCodeUtil;
|
|
|
use common\components\stringUtil;
|
|
|
use Yii;
|
|
|
@@ -654,35 +657,75 @@ class OrderController extends BaseController
|
|
|
$get = Yii::$app->request->get();
|
|
|
$id = isset($get['id']) ? $get['id'] : 0;
|
|
|
$order = OrderClass::getById($id, true);
|
|
|
- if (isset($order->status) == false || $order->status != 1) {
|
|
|
- util::fail('不是待付款订单');
|
|
|
+ if (empty($order)) {
|
|
|
+ $msg = '没有找到订单';
|
|
|
+ util::success(['returnStatus' => 'FAILURE'], $msg);
|
|
|
+ }
|
|
|
+ if ($order->status != 1) {
|
|
|
+ $msg = '不是待付款订单';
|
|
|
+ util::success(['returnStatus' => 'FAILURE'], $msg);
|
|
|
}
|
|
|
OrderClass::valid($order, $this->shopId);
|
|
|
$cgId = $order->purchaseId ?? 0;
|
|
|
$cg = PurchaseClass::getById($cgId, true);
|
|
|
$orderSn = $cg->orderSn ?? '';
|
|
|
if (empty($orderSn)) {
|
|
|
- util::fail('没有找到采购单');
|
|
|
+ $msg = '没有找到采购单';
|
|
|
+ util::success(['returnStatus' => 'FAILURE'], $msg);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ $codePayErrorKey = 'code_pay_error_' . $id;
|
|
|
+ $hasFailPay = Yii::$app->redis->executeCommand('GET', [$codePayErrorKey]);
|
|
|
+ //前面有付失败过,要重新生成单号
|
|
|
+ if (!empty($hasFailPay)) {
|
|
|
+ $oldOrderSn = $orderSn;
|
|
|
+ $orderSn = orderSn::getPurchaseSn();
|
|
|
+ $cg->orderSn = $orderSn;
|
|
|
+ $cg->save();
|
|
|
+ noticeUtil::push("重新扫码,成功更换单号 {$oldOrderSn} {$orderSn}", '15280215347');
|
|
|
+ PurchaseItemClass::updateByCondition(['orderSn' => $oldOrderSn], ['orderSn' => $orderSn]);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $shop = $this->shop;
|
|
|
+ $sj = $shop->merchantName;
|
|
|
+ $shopName = $shop->shopName;
|
|
|
+ $name = $shopName == '首店' ? $sj : $sj . '-' . $shopName;
|
|
|
+
|
|
|
//付款码
|
|
|
$authCode = (string)$get['authCode'] ?? '';
|
|
|
+ $authCode = trim($authCode);
|
|
|
if (empty($authCode)) {
|
|
|
- util::fail('支付失败');
|
|
|
+ $msg = '没有扫到付款码';
|
|
|
+ $remind = $msg . "(付款码:{$authCode})" . '(' . $name . ')';
|
|
|
+ noticeUtil::push($remind . ' 编号001', '15280215347');
|
|
|
+ util::success(['returnStatus' => 'FAILURE'], $msg);
|
|
|
+ }
|
|
|
+ //微信文档说明 https://pay.weixin.qq.com/doc/v2/merchant/4011936234
|
|
|
+ $wxPattern = '/^(10|11|12|13|14|15)\d{16}$/';
|
|
|
+ //支付宝文档说明 https://opendocs.alipay.com/open/194/106039/
|
|
|
+ $aliPattern = '/^(25|26|27|28|29|30)\d{14,22}$/';
|
|
|
+ if (!preg_match($wxPattern, $authCode) && !preg_match($aliPattern, $authCode)) {
|
|
|
+ $msg = '付款码有问题';
|
|
|
+ $remind = $msg . "(付款码:{$authCode})" . '(' . $name . ')';
|
|
|
+ noticeUtil::push($remind . ' 编号002', '15280215347');
|
|
|
+ util::success(['returnStatus' => 'FAILURE'], $msg);
|
|
|
}
|
|
|
|
|
|
$deadline = $cg->deadline;
|
|
|
$current = date("Y-m-d H:i:s");
|
|
|
if ((strtotime($deadline) + 20) < strtotime($current)) {
|
|
|
- util::fail('订单已经失效');
|
|
|
+ $msg = '订单已经失效';
|
|
|
+ util::success(['returnStatus' => 'FAILURE'], $msg);
|
|
|
}
|
|
|
$totalFee = $cg->actPrice ?? 0;
|
|
|
|
|
|
$connection = Yii::$app->db;
|
|
|
$transaction = $connection->beginTransaction();
|
|
|
try {
|
|
|
- $subject = '购买花材';
|
|
|
+ $subject = '购买花材 '.$orderSn;
|
|
|
$capitalType = dict::getDict('capitalType', 'xhPurchase', 'id');
|
|
|
- $shop = $this->shop;
|
|
|
$merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
|
|
|
$lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
|
|
|
$params = [
|
|
|
@@ -768,8 +811,19 @@ class OrderController extends BaseController
|
|
|
}
|
|
|
util::success(['returnStatus' => 'SUCCESS']);
|
|
|
} else {
|
|
|
+
|
|
|
+ //标记有没付成功的次数,原因有可能是余额不足等
|
|
|
+ Yii::$app->redis->executeCommand('SETEX', [$codePayErrorKey, 1200, 'hasFail']);
|
|
|
+
|
|
|
$msg = $response['msg'] ?? '';
|
|
|
- util::success(['returnStatus' => 'FAILURE'], $msg);
|
|
|
+ $retCode = $response['code'] ?? '';
|
|
|
+ if ($retCode == 'BBS10000' || $retCode == 'BBS11105') {
|
|
|
+ $shopId = $order->shopId;
|
|
|
+ ShopExtClass::remindInputPassword($shopId);
|
|
|
+ }
|
|
|
+ $fullMsg = $msg . "(付款码:{$authCode})" . '(' . $name . ')';
|
|
|
+ noticeUtil::push($fullMsg . ' ' . $retCode . ' 编号007', '15280215347');
|
|
|
+ util::success(['returnStatus' => 'FAILURE', 'returnCode' => $retCode], $msg);
|
|
|
}
|
|
|
} catch (\Exception $e) {
|
|
|
$transaction->rollBack();
|
|
|
@@ -976,7 +1030,7 @@ class OrderController extends BaseController
|
|
|
Yii::$app->redis->executeCommand('SETEX', [$createOrderCacheKey, 5, 'has']);
|
|
|
|
|
|
CustomClass::valid($custom, $this->shopId);
|
|
|
- if (isset($custom['mainId']) && !empty($custom['mainId']) && $custom['mainId'] == $custom['ownMainId']) {
|
|
|
+ if (!empty($custom['mainId']) && $custom['mainId'] == $custom['ownMainId']) {
|
|
|
util::fail('不能给自己开单');
|
|
|
}
|
|
|
$post['ghsId'] = $custom['ghsId'] ?? 0;
|
|
|
@@ -994,10 +1048,24 @@ class OrderController extends BaseController
|
|
|
$post['showAddress'] = $custom['showAddress'] ?? '';
|
|
|
$post['long'] = $custom['long'] ?? '';
|
|
|
$post['lat'] = $custom['lat'] ?? '';
|
|
|
- if (isset($post['getStaffId']) == true && !empty($post['getStaffId'])) {
|
|
|
- $getStaffName = $post['getStaffName'] ?? '';
|
|
|
- $shopAdminId = $post['getStaffId'];
|
|
|
- $shopAdminName = $getStaffName;
|
|
|
+ if (!empty($post['getStaffId'])) {
|
|
|
+ if (getenv('YII_ENV') == 'production') {
|
|
|
+ $tbMainId = 44171;
|
|
|
+ } else {
|
|
|
+ $tbMainId = 644;
|
|
|
+ }
|
|
|
+ if ($this->mainId == $tbMainId) {
|
|
|
+ //平潭花天下,就算选了收款人,也不要给改变开单人,临时解决方案 ssh 2250314
|
|
|
+ if (!empty($post['shopAdminId'])) {
|
|
|
+ $getStaffName = $post['shopAdminName'] ?? '';
|
|
|
+ $shopAdminId = $post['shopAdminId'];
|
|
|
+ $shopAdminName = $getStaffName;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ $getStaffName = $post['getStaffName'] ?? '';
|
|
|
+ $shopAdminId = $post['getStaffId'];
|
|
|
+ $shopAdminName = $getStaffName;
|
|
|
+ }
|
|
|
} else {
|
|
|
if (getenv('YII_ENV') == 'production') {
|
|
|
//鹏诚需要选择开单人
|
|
|
@@ -1014,7 +1082,7 @@ class OrderController extends BaseController
|
|
|
if (getenv('YII_ENV') == 'production') {
|
|
|
//小向花卉开单售后控制
|
|
|
if ($this->mainId == 23390) {
|
|
|
- if (!in_array($this->adminId, [24043, 24585, 24586, 24654, 24115, 23960, 28456, 31105, 28456, 31105])) {
|
|
|
+ if (!in_array($this->adminId, [24043, 24585, 24586, 24654, 24115, 23960, 28456, 31105, 28456, 31105, 52528, 25011])) {
|
|
|
util::fail('你不能开单哦');
|
|
|
}
|
|
|
}
|
|
|
@@ -1038,6 +1106,15 @@ class OrderController extends BaseController
|
|
|
$transType = $post['transType'] ?? 0;
|
|
|
|
|
|
$shop = $this->shop;
|
|
|
+
|
|
|
+ //到期超过5天不支持开单
|
|
|
+ $deadline = $shop->deadline;
|
|
|
+ $deadTime = strtotime($deadline);
|
|
|
+ $myCurrentTime = time() + 432000;
|
|
|
+ if ($myCurrentTime > $deadTime) {
|
|
|
+ util::fail('系统已到期,请续费');
|
|
|
+ }
|
|
|
+
|
|
|
if (isset($shop->pfLevel) && $shop->pfLevel == 1) {
|
|
|
//昆明发往全国
|
|
|
$sendCost = isset($post['sendCost']) && $post['sendCost'] > 0 ? $post['sendCost'] : 0;
|
|
|
@@ -1077,15 +1154,15 @@ class OrderController extends BaseController
|
|
|
}
|
|
|
|
|
|
if (getenv('YII_ENV') == 'production') {
|
|
|
- if($this->mainId == 1082){
|
|
|
+ if ($this->mainId == 1082) {
|
|
|
//泉城鲜花批发的出车,只能开收现金方式,多处要修改,关键词qc_cash
|
|
|
- if($hasPay != 0){
|
|
|
+ if ($hasPay != 0) {
|
|
|
util::fail('只能使用扫码付款,编号193');
|
|
|
}
|
|
|
}
|
|
|
- }else{
|
|
|
- if($this->mainId == 644){
|
|
|
- if($hasPay != 0){
|
|
|
+ } else {
|
|
|
+ if ($this->mainId == 644) {
|
|
|
+ if ($hasPay != 0) {
|
|
|
//util::fail('只能使用扫码付款,编号190');
|
|
|
}
|
|
|
}
|
|
|
@@ -1465,11 +1542,11 @@ class OrderController extends BaseController
|
|
|
Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 4, 'has']);
|
|
|
|
|
|
if (getenv('YII_ENV') == 'production') {
|
|
|
- if($this->mainId == 1082){
|
|
|
+ if ($this->mainId == 1082) {
|
|
|
//泉城鲜花批发的出车,只能开收现金方式,多处要修改,关键词qc_cash
|
|
|
util::fail('只能使用扫码付款,编号293');
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -2304,7 +2381,7 @@ class OrderController extends BaseController
|
|
|
//超管或者约定的人可以修改日期
|
|
|
if (getenv('YII_ENV') == 'production') {
|
|
|
if (in_array($mainId, [23390])) {
|
|
|
- if (!in_array($this->adminId, [24586, 23960])) {
|
|
|
+ if (!in_array($this->adminId, [24586, 23960, 24043])) {
|
|
|
util::fail('你不能修改哦');
|
|
|
}
|
|
|
}
|
|
|
@@ -2854,4 +2931,55 @@ class OrderController extends BaseController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //打印发物流用和标签 ssh 20250312
|
|
|
+ public function actionPrintWlLabel()
|
|
|
+ {
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $id = $get['id'] ?? 0;
|
|
|
+ $order = OrderClass::getById($id, true);
|
|
|
+ if (empty($order)) {
|
|
|
+ util::fail('没有找到订单');
|
|
|
+ }
|
|
|
+ $customId = $order->customId ?? 0;
|
|
|
+ $custom = CustomClass::getById($customId, true);
|
|
|
+ if (empty($custom)) {
|
|
|
+ util::fail('没有找到客户');
|
|
|
+ }
|
|
|
+ $shortName = $custom->shortName ?? '';
|
|
|
+ if (empty($shortName)) {
|
|
|
+ util::fail('客户的短名没有设置');
|
|
|
+ }
|
|
|
+ $shortName = stringUtil::subStringUtf8($shortName, 5);
|
|
|
+ $customMobile = $order->customMobile ?? '';
|
|
|
+ if (empty($customMobile)) {
|
|
|
+ util::fail('客户手机号无效');
|
|
|
+ }
|
|
|
+ $shortMobile = substr($customMobile, -4);
|
|
|
+ $remark = $order->remark ?? '';
|
|
|
+ $shortRemark = stringUtil::subStringUtf8($remark, 8);
|
|
|
+
|
|
|
+ $shop = $this->shop;
|
|
|
+ $shopName = $shop->shopName ?? '';
|
|
|
+ $sjName = $shop->merchantName;
|
|
|
+ $currentName = $shopName == '首店' ? $sjName : $sjName . ' ' . $shopName;
|
|
|
+ $telephone = $shop->telephone ?? '';
|
|
|
+
|
|
|
+ $ext = $this->shopExt;
|
|
|
+ $wlLabelSn = $ext->wlLabelSn ?? '';
|
|
|
+ if (empty($wlLabelSn)) {
|
|
|
+ util::fail('请绑定物流标签机');
|
|
|
+ }
|
|
|
+ $p = new printUtil($wlLabelSn);
|
|
|
+ $p->times = 2;
|
|
|
+ $content = '<TEXT x="420" y="130" font="12" w="4" h="4" r="90">' . $shortName . '</TEXT>';
|
|
|
+ $content .= '<TEXT x="395" y="10" font="12" w="2" h="2" r="90">地址</TEXT>';
|
|
|
+ $content .= '<TEXT x="290" y="130" font="12" w="4" h="4" r="90">' . $shortMobile . '</TEXT>';
|
|
|
+ $content .= '<TEXT x="265" y="10" font="12" w="2" h="2" r="90">代码</TEXT>';
|
|
|
+ $content .= '<TEXT x="170" y="130" font="12" w="4" h="4" r="90">' . $shortRemark . '</TEXT>';
|
|
|
+ $content .= '<TEXT x="150" y="10" font="12" w="2" h="2" r="90">物流</TEXT>';
|
|
|
+ $content .= '<TEXT x="45" y="70" font="12" w="2" h="2" r="90">' . $currentName . ' ' . $telephone . '</TEXT>';
|
|
|
+ $p->printLabelMsg($content);
|
|
|
+ util::complete('打印成功');
|
|
|
+ }
|
|
|
+
|
|
|
}
|