Explorar o código

Merge branch 'master' into zhongqi-ghsCallExpress

shish hai 10 meses
pai
achega
53508e54b9
Modificáronse 45 ficheiros con 773 adicións e 219 borrados
  1. 2 0
      app-ghs/controllers/ConsoleController.php
  2. 1 1
      app-ghs/controllers/MainController.php
  3. 4 13
      app-ghs/controllers/OrderController.php
  4. 2 2
      app-ghs/controllers/ProductController.php
  5. 0 3
      app-ghs/controllers/PurchaseOrderController.php
  6. 27 0
      app-ghs/controllers/ScanPayController.php
  7. 27 2
      app-ghs/controllers/ShopController.php
  8. 3 3
      app-ghs/controllers/TestController.php
  9. 3 2
      app-hd/controllers/ApplyController.php
  10. 2 2
      app-hd/controllers/ConsoleController.php
  11. 3 3
      app-hd/controllers/MainController.php
  12. 10 3
      app-hd/controllers/OrderController.php
  13. 0 1
      app-hd/controllers/PicTextController.php
  14. 6 0
      app-hd/controllers/RechargeController.php
  15. 27 0
      app-hd/controllers/ScanPayController.php
  16. 10 3
      app-hd/controllers/ShopController.php
  17. 77 29
      app-mall/controllers/NoticeController.php
  18. 16 102
      app-mall/controllers/OrderController.php
  19. 0 1
      app-mall/controllers/ShopController.php
  20. 42 7
      app-mall/controllers/UserController.php
  21. 0 1
      biz-ghs/order/classes/OrderClass.php
  22. 18 0
      biz-ghs/order/classes/ScanPayClass.php
  23. 15 0
      biz-ghs/order/models/ScanPay.php
  24. 4 0
      biz-ghs/product/classes/ProductClass.php
  25. 43 0
      biz-hd/custom/classes/CustomClass.php
  26. 16 18
      biz-hd/goods/classes/GoodsCategoryClass.php
  27. 15 7
      biz-hd/order/classes/OrderClass.php
  28. 26 2
      biz-hd/order/classes/OrderGoodsClass.php
  29. 93 0
      biz-hd/order/classes/ScanPayClass.php
  30. 40 0
      biz-hd/order/classes/ScanPaySnClass.php
  31. 15 0
      biz-hd/order/models/ScanPay.php
  32. 15 0
      biz-hd/order/models/ScanPaySn.php
  33. 9 4
      biz-hd/order/services/OrderService.php
  34. 1 0
      biz-hd/recharge/classes/RechargeClass.php
  35. 38 0
      biz/shop/classes/ShopClass.php
  36. 42 0
      biz/shop/classes/ShopExtClass.php
  37. 2 2
      biz/stock/classes/GoodsStockRecordClass.php
  38. 45 0
      biz/wx/classes/WxMessageClass.php
  39. 2 2
      common/components/book.php
  40. 0 1
      common/components/bookJd.php
  41. 2 0
      common/components/dict.php
  42. 16 0
      common/components/orderSn.php
  43. 5 0
      common/components/payUtil.php
  44. 48 4
      common/components/printUtil.php
  45. 1 1
      common/components/qrCodeUtil.php

+ 2 - 0
app-ghs/controllers/ConsoleController.php

@@ -239,6 +239,8 @@ class ConsoleController extends BaseController
                 //["name" => "预订明细", "img" => "ghs/home/yggl.png", "url" => "/admin/book/itemCustom"],
                 //["name" => "新增预订", "img" => "ghs/home/yggl.png", "url" => "/admin/custom/selectCustom?style=1&book=1&getAll=1"],
                 ["name" => "拆散", "img" => "ghs/home/kcyjs.png", "url" => "/admin/part/list"],
+                ["name" => "收款码流水", "img" => "ghs/home/kcyjs.png", "url" => "/admin/order/scanPay"],
+                ["name" => "收款码", "img" => "ghs/home/shop.png", "url" => "/admin/cg/code"]
             ];
         }
         //用于审核,不展示全部完整的功能,批发的功能不展示出来,否则要申请B2B类目!!!!!!!!

+ 1 - 1
app-ghs/controllers/MainController.php

@@ -237,7 +237,7 @@ class MainController extends BaseController
         if (!empty($shop)) {
             $shopImg = imgUtil::groupImg($shop->avatar);
         }
-        $smallShopImg = $shopImg . "?x-oss-process=image/resize,m_fill,h_80,w_80";
+        $smallShopImg = $shopImg . "?x-oss-process=image/resize,m_fill,h_180,w_180";
 
         $deadline = $sj['deadline'] ?? '';
         $relation = isset($this->shopAdmin) && !empty($this->shopAdmin) ? $this->shopAdmin->attributes : [];

+ 4 - 13
app-ghs/controllers/OrderController.php

@@ -27,14 +27,11 @@ 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;
 use common\components\util;
 use biz\shop\classes\ShopAdminClass;
-use biz\notice\classes\NoticeClass;
-use biz\wx\classes\WxMessageClass;
 use biz\shop\classes\ShopClass;
 use common\components\lakala\Lakala;
 
@@ -1051,13 +1048,10 @@ class OrderController extends BaseController
         $shopAdminId = $this->shopAdminId;
         $shopAdminName = $shopAdmin->name ?? '';
 
-        //n秒内不允许重复提交,有多个地方要同步修改,关键词ghs_custom_create_order_redis
-        $createOrderCacheKey = 'ghs_custom_create_order_' . $customId . '_' . $shopAdminId;
-        $has = Yii::$app->redis->executeCommand('GET', [$createOrderCacheKey]);
-        if (!empty($has)) {
-            util::fail('已提交过,5秒后再试');
-        }
-        Yii::$app->redis->executeCommand('SETEX', [$createOrderCacheKey, 5, 'has']);
+        //解决开单提交订单时,别人修改价格,造成提交价格不是真实卖价问题!!
+        $dealPrice = $post['dealPrice'] ?? 0;
+        //解决重复提交问题
+        util::checkRepeatCommit($this->adminId . '_' . $dealPrice, 3);
 
         CustomClass::valid($custom, $this->shopId);
         if (!empty($custom['mainId']) && $custom['mainId'] == $custom['ownMainId']) {
@@ -1233,7 +1227,6 @@ class OrderController extends BaseController
             util::fail('请选择花材');
         }
 
-        $dealPrice = $post['dealPrice'] ?? 0;
         $ids = array_unique(array_filter(array_column($productList, 'productId')));
         $itemInfo = ProductClass::getByIds($ids, null, 'id');
         if (empty($itemInfo)) {
@@ -1267,8 +1260,6 @@ class OrderController extends BaseController
         //解决开单提交订单时,别人修改价格,造成提交价格不是真实卖价问题!!
         if ($dealPrice == 0) {
             if (!empty($diff)) {
-                //n秒内不允许重复提交,有多个地方要同步修改,关键词ghs_custom_create_order_redis
-                Yii::$app->redis->executeCommand('DEL', [$createOrderCacheKey]);
                 util::success(['diff' => $diff, 'respondType' => 'priceError']);
             }
         } else {

+ 2 - 2
app-ghs/controllers/ProductController.php

@@ -1071,7 +1071,7 @@ class ProductController extends BaseController
     public function actionUpdate()
     {
         $shopAdmin = $this->shopAdmin;
-        if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
+        if (!isset($shopAdmin->super) || $shopAdmin->super != 1) {
             util::fail('超管才能操作');
         }
 
@@ -1094,7 +1094,7 @@ class ProductController extends BaseController
         $post = Yii::$app->request->post();
         $discountPrice = $post['discountPrice'] ?? 0;
         if ($discountPrice > 0) {
-            if (isset($post['hjDiscountPrice']) == false || empty($post['hjDiscountPrice'])) {
+            if (empty($post['hjDiscountPrice'])) {
                 $addPrice = $post['addPrice'] ?? 0;
                 $hjAddPrice = $post['hjAddPrice'] ?? 0;
                 $skMore = $post['skMore'] ?? 0;

+ 0 - 3
app-ghs/controllers/PurchaseOrderController.php

@@ -4,7 +4,6 @@ namespace ghs\controllers;
 
 use biz\ghs\classes\GhsClass;
 use biz\sj\classes\SjClass;
-use biz\wx\classes\WxMessageClass;
 use bizGhs\book\classes\BookItemClass;
 use bizGhs\order\classes\PurchaseOrderClass;
 use bizGhs\order\classes\PurchaseOrderItemClass;
@@ -12,13 +11,11 @@ use bizGhs\product\classes\ProductClass;
 use bizGhs\shop\classes\ShopClass;
 use bizHd\purchase\classes\PurchaseClass;
 use common\components\dateUtil;
-use common\components\dict;
 use common\components\dirUtil;
 use common\components\noticeUtil;
 use common\components\printUtil;
 use common\components\stringUtil;
 use common\components\util;
-use biz\shop\classes\ShopExtClass;
 use Yii;
 
 class PurchaseOrderController extends BaseController

+ 27 - 0
app-ghs/controllers/ScanPayController.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace ghs\controllers;
+
+use bizGhs\order\classes\ScanPayClass;
+use common\components\util;
+use Yii;
+
+class ScanPayController extends BaseController
+{
+
+    public $guestAccess = [];
+
+    public function actionList()
+    {
+        $get = Yii::$app->request->get();
+        $status = $get['status'] ?? 0;
+        $where = [];
+        $where['mainId'] = $this->mainId;
+        if (!empty($status)) {
+            $where['status'] = $status;
+        }
+        $list = ScanPayClass::getPayList($where);
+        util::success($list);
+    }
+
+}

+ 27 - 2
app-ghs/controllers/ShopController.php

@@ -30,6 +30,23 @@ class ShopController extends BaseController
 
     public $guestAccess = ['all'];
 
+    //小程序端使用,下载收款码 ssh 20250821
+    public function actionMiniGatheringCode()
+    {
+        $shop = $this->shop;
+        $lsShopId = $shop->lsShopId ?? 0;
+        if (empty($lsShopId)) {
+            util::fail('没有零售店ID');
+        }
+        $lsShop = ShopClass::getById($lsShopId, true);
+        if (empty($lsShop)) {
+            util::fail('没有零售店呢');
+        }
+        $sjId = $lsShop->sjId ?? 0;
+        $imgUrl = \biz\shop\classes\ShopClass::generateGatheringCode($sjId, $lsShopId);
+        util::success(['imgUrl' => $imgUrl]);
+    }
+
     //修改客户微信二维码 ssh 20240714
     public function actionChangeWx()
     {
@@ -177,10 +194,10 @@ class ShopController extends BaseController
 
         //同步更新同城配送微信门店
         // 校验有无经纬度数据,没有不更新(说明地图定位功能不可用了)
-        if($post['lat'] != '' && $post['long'] != '') {
+        if ($post['lat'] != '' && $post['long'] != '') {
             $shopExt = \bizGhs\shop\classes\MainClass::getById($this->mainId, false, false, 'id, wxStoreId');
             if ($shopExt['wxStoreId'] == '') {
-                Yii::error(__CLASS__ . __METHOD__ .' - 未创建门店,请先创建');
+                Yii::error(__CLASS__ . __METHOD__ . ' - 未创建门店,请先创建');
                 util::complete();
             }
 
@@ -426,6 +443,14 @@ class ShopController extends BaseController
             if ($mainId == 1459 && $adminId == 2812) {
                 util::fail('收银专用账号,不允许切换门店');
             }
+            //淘花里中山店
+            if ($mainId == 16948 && $adminId == 17908) {
+                util::fail('收银专用账号,不允许切换门店');
+            }
+            //淘花里小榄店
+            if ($mainId == 72057 && $adminId == 69792) {
+                util::fail('收银专用账号,不允许切换门店');
+            }
         }
 
         $shopAdmin = $this->shopAdmin;

+ 3 - 3
app-ghs/controllers/TestController.php

@@ -398,7 +398,7 @@ class TestController extends BaseController
             //['name' => '济南伟伟鲜花批发', 'merchantNo' => '8224510599200EL', 'wx' => [789073494, 789074603], 'zfb' => '2088670850497224'],
             //['name' => '赣州紫荆鲜花批发', 'merchantNo' => '82242805992004J', 'wx' => [790052021, 790051859], 'zfb' => '2088670969143838'],
             //['name' => '莆田鲜花闪送', 'merchantNo' => '82239405992005W', 'wx' => [808858266, 808858114], 'zfb' => '2088970298325670'],
-            ['name' =>'小榄淘花里', 'merchantNo' => '8226030599200A2', 'wx' => [809357489, 809358311], 'zfb' => '2088970343842282'],
+            ['name' => '小榄淘花里', 'merchantNo' => '8226030599200A2', 'wx' => [809357489, 809358311], 'zfb' => '2088970343842282'],
             ['name' => '深圳鼎盛皇室花卉', 'merchantNo' => '8225840599201MF', 'wx' => [807078304, 807076486], 'zfb' => '2088970117746334'],
             //['name' => '东莞惠雅鲜花(莞城店)', 'merchantNo' => '8226020599200GJ', 'wx' => [796953190, 796976959], 'zfb' => '2088770940104912'],
             //['name' => '东莞惠雅鲜花(南城店)', 'merchantNo' => '8226020599200JK', 'wx' => [802315656, 802315755], 'zfb' => '2088870583889365'],
@@ -758,7 +758,7 @@ class TestController extends BaseController
     //零售订单查询 ssh 20231031
     public function actionLsTradeQuery()
     {
-        $shopId = 13626;
+        $shopId = 726;
         $shop = ShopClass::getById($shopId, true);
         if (empty($shop)) {
             util::stop('没有找到门店21');
@@ -775,7 +775,7 @@ class TestController extends BaseController
         ];
         $laResource = new Lakala($params);
         $queryParams = [
-            'orderSn' => 'KD26628409',
+            'orderSn' => 'KD26635896',
             //'tradeNo' => '66222010853306',
         ];
         $response = $laResource->query($queryParams, 0);

+ 3 - 2
app-hd/controllers/ApplyController.php

@@ -130,8 +130,9 @@ class ApplyController extends BaseController
 
             //前期限制只有批发店邀请了才能注册
             $ghsShopAdminId = $post['ghsShopAdminId'] ?? 0;
-            if (empty($ghsShopAdminId)) {
-                //util::fail('批发店推荐才能注册');
+            $hdShopAdminId = $post['hdShopAdminId'] ?? 0;
+            if (empty($ghsShopAdminId) && empty($hdShopAdminId)) {
+                util::fail('批发店推荐才能注册,编号:' . $ghsShopAdminId . ' ' . $hdShopAdminId);
             }
 
             $shopName = $post['name'] ?? '';

+ 2 - 2
app-hd/controllers/ConsoleController.php

@@ -38,8 +38,8 @@ class ConsoleController extends BaseController
         $totalVisit = $main->totalVisit ?? 0;
         $totalOrder = $main->finishOrder ?? 0;
         $overview = [
-            ['name' => "库存数", "url" => '/admin/stat/stock', 'value' => $totalItemNum, 'type' => 1],
-            ['name' => "库存值", "url" => '/admin/stat/stock', 'value' => $totalCost, 'type' => 1],
+            ['name' => "花材数", "url" => '/admin/stat/stock', 'value' => $totalItemNum, 'type' => 1],
+            ['name' => "花材值", "url" => '/admin/stat/stock', 'value' => $totalCost, 'type' => 1],
             ['name' => "花束", "url" => '/admin/custom/showTotalBalance', 'value' => 0, 'type' => 1],
             ['name' => "总客户", "url" => '/admin/stat/stock', 'value' => 10, 'type' => 1],
             ['name' => "总订单", "url" => '/admin/home/member', 'value' => $totalCustom, 'type' => 4],

+ 3 - 3
app-hd/controllers/MainController.php

@@ -41,9 +41,9 @@ class MainController extends BaseController
             }
         }
 
-        $goodsShortUrl = 'wx_mini_goods_short_url';
-        $itemShortUrl = 'wx_mini_item_short_url';
-        $imageShortUrl = 'wx_mini_image_short_url';
+        $goodsShortUrl = 'wx_mini_goods_short_url' . $shopId;
+        $itemShortUrl = 'wx_mini_item_short_url' . $shopId;
+        $imageShortUrl = 'wx_mini_image_short_url' . $shopId;
 
         $goodsUrl = Yii::$app->redis->executeCommand('GET', [$goodsShortUrl]);
         $imgUrl = Yii::$app->redis->executeCommand('GET', [$itemShortUrl]);

+ 10 - 3
app-hd/controllers/OrderController.php

@@ -601,6 +601,12 @@ class OrderController extends BaseController
             if ($hasPay != 1) {
                 util::fail('售后付款单只能走线下转账');
             }
+            $historyDate = $post['historyDate'] ?? '';
+            if (!empty($historyDate)) {
+                if ($historyDate != date("Y-m-d")) {
+                    util::fail('售后付款单不能修改账单日期,只能今天');
+                }
+            }
         } else {
             //如果不是售后付款单,并且选的不是余额支付,余额又够付当前订单,则自动切到余额支付
             $balance = $custom->balance ?? 0;
@@ -654,9 +660,6 @@ class OrderController extends BaseController
         try {
             $post['product'] = $productList;
 
-            //解决重复提交
-            util::checkRepeatCommit($this->adminId, 2);
-
             $reduceStock = $post['reduceStock'] ?? 0;
             if ($reduceStock == 1) {
                 //如果扣除库,则走另外一条路
@@ -667,6 +670,10 @@ class OrderController extends BaseController
 
             //解决开单提交订单时,别人修改价格,造成提交价格不是真实卖价问题!!
             $dealPrice = $post['dealPrice'] ?? 0;
+
+            //解决重复提交
+            util::checkRepeatCommit($this->adminId . '_' . $dealPrice, 3);
+
             if ($dealPrice == 0) {
                 $productIds = [];
                 $hsIds = [];

+ 0 - 1
app-hd/controllers/PicTextController.php

@@ -2,7 +2,6 @@
 namespace hd\controllers;
 
 use bizHd\goods\classes\CategoryClass;
-use bizHd\goods\models\Pic;
 use bizHd\shop\classes\ShopExtClass;
 use Yii;
 use bizHd\pictext\classes\PicTextClass;

+ 6 - 0
app-hd/controllers/RechargeController.php

@@ -9,6 +9,7 @@ use biz\shop\classes\ShopClass;
 use biz\sj\classes\SjClass;
 use bizGhs\custom\classes\CustomClass;
 use bizHd\custom\classes\HdClass;
+use bizHd\member\classes\MemberWealClass;
 use bizHd\order\classes\OrderClass;
 use bizHd\order\classes\SettleClass;
 use bizHd\wx\classes\WxOpenClass;
@@ -55,6 +56,11 @@ class RechargeController extends BaseController
     //获取扫码充值的小程序码 ssh 20250307
     public function actionGetRechargeCode()
     {
+
+        $shopId = $this->shopId;
+        $recharge = MemberWealClass::getAllByCondition(['shopId' => $shopId], 'recharge asc', '*', null, true);
+        //这里取前面三个放在海报里,对应表名是 xhMemberRecharge 不是 MemberWeal
+
         $merchant = WxOpenClass::getMallWxInfo();
         $page = 'pages/member/recharge';
         $ptStyle = dict::getDict('ptStyle', 'mall');

+ 27 - 0
app-hd/controllers/ScanPayController.php

@@ -0,0 +1,27 @@
+<?php
+
+namespace hd\controllers;
+
+use bizHd\order\classes\ScanPayClass;
+use common\components\util;
+use Yii;
+
+class ScanPayController extends BaseController
+{
+
+    public $guestAccess = [];
+
+    public function actionList()
+    {
+        $get = Yii::$app->request->get();
+        $status = $get['status'] ?? 0;
+        $where = [];
+        $where['mainId'] = $this->mainId;
+        if (!empty($status)) {
+            $where['status'] = $status;
+        }
+        $list = ScanPayClass::getPayList($where);
+        util::success($list);
+    }
+
+}

+ 10 - 3
app-hd/controllers/ShopController.php

@@ -119,10 +119,10 @@ class ShopController extends BaseController
 
         //同步更新同城配送微信门店
         // 校验有无经纬度数据,没有不更新(说明地图定位功能不可用了)
-        if($data['lat'] != '' && $data['long'] != '') {
+        if ($data['lat'] != '' && $data['long'] != '') {
             $shopExt = MainClass::getById($this->mainId, false, false, 'id, wxStoreId');
             if ($shopExt['wxStoreId'] == '') {
-                Yii::error(__CLASS__ . __METHOD__ .' - 未创建门店,请先创建');
+                Yii::error(__CLASS__ . __METHOD__ . ' - 未创建门店,请先创建');
                 util::complete();
             }
 
@@ -216,6 +216,14 @@ class ShopController extends BaseController
             if ($mainId == 1459 && $adminId == 2812) {
                 util::fail('收银专用账号,不允许切换门店');
             }
+            //淘花里中山店
+            if ($mainId == 16948 && $adminId == 17908) {
+                util::fail('收银专用账号,不允许切换门店');
+            }
+            //淘花里小榄店
+            if ($mainId == 72057 && $adminId == 69792) {
+                util::fail('收银专用账号,不允许切换门店');
+            }
         }
 
         $shopAdmin = $this->shopAdmin;
@@ -261,7 +269,6 @@ class ShopController extends BaseController
     {
         $shop = $this->shop;
         $shopId = $shop->id;
-        ShopClass::valid($shop->attributes, $this->sjId);
         $imgUrl = ShopClass::generateGatheringCode($this->sjId, $shopId);
         util::success(['imgUrl' => $imgUrl]);
     }

+ 77 - 29
app-mall/controllers/NoticeController.php

@@ -5,6 +5,8 @@ namespace mall\controllers;
 use biz\shop\classes\ShopClass;
 use biz\wx\classes\WxMessageClass;
 use bizHd\order\classes\OrderClass;
+use bizHd\order\classes\ScanPayClass;
+use bizHd\recharge\classes\RechargeClass;
 use bizHd\refund\classes\HdRefundClass;
 use bizHd\wx\classes\WxOpenClass;
 use common\components\noticeUtil;
@@ -153,8 +155,8 @@ class NoticeController extends PublicController
 
             echo "SUCCESS";
 
-            //解决重复通知,重要
             if ($capitalType == dict::getDict('capitalType', 'xhOrder', 'id')) {
+                //解决重复通知,重要
                 $cacheKey = 'mall_order_pay_' . $orderSn;
                 $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
                 if (empty($has)) {
@@ -162,24 +164,46 @@ class NoticeController extends PublicController
 
                     //打印小票和语音播报
                     $order = OrderClass::getByCondition(['orderSn' => $orderSn], true);
-                    ShopExtClass::hdGatheringReport($order);
                     OrderClass::onlinePrint($order);
 
                     $shopId = $order->shopId ?? 0;
                     $shop = ShopClass::getById($shopId, true);
-                    if (in_array($order->fromType, [dict::getDict("fromType", "shop"), dict::getDict("fromType", "friend")])) {
-                        //您有新的收入提醒
-                        WxMessageClass::gatheringIncomeInform($shop, $order);
-                    }
-                    if ($order->fromType == dict::getDict("fromType", "mall")) {
-                        //来自商城的新订单微信通知
-                        WxMessageClass::hdNewOrderInform($shop, $order);
-                    }
+                    //来自商城的新订单微信通知
+                    WxMessageClass::hdNewOrderInform($shop, $order);
 
                     $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
                     ShopExtClass::newWorkRemind($shopExt, $order);
                 }
             }
+
+            if ($capitalType == dict::getDict('capitalType', 'scanPay', 'id')) {
+                //解决重复通知,重要
+                $myKey = 'mall_order_scan_pay_' . $orderSn;
+                $has = Yii::$app->redis->executeCommand('GET', [$myKey]);
+                if (empty($has)) {
+                    Yii::$app->redis->executeCommand('SETEX', [$myKey, 864000, 'has']);
+                    $scan = ScanPayClass::getByCondition(['orderSn' => $orderSn], true);
+
+                    //微信通知
+                    $shopId = $scan->shopId ?? 0;
+                    $shop = ShopClass::getById($shopId, true);
+                    WxMessageClass::hdScanPayInform($shop, $scan);
+
+                    ShopExtClass::hdScanPayReport($scan);
+                }
+            }
+
+            if ($capitalType == dict::getDict('capitalType', 'xhRecharge', 'id')) {
+                //解决重复通知,重要
+                $myKey = 'mall_rehcarge_' . $orderSn;
+                $has = Yii::$app->redis->executeCommand('GET', [$myKey]);
+                if (empty($has)) {
+                    Yii::$app->redis->executeCommand('SETEX', [$myKey, 864000, 'has']);
+                    $recharge = RechargeClass::getByCondition(['orderSn' => $orderSn], true);
+                    ShopExtClass::skRechargeReport($recharge);
+                }
+            }
+
         } catch (\Exception $e) {
             $transaction->rollBack();
             Yii::error("失败原因:" . $e->getMessage());
@@ -208,8 +232,8 @@ class NoticeController extends PublicController
         //接收流水类型、代金劵
         parse_str($attach);
         //流水类型
-        $capitalType = isset($capitalType) ? $capitalType : null;
-        if (isset($capitalType) == false) {
+        $capitalType = $capitalType ?? null;
+        if (!isset($capitalType)) {
             Yii::warning('capitalType empty,orderSn:' . $orderSn);
             util::end();
         }
@@ -425,7 +449,15 @@ class NoticeController extends PublicController
             util::end();
         }
 
-        $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
+        //接收流水类型、代金劵等
+        $remarkString = $orderTradeInfo['trade_remark'] ?? '';
+        $remarkData = json_decode($remarkString, true);
+        $capitalType = $remarkData['capitalType'] ?? null;
+        if (!isset($capitalType)) {
+            $msg = '支付回调失败了,没有找到capitalType,orderSn:' . $orderSn . ' remark:' . $remarkString;
+            noticeUtil::push($msg, '15280215347');
+            util::end();
+        }
 
         $connection = Yii::$app->db;
         $transaction = $connection->beginTransaction();
@@ -447,23 +479,39 @@ class NoticeController extends PublicController
                 payUtil::thirdPay($payWayType, $capitalType, $orderSn, $totalFee, $attach, $transactionId);
                 $transaction->commit();
 
-                //打印小票和语音播报
-                $order = OrderClass::getByCondition(['orderSn' => $orderSn], true);
-                if (!empty($order)) {
-                    $order->thirdLogNo = $thirdLogNo;
-                    $order->save();
-                    ShopExtClass::hdGatheringReport($order);
-                    OrderClass::onlinePrint($order);
-
-                    $shopId = $order->shopId ?? 0;
-                    $shop = ShopClass::getById($shopId, true);
-                    if (in_array($order->fromType, [dict::getDict("fromType", "shop"), dict::getDict("fromType", "friend")])) {
-                        //您有新的收入提醒
-                        WxMessageClass::gatheringIncomeInform($shop, $order);
+                if ($capitalType == dict::getDict('capitalType', 'xhOrder', 'id')) {
+                    //避免重复
+                    $cacheKey = 'mall_order_pay_' . $orderSn;
+                    $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
+                    if (empty($has)) {
+                        Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 864000, 'has']);
+                        //打印小票和语音播报
+                        $order = OrderClass::getByCondition(['orderSn' => $orderSn], true);
+                        if (!empty($order)) {
+                            $order->thirdLogNo = $thirdLogNo;
+                            $order->save();
+                            OrderClass::onlinePrint($order);
+                            $shopId = $order->shopId ?? 0;
+                            $shop = ShopClass::getById($shopId, true);
+                            //来自商城的新订单微信通知
+                            WxMessageClass::hdNewOrderInform($shop, $order);
+                        }
                     }
-                    if ($order->fromType == dict::getDict("fromType", "mall")) {
-                        //来自商城的新订单微信通知
-                        WxMessageClass::hdNewOrderInform($shop, $order);
+                }
+                if ($capitalType == dict::getDict('capitalType', 'scanPay', 'id')) {
+                    //避免重复
+                    $myKey = 'mall_order_scan_pay_' . $orderSn;
+                    $has = Yii::$app->redis->executeCommand('GET', [$myKey]);
+                    if (empty($has)) {
+                        Yii::$app->redis->executeCommand('SETEX', [$myKey, 864000, 'has']);
+                        $scan = ScanPayClass::getByCondition(['orderSn' => $orderSn], true);
+
+                        //微信通知
+                        $shopId = $scan->shopId ?? 0;
+                        $shop = ShopClass::getById($shopId, true);
+                        WxMessageClass::hdScanPayInform($shop, $scan);
+
+                        ShopExtClass::hdScanPayReport($scan);
                     }
                 }
             }

+ 16 - 102
app-mall/controllers/OrderController.php

@@ -6,6 +6,7 @@ use biz\product\classes\ProductClass;
 use biz\shop\classes\ShopClass;
 use biz\wx\classes\WxMessageClass;
 use bizHd\custom\classes\HdClass;
+use bizHd\order\classes\ScanPayClass;
 use bizHd\wx\classes\WxOpenClass;
 use bizMall\custom\classes\CustomClass;
 use bizMall\goods\classes\GoodsClass;
@@ -803,26 +804,12 @@ class OrderController extends BaseController
         if (empty($shop)) {
             util::fail('没有门店信息');
         }
-        $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
-        $gatheringItem = !empty($ext) ? $ext->gatheringItem : 0;
-        if (empty($gatheringItem)) {
-            util::fail('请设置付款用的商品');
-        }
-        $gatheringItemInfo = ItemClass::getById($gatheringItem, true);
-        if (empty($gatheringItemInfo)) {
-            util::fail('付款用的商品没有设置');
-        }
-        $ptItemId = $gatheringItemInfo->itemId ?? 0;
-        $classId = $gatheringItemInfo->classId ?? 0;
-        //收款码是否算收入由ext gatherRepeat决定
-        $post['repeat'] = $ext->gatherRepeat ?? 0;
         $customId = $this->customId;
         $custom = $this->custom;
         $hdId = $this->hdId;
         $hd = $this->hd;
         if (empty($customId) || empty($hdId)) {
             //考虑没有登录时的付款
-            $shop = $this->shop;
             $defaultCustomId = $shop->defaultCustomId ?? 0;
             if (empty($defaultCustomId)) {
                 util::fail('请设置快捷开单的客户');
@@ -830,7 +817,7 @@ class OrderController extends BaseController
             $customId = $defaultCustomId;
             $custom = CustomClass::getById($defaultCustomId, true);
             if (empty($custom)) {
-                util::fail('请设置快捷客户');
+                util::fail('无效的快捷客户');
             }
             $hdId = $custom->hdId;
             $hd = \bizMall\hd\classes\HdClass::getById($hdId, true);
@@ -844,89 +831,28 @@ class OrderController extends BaseController
         $customPy = $custom->py ?? '';
         $post['customName'] = $customName;
         $post['customNamePy'] = $customPy;
-        $post['gatheringItem'] = $gatheringItem;
         $post['shopId'] = $shopId;
         $post['mainId'] = $this->mainId;
-        $post['sjId'] = $this->sjId;
-        $post['store'] = 0;
         $post['customId'] = $customId;
-        $user = $this->user->attributes ?? [];
-        $post['bookName'] = $user['userName'] ?? '';
-        $bookMobile = !empty($post['bookMobile']) && stringUtil::isMobile($post['bookMobile']) ? $post['bookMobile'] : '';
-        $bookMobile = empty($bookMobile) && !empty($user['mobile']) ? $user['mobile'] : $bookMobile;
-        $post['bookMobile'] = $bookMobile;
+
         $prePrice = round($post['prePrice'], 2);
-        $couponId = $post['couponId'] ?? 0;
-        $discountData = OrderService::getDiscountPrice(['price' => $prePrice, 'sourceType' => 0, 'couponId' => $couponId, 'userId' => $this->userId]);
-        $actPrice = $discountData['price'];
-        $post['discountType'] = $discountData['discountType'];
-        $post['discountAmount'] = $discountData['discountAmount'];
-        $post['orderPrice'] = $actPrice;
+        $actPrice = $prePrice;
+        if ($actPrice <= 0) {
+            util::fail('请填写付款金额');
+        }
         $post['actPrice'] = $actPrice;
-        $post['realPrice'] = $actPrice;
-        $post['mainPay'] = $actPrice;
-        $post['modifyPrice'] = $actPrice;
         $post['userId'] = $this->userId;
-        $post['needPrint'] = dict::getDict('needPrint', 'noNeed');
         $now = time();
         $expireTime = $now + 300;//订单5分钟后过期
         $post['createTime'] = date("Y-m-d H:i:s", $now);
-        $post['deadline'] = $expireTime;
-        if ($actPrice <= 0) {
-            util::fail('请填写付款金额');
-        }
-
-        $post['goodsNum'] = 1;
-        $product = [[
-            'productId' => $gatheringItem,
-            'bigNum' => 1,
-            'smallNum' => '',
-            'num' => 1,
-            'unitType' => 0,
-            'property' => 1,
-            'unitPrice' => $actPrice,
-            'itemId' => $ptItemId,
-            'classId' => $classId
-        ]];
-        $post['product'] = $product;
-
-        $post['reachDate'] = !empty($post['reachDate']) ? $post['reachDate'] : '00-00-00';
-        $post['onlinePay'] = dict::getDict('onlinePay', 'yes');
-
-        //前端未修改时这边做兼容
-        if (!empty($post['receiveAddress'])) {
-            $post['address'] = $post['receiveAddress'];
-            if (!empty($post['receiveProvince'])) {
-                $post['province'] = $post['receiveProvince'];
-            }
-            if (!empty($post['receiveCity'])) {
-                $post['city'] = $post['receiveCity'];
-            }
-            if (!empty($post['receiveFloor'])) {
-                $post['floor'] = $post['receiveFloor'];
-            }
-            if (!empty($post['latitude'])) {
-                $post['lat'] = $post['latitude'];
-            }
-            if (!empty($post['longitude'])) {
-                $post['long'] = $post['longitude'];
-            }
-            $city = $post['receiveCity'] ?? '';
-            $address = $post['receiveAddress'];
-            $floor = $post['receiveFloor'] ?? '';
-            $post['fullAddress'] = $city . $address . $floor;
-        }
-        $hasPay = 0;
-        $post['sendType'] = 1;
-        $post['orderType'] = 2;//花材订单
-        $post['dealPrice'] = 1;
-        $post['fromType'] = 1;
-        $order = \bizHd\order\services\OrderService::createHdOrder($post, $custom, $hasPay);
+        $post['deadline'] = date("Y-m-d H:i:s", $expireTime);
+        $order = ScanPayClass::addOrder($post);
         $orderId = $order->id ?? 0;
         $orderSn = $order->orderSn ?? '';
+        $capitalType = dict::getDict('capitalType', 'scanPay', 'id');
         if ($payWay == 0) {
             //微信
-            $name = '购买商品';
+            $name = '购买鲜花,扫码付款';
             $totalFee = $actPrice;
             $user = UserService::getById($this->userId);
             //小程序使用miniOpenId
@@ -937,10 +863,8 @@ class OrderController extends BaseController
             if (empty($openId)) {
                 util::fail('没有微信信息');
             }
-            $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
 
             $sjExtend = WxOpenClass::getMallWxInfo();
-            $shop = $this->shop;
             $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
             $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
             $params = [
@@ -961,7 +885,7 @@ class OrderController extends BaseController
                 'wxAppId' => $sjExtend['miniAppId'],
                 'openId' => $openId,
                 'subject' => $name,
-                'couponId' => $couponId,
+                'couponId' => 0,
             ];
             $response = $laResource->driveWxPay($wxParams);
             if (!isset($response['code']) || $response['code'] != 'BBS00000') {
@@ -992,9 +916,7 @@ class OrderController extends BaseController
         } elseif ($payWay == 1) {
             //支付宝
             $totalFee = $actPrice;
-            $subject = '购买花材';
-            $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
-            $shop = $this->shop;
+            $subject = '购买鲜花,扫码付款';
             $merchantPrivateKeyPath = Yii::getAlias("@vendor/lakala") . '/production/api_private_key.pem';
             $lklCertificatePath = Yii::getAlias("@vendor/lakala") . '/production/lkl-apigw-v1.cer';
             $params = [
@@ -1018,22 +940,14 @@ class OrderController extends BaseController
             if (!isset($response['code']) || $response['code'] != '000000') {
                 util::fail('支付失败了');
             }
-            $url = $response['resp_data']['counter_url'] ? $response['resp_data']['counter_url'] : '';
+            $url = $response['resp_data']['counter_url'] ?? '';
             if (empty($url)) {
                 util::fail('支付失败');
             }
             util::success(['url' => $url]);
         } elseif ($payWay == 2) {
-            util::fail('无效的支付方式');
-            //余额支付,验证支付密码是否正确
-            $payPassword = isset($post['payPassword']) ? $post['payPassword'] : 0;
-            $user = UserService::getUserInfo($this->userId);
-            UserService::validPayPassword($payPassword, $user);
-            $capitalType = dict::getDict('capitalType', 'xhOrder', 'id');
-            $callbackParams = [];
-            $respond = xhPayToolService::balancePay($callbackParams, $orderSn, $actPrice, $capitalType, $couponId);
-            $balance = isset($respond['balance']) ? $respond['balance'] : 0;
-            util::success(['discountAmount' => $discountData['discountAmount'], 'discountType' => $discountData['discountType'], 'orderSn' => $orderSn, 'orderId' => $orderId, 'balance' => $balance]);
+            //余额支付
+            util::fail('暂不支持');
         } else {
             util::fail('无效的支付方式');
         }

+ 0 - 1
app-mall/controllers/ShopController.php

@@ -38,7 +38,6 @@ class ShopController extends BaseController
         $custom = [];
         if (!empty($user)) {
             if (empty($hdId)) {
-                $shop = $this->shop;
                 $respond = CustomClass::buildRelation($shop, $user);
                 $hd = $respond['hd'];
                 $custom = $respond['custom'];

+ 42 - 7
app-mall/controllers/UserController.php

@@ -11,6 +11,7 @@ use bizMall\user\services\UserService;
 use common\components\dict;
 use common\components\imgUtil;
 use common\components\jwt;
+use common\components\noticeUtil;
 use common\components\stringUtil;
 use Yii;
 use common\components\util;
@@ -67,27 +68,27 @@ class UserController extends BaseController
             util::fail('农历没有31号');
         }
         $user = $this->user;
+        $userId = $this->userId;
         if ($user->birthdaySet == 1) {
             util::fail('你已经设置过了');
         }
-
-        $calendar = new Calendar();
         if ($lunar == 1) {
             try {
+                //农历转阳历,有多处使用,需要同步修改,关键词change_my_birthday
+                $calendar = new Calendar();
                 $result = $calendar->lunar(date("Y"), $birthdayMonth, $birthdayDate);
+                $month = $result['gregorian_month'] ?? 1;
+                $date = $result['gregorian_day'] ?? 1;
+                $birthday = date("Y") . '-' . $month . '-' . $date;
             } catch (\InvalidArgumentException $e) {
                 $msg = $e->getMessage();
+                $birthday = '0000-00-00 00:00:00';
                 util::fail($msg);
             }
-            $month = $result['gregorian_month'] ?? 1;
-            $date = $result['gregorian_day'] ?? 1;
-            $birthday = date("Y") . '-' . $month . '-' . $date;
         } else {
             $birthday = date("Y") . '-' . $birthdayMonth . '-' . $birthdayDate;
         }
         $birthdayTime = strtotime($birthday);
-
-
         $user->lunar = $lunar;
         $user->birthdayDate = $birthdayDate;
         $user->birthdayMonth = $birthdayMonth;
@@ -115,6 +116,39 @@ class UserController extends BaseController
     {
         $user = $this->user;
         if (!empty($user)) {
+            $birthday = $user->birthday ?? '';
+            //如果当年的生日时间没有更新,则需要给更新
+            $year = date("Y", strtotime($birthday));
+            $thisYear = date("Y");
+            if ($year != $thisYear) {
+                $lunar = $user->lunar ?? 0;
+                $userId = $this->userId;
+                $birthdayMonth = $user->birthdayMonth ?? 0;
+                $birthdayDate = $user->birthdayDate ?? 0;
+                if ($lunar == 1) {
+                    try {
+                        //农历转阳历,有多处使用,需要同步修改,关键词change_my_birthday
+                        $calendar = new Calendar();
+                        $result = $calendar->lunar(date("Y"), $birthdayMonth, $birthdayDate);
+                        $month = $result['gregorian_month'] ?? 1;
+                        $date = $result['gregorian_day'] ?? 1;
+                        $birthday = date("Y") . '-' . $month . '-' . $date;
+                        $user->birthday = $birthday;
+                        $user->save();
+                        CustomClass::updateByCondition(['userId' => $userId], ['birthday' => $birthday]);
+                    } catch (\InvalidArgumentException $e) {
+                        $msg = $e->getMessage();
+                        noticeUtil::push("更新生日出错了呢,userId:" . $userId . ' ' . $msg, '15280215347');
+                        $birthday = '0000-00-00 00:00:00';
+                    }
+                } else {
+                    $birthday = date("Y") . '-' . $birthdayMonth . '-' . $birthdayDate;
+                    $user->birthday = $birthday;
+                    $user->save();
+                    CustomClass::updateByCondition(['userId' => $userId], ['birthday' => $birthday]);
+                }
+            }
+
             // 将 $user 转换为数组,然后添加 hasMap 属性(字典中的 hasMap)
             $user = $user->toArray();
             $shortAvatar = $user['avatar'] ?? '';
@@ -124,6 +158,7 @@ class UserController extends BaseController
             $user['smallAvatar'] = $smallAvatar;
             $user['shortAvatar'] = $shortAvatar;
         }
+
         $hasMap = dict::getDict('hasMap');
         $user['hasMap'] = $hasMap;
         util::success(['info' => $user]);

+ 0 - 1
biz-ghs/order/classes/OrderClass.php

@@ -1750,7 +1750,6 @@ class OrderClass extends BaseClass
     //云打印 ssh 20210709
     public static function onlinePrint($orderInfo, $showPrice = 1)
     {
-
         if (getenv('YII_ENV') == 'production') {
             //淮北花语集、丽子鲜花,客户线上下单不显示价格,门店开单显示价格
             if ($orderInfo->shopId == 1527 || $orderInfo->mainId == 52291) {

+ 18 - 0
biz-ghs/order/classes/ScanPayClass.php

@@ -0,0 +1,18 @@
+<?php
+
+namespace bizGhs\order\classes;
+
+use Yii;
+use bizGhs\base\classes\BaseClass;
+
+class ScanPayClass extends BaseClass
+{
+
+    public static $baseFile = '\bizGhs\order\models\ScanPay';
+
+    public static function getPayList($where)
+    {
+        return self::getList('*', $where, 'addTime DESC,id DESC');
+    }
+
+}

+ 15 - 0
biz-ghs/order/models/ScanPay.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace bizGhs\order\models;
+
+use bizGhs\base\models\Base;
+
+class ScanPay extends Base
+{
+
+    public static function tableName()
+    {
+        return 'xhScanPay';
+    }
+
+}

+ 4 - 0
biz-ghs/product/classes/ProductClass.php

@@ -1932,6 +1932,10 @@ class ProductClass extends BaseClass
                     unset($params['skMore']);
                     unset($params['hjAddPrice']);
                     unset($params['cost']);
+                    //特价的金额也不能同步,淘花里
+                    unset($params['hjDiscountPrice']);
+                    unset($params['discountPrice']);
+                    unset($params['skDiscountPrice']);
                     self::updateById($chainProduct->id, $params);
                     continue;
                 }

+ 43 - 0
biz-hd/custom/classes/CustomClass.php

@@ -14,8 +14,10 @@ use bizHd\order\classes\SettleClass;
 use bizHd\shop\classes\ShopClass;
 use common\components\dict;
 use common\components\imgUtil;
+use common\components\noticeUtil;
 use common\components\stringUtil;
 use common\components\util;
+use Overtrue\ChineseCalendar\Calendar;
 use Yii;
 use bizHd\base\classes\BaseClass;
 
@@ -671,6 +673,47 @@ class CustomClass extends BaseClass
                 'visitTime' => $visitTime,
                 'salt' => $salt,
             ];
+            $birthdaySet = $user->birthdaySet ?? 0;
+            if ($birthdaySet == 1) {
+                //如果用户自己设置过了生日,则生日给传过去
+                $lunar = $user->lunar ?? 0;
+                $birthday = $user->birthday ?? '';
+                $birthdayTime = $user->birthdayTime ?? 0;
+                $birthdayMonth = $user->birthdayMonth ?? 0;
+                $birthdayDate = $user->birthdayDate ?? 0;
+                //如果当年的生日时间没有更新,则需要给更新
+                $year = date("Y", strtotime($birthday));
+                $thisYear = date("Y");
+                if ($year != $thisYear) {
+                    if ($lunar == 1) {
+                        try {
+                            //农历转阳历,有多处使用,需要同步修改,关键词change_my_birthday
+                            $calendar = new Calendar();
+                            $result = $calendar->lunar(date("Y"), $birthdayMonth, $birthdayDate);
+                            $month = $result['gregorian_month'] ?? 1;
+                            $date = $result['gregorian_day'] ?? 1;
+                            $birthday = date("Y") . '-' . $month . '-' . $date;
+                            $user->birthday = $birthday;
+                            $user->save();
+                            CustomClass::updateByCondition(['userId' => $userId], ['birthday' => $birthday]);
+                        } catch (\InvalidArgumentException $e) {
+                            $msg = $e->getMessage();
+                            noticeUtil::push("更新生日出错了,userId:" . $userId . ' ' . $msg, '15280215347');
+                            $birthday = '0000-00-00 00:00:00';
+                        }
+                    } else {
+                        $birthday = date("Y") . '-' . $birthdayMonth . '-' . $birthdayDate;
+                        $user->birthday = $birthday;
+                        $user->save();
+                        CustomClass::updateByCondition(['userId' => $userId], ['birthday' => $birthday]);
+                    }
+                }
+                $data['birthday'] = $birthday;
+                $data['birthdayTime'] = $birthdayTime;
+                $data['birthdayMonth'] = $birthdayMonth;
+                $data['birthdayDate'] = $birthdayDate;
+                $data['lunar'] = $lunar;
+            }
             $custom = self::addCustom($data);
             $isNewCustom = 1;
         }

+ 16 - 18
biz-hd/goods/classes/GoodsCategoryClass.php

@@ -27,8 +27,8 @@ class GoodsCategoryClass extends BaseClass
         $mainId = $shop->mainId;
         $query = GoodsCategory::find();
         $query->where(['xhGoodsCategory.mainId' => $mainId]);
-        //早期前期写法没规范,cId catId categoryId都有可能,需要兼容
-        if (!empty($askInfo['cId']) || !empty($askInfo['categoryId']) || !empty($askInfo['catId'])) {
+        //早期前期写法没规范,cId catId categoryId classId都有可能,需要兼容
+        if (!empty($askInfo['cId']) || !empty($askInfo['categoryId']) || !empty($askInfo['catId']) || !empty($askInfo['classId'])) {
             $cId = $askInfo['cId'] ?? 0;
             if (empty($cId)) {
                 $cId = $askInfo['categoryId'] ?? 0;
@@ -36,6 +36,9 @@ class GoodsCategoryClass extends BaseClass
             if (empty($cId)) {
                 $cId = $askInfo['catId'] ?? 0;
             }
+            if (empty($cId)) {
+                $cId = $askInfo['classId'] ?? 0;
+            }
             $query->andWhere(['xhGoodsCategory.cId' => $cId]);
         }
         if (!empty($askInfo['searchText'])) {
@@ -53,26 +56,21 @@ class GoodsCategoryClass extends BaseClass
 
                 $query->andWhere(['xhGoods.delStatus' => 0]);
 
-                $priceStatus = isset($askInfo['priceStatus']) && is_numeric($askInfo['priceStatus']) ? $askInfo['priceStatus'] : -1;
-                if ($priceStatus > -1) {
-                    //1 有价格,2 无价格
-                    if ($priceStatus == 1) {
-                        $query->andWhere(['xhGoods.priceType' => 1]);
-                    }
-                    if ($priceStatus == 2) {
-                        $query->andWhere(['xhGoods.priceType' => 0]);
-                    }
+                $priceType = isset($askInfo['priceType']) && is_numeric($askInfo['priceType']) ? $askInfo['priceType'] : -1;
+                if ($priceType > -1) {
+                    //0 无价格,1 有价格
+                    $query->andWhere(['xhGoods.priceType' => $priceType]);
                 }
 
-                $stockStatus = isset($askInfo['stockStatus']) && is_numeric($askInfo['stockStatus']) ? $askInfo['stockStatus'] : -1;
-                if ($stockStatus > -1) {
-                    //1 有库存,2 无库存
-                    if ($stockStatus == 1) {
-                        $query->andWhere(['>', 'xhGoods.stock', 0]);
-                    }
-                    if ($stockStatus == 2) {
+                $hasStock = isset($askInfo['hasStock']) && is_numeric($askInfo['hasStock']) ? $askInfo['hasStock'] : -1;
+                if ($hasStock > -1) {
+                    //$hasStock 0 没库存 1有库存
+                    if ($hasStock == 0) {
                         $query->andWhere(['xhGoods.stock' => 0]);
                     }
+                    if ($hasStock == 1) {
+                        $query->andWhere(['>', 'xhGoods.stock', 0]);
+                    }
                 }
 
                 $flowerNum = isset($askInfo['flowerNum']) && is_numeric($askInfo['flowerNum']) ? $askInfo['flowerNum'] : 0;

+ 15 - 7
biz-hd/order/classes/OrderClass.php

@@ -255,9 +255,13 @@ class OrderClass extends BaseClass
 
         $sendType = $data['sendType'] ?? 0;
         if ($sendType == 1) {
-            //到店自取,默认当天23点前,没有用,为了方便查询排序
-            $data['reachDate'] = date("Y-m-d");
-            $data['reachPeriod'] = '22:00';
+            //到店自取,客户自己下单,不会有到店自取时间,但是如果是花店后台接单,会填到店自取时间,重要!!!!!!!!阿东那边已经出问题了!!!
+            if (empty($data['reachDate'])) {
+                $data['reachDate'] = date("Y-m-d");
+            }
+            if (empty($data['reachPeriod'])) {
+                $data['reachPeriod'] = '22:00';
+            }
         } else {
             //如果不是到店自取的,则必须要有配送时间,默认当天
             $data['reachDate'] = !empty($data['reachDate']) ? $data['reachDate'] : date("Y-m-d");
@@ -391,12 +395,12 @@ class OrderClass extends BaseClass
         $order->thirdNo = $transactionId;
         $order->onlinePay = dict::getDict('onlinePay', 'yes');
         $order->save();
-
-        self::payAfter($order, $payWay);
+        $params = [];
+        self::payAfter($order, $payWay, $params);
     }
 
     //订单完成 ssh 2021.4.20
-    public static function payAfter($order, $payWay)
+    public static function payAfter($order, $payWay, $params = [])
     {
         if (empty($order)) {
             util::fail('没有找到订单');
@@ -436,7 +440,11 @@ class OrderClass extends BaseClass
         $order->status = self::ORDER_STATUS_UN_SEND; // 付款后,订单状态设置为:已付款(待配送)
         $order->payWay = $payWay;
         $order->payStatus = 1;
-        $order->payTime = date("Y-m-d H:i:s");
+        if (!empty($params['historyDate'])) {
+            $order->payTime = $params['historyDate'] . ' ' . date("H:i:s");
+        } else {
+            $order->payTime = date("Y-m-d H:i:s");
+        }
         $order->stockChange = 1;
         $order->save();
 

+ 26 - 2
biz-hd/order/classes/OrderGoodsClass.php

@@ -207,7 +207,7 @@ class OrderGoodsClass extends BaseClass
     }
 
     //花店商家自主开单,库存不足则不能开单
-    public static function addData($data, $custom = null)
+    public static function addData($data, $custom = null, $goodsInfo = [])
     {
         $goodsId = $data['goodsId'] ?? 0;
         $num = $data['num'] ?? 0;
@@ -231,9 +231,33 @@ class OrderGoodsClass extends BaseClass
         $recordData['oldStock'] = $oldStock;
         $recordData['newStock'] = $newStock;
         $recordData['relateName'] = $customName;
-        //搜索关键词GoodsStockRecordClass::sellGoods,可以找到相同的方法,暂时没有写在一起
         GoodsStockRecordClass::sellGoods($recordData);
 
+        $currentGoods = $goodsInfo[$goodsId] ?? [];
+        if (!empty($currentGoods)) {
+            //如果定义库存充值的商品,并且库存低于99时,自动增加库存到999。
+            if (isset($currentGoods['stockSet']) && $currentGoods['stockSet'] == 0) {
+                if ($newStock < 99) {
+                    $addNum = bcsub(999, $newStock);
+                    $ret = GoodsClass::addStock($goodsId, $mainId, $addNum);
+                    $oldStock = $ret['oldStock'] ?? 0;
+                    $newStock = $ret['newStock'] ?? 0;
+                    $recordData = [];
+                    $recordData['sjId'] = $sjId;
+                    $recordData['shopId'] = $shopId;
+                    $recordData['mainId'] = $mainId;
+                    $recordData['orderSn'] = '';
+                    $recordData['goodsId'] = $goodsId;
+                    $recordData['goodsNum'] = $addNum;
+                    $recordData['oldStock'] = $oldStock;
+                    $recordData['newStock'] = $newStock;
+                    $recordData['relateName'] = '系统';
+                    $recordData['remark'] = '自动补充库存';
+                    GoodsStockRecordClass::pdGoods($recordData);
+                }
+            }
+        }
+
         return self::add($data, true);
     }
 

+ 93 - 0
biz-hd/order/classes/ScanPayClass.php

@@ -0,0 +1,93 @@
+<?php
+
+namespace bizHd\order\classes;
+
+use biz\goods\classes\GoodsClass;
+use biz\goods\models\Goods;
+use biz\shop\classes\ShopCapitalClass;
+use biz\shop\classes\ShopClass;
+use biz\shop\classes\ShopExtClass;
+use biz\stat\classes\StatOrderCountClass;
+use biz\stock\classes\GoodsStockRecordClass;
+use bizGhs\order\classes\CheckOrderClass;
+use bizGhs\product\classes\ProductClass;
+use bizGhs\stock\classes\StockRecordClass;
+use bizHd\custom\classes\CustomClass;
+use bizHd\item\classes\ItemClass;
+use bizHd\merchant\classes\SjClass;
+use bizHd\refund\classes\HdRefundClass;
+use bizHd\shop\classes\MainClass;
+use bizHd\shop\classes\ShopMoneyChangeClass;
+use bizHd\user\classes\UserClass;
+use bizHd\work\classes\WorkClass;
+use common\components\dict;
+use common\components\imgUtil;
+use common\components\miniUtil;
+use common\components\noticeUtil;
+use common\components\orderSn;
+use common\components\printUtil;
+use common\components\stringUtil;
+use common\components\util;
+use Yii;
+use bizHd\base\classes\BaseClass;
+use common\components\lakala\Lakala;
+
+class ScanPayClass extends BaseClass
+{
+
+    public static $baseFile = '\bizHd\order\models\ScanPay';
+
+    public static function getPayList($where)
+    {
+        return self::getList('*', $where, 'addTime DESC,id DESC');
+    }
+
+    public static function addOrder($data)
+    {
+        $mainId = $data['mainId'] ?? 0;
+        $shopId = $data['shopId'] ?? 0;
+        $hdId = $data['hdId'] ?? 0;
+        $customId = $data['customId'] ?? 0;
+        $snData = ['mainId' => $mainId, 'shopId' => $shopId, 'hdId' => $hdId, 'customId' => $customId];
+        $data['orderSn'] = orderSn::getScanPaySn($snData);
+        return self::add($data, true);
+    }
+
+    public static function thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId)
+    {
+        $order = self::getByCondition(['orderSn' => $orderSn], true);
+        if (empty($order)) {
+            noticeUtil::push('扫码付款成功,支付回调,单号:' . $orderSn . ' 金额:' . $totalFee . ' 回调id:' . $transactionId . ' 附件:' . $attach . ',没有找到单号', '15280215347');
+            $msg = "没有找到零售订单 orderSn:{$orderSn}";
+            Yii::info($msg);
+            util::fail($msg);
+        }
+        if ($order->actPrice != $totalFee) {
+            noticeUtil::push("扫码付款成功,支付回调错误,订单金额与回调通知金额不一致 orderSn:{$orderSn} {$order->actPrice} {$totalFee} 附件:{$attach}", '15280215347');
+            $msg = "零售订单金额与回调通知金额不一致 orderSn:{$orderSn} {$order->actPrice} {$totalFee}";
+            Yii::info($msg);
+            util::fail($msg);
+        }
+        $id = $order->id;
+        $order = self::getLockById($id);
+        $date = date("Y-m-d H:i:s");
+        $order->payStatus = 1;
+        $order->status = 2;
+        $order->payTime = $date;
+        $order->returnCode = $transactionId;
+        $order->save();
+        self::payAfter($order);
+    }
+
+    public static function payAfter($order)
+    {
+        $capitalType = dict::getDict('capitalType', 'scanPay', 'id');
+        $mainId = $order->mainId;
+        $shopId = $order->shopId;
+        $amount = $order->actPrice ?? 0;
+        $main = MainClass::getById($mainId, true);
+        $shop = ShopClass::getLockById($shopId);
+        ShopClass::customScanPayAddBalance($main, $shop, $amount, $order, $capitalType);
+    }
+
+}

+ 40 - 0
biz-hd/order/classes/ScanPaySnClass.php

@@ -0,0 +1,40 @@
+<?php
+
+namespace bizHd\order\classes;
+
+use biz\goods\classes\GoodsClass;
+use biz\goods\models\Goods;
+use biz\shop\classes\ShopCapitalClass;
+use biz\shop\classes\ShopClass;
+use biz\shop\classes\ShopExtClass;
+use biz\stat\classes\StatOrderCountClass;
+use biz\stock\classes\GoodsStockRecordClass;
+use bizGhs\order\classes\CheckOrderClass;
+use bizGhs\product\classes\ProductClass;
+use bizGhs\stock\classes\StockRecordClass;
+use bizHd\custom\classes\CustomClass;
+use bizHd\item\classes\ItemClass;
+use bizHd\merchant\classes\SjClass;
+use bizHd\refund\classes\HdRefundClass;
+use bizHd\shop\classes\MainClass;
+use bizHd\shop\classes\ShopMoneyChangeClass;
+use bizHd\user\classes\UserClass;
+use bizHd\work\classes\WorkClass;
+use common\components\dict;
+use common\components\imgUtil;
+use common\components\miniUtil;
+use common\components\noticeUtil;
+use common\components\orderSn;
+use common\components\printUtil;
+use common\components\stringUtil;
+use common\components\util;
+use Yii;
+use bizHd\base\classes\BaseClass;
+use common\components\lakala\Lakala;
+
+class ScanPaySnClass extends BaseClass
+{
+
+    public static $baseFile = '\bizHd\order\models\ScanPaySn';
+
+}

+ 15 - 0
biz-hd/order/models/ScanPay.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace bizHd\order\models;
+
+use bizHd\base\models\Base;
+
+class ScanPay extends Base
+{
+
+	public static function tableName()
+	{
+		return 'xhScanPay';
+	}
+
+}

+ 15 - 0
biz-hd/order/models/ScanPaySn.php

@@ -0,0 +1,15 @@
+<?php
+
+namespace bizHd\order\models;
+
+use bizHd\base\models\Base;
+
+class ScanPaySn extends Base
+{
+
+	public static function tableName()
+	{
+		return 'xhScanPaySn';
+	}
+
+}

+ 9 - 4
biz-hd/order/services/OrderService.php

@@ -2,6 +2,7 @@
 
 namespace bizHd\order\services;
 
+use bizGhs\item\classes\ItemClass;
 use bizHd\base\services\BaseService;
 use biz\sj\services\SjCapitalService;
 use biz\sj\services\MerchantService;
@@ -74,7 +75,7 @@ class OrderService extends BaseService
         $itemInfo = [];
         $currentItemIds = array_unique(array_filter($currentItemIds));
         if (!empty($currentItemIds)) {
-            $itemInfo = \bizGhs\item\classes\ItemClass::getByIds($currentItemIds, null, 'id');
+            $itemInfo = ItemClass::getByIds($currentItemIds, null, 'id');
         }
 
         $goodsPrice = 0;
@@ -134,7 +135,7 @@ class OrderService extends BaseService
                     'forwardStock' => $forwardStock,
                 ];
                 //占用库存在这里
-                OrderGoodsClass::addData($currentGoodsData, $custom);
+                OrderGoodsClass::addData($currentGoodsData, $custom, $goodsInfo);
             }
             if ($property == dict::getDict('property', 'item')) {
                 $currentInfo = $itemInfo[$currentId] ?? [];
@@ -278,9 +279,13 @@ class OrderService extends BaseService
 
         //欠款、已付款、余额支付的直接完成,另外客服下的单要走配送流程,所以是待配送状态
         if (in_array($hasPay, [dict::getDict('hasPay', 'payed'), dict::getDict('hasPay', 'debt'), dict::getDict('hasPay', 'balance')])) {
-            OrderClass::payAfter($returnOrder, $payWay);
+            $params = [];
+            if (!empty($data['historyDate'])) {
+                //后台开单传账单日期
+                $params['historyDate'] = $data['historyDate'];
+            }
+            OrderClass::payAfter($returnOrder, $payWay, $params);
         }
-
         return $returnOrder;
     }
 

+ 1 - 0
biz-hd/recharge/classes/RechargeClass.php

@@ -303,6 +303,7 @@ class RechargeClass extends BaseClass
             'relateId' => $relateId,
             'onlinePay' => $onlinePay,
             'capitalType' => $capitalType,
+            'giveAmount' => $balanceGive,
             'amount' => $totalBalance,
             'balance' => $hd->balance,
             'io' => 1,

+ 38 - 0
biz/shop/classes/ShopClass.php

@@ -447,6 +447,44 @@ class ShopClass extends BaseClass
         PtAssetClass::customKdAddBalance($shop, $amount, $order, $capitalType, $tx);
     }
 
+    public static function customScanPayAddBalance($main, $shop, $amount, $order, $capitalType)
+    {
+        //门店余额增加
+        $mainId = $shop->mainId ?? 0;
+        $currentBalance = bcadd($main->balance, $amount, 2);
+        $main->balance = $currentBalance;
+        //可提现余额同步增加
+        $currentTx = bcadd($main->txBalance, $amount, 2);
+        $main->txBalance = $currentTx;
+        $main->save();
+
+        $customName = '客户';
+        $customId = $order->customId ?? 0;
+        $custom = \bizHd\custom\classes\CustomClass::getById($customId, true);
+        if (!empty($custom->name)) {
+            $customName = $custom->name;
+        }
+
+        //增加余额变动记录
+        $id = $order->id;
+        $event = $customName . "扫码付款" . floatval($amount) . "元";
+        $change = [
+            'relateId' => $id,
+            'capitalType' => $capitalType,
+            'amount' => $amount,
+            'balance' => $currentBalance,
+            'txBalance' => $currentTx,
+            'io' => 1,
+            'payWay' => $order->payWay,
+            'event' => $event,
+            'mainId' => $mainId,
+            'tx' => 2,
+            'ptStyle' => $shop->ptStyle,
+            'fromType' => 1,
+        ];
+        ShopYeChangeClass::addChange($change, true);
+    }
+
     //门店充值增加余额 ssh 2021.2.21
     //$fix = true 余额只能在指定门店使用
     public static function rechargeAddBalance($shop, $amount, $order, $tx, $capitalType, $fix = false)

+ 42 - 0
biz/shop/classes/ShopExtClass.php

@@ -307,6 +307,48 @@ class ShopExtClass extends BaseClass
         }
     }
 
+    public static function skRechargeReport($recharge)
+    {
+        if (empty($recharge)) {
+            return false;
+        }
+        if ($recharge->payStatus != 1) {
+            //还没有付款订单不播报
+            return false;
+        }
+        $shopId = $recharge->shopId ?? 0;
+        $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
+        if (!empty($shopExt->lbSn)) {
+            $actPrice = $recharge->amount ?? 0;
+            $payWay = $recharge->payWay ?? 0;
+            $sound = $payWay == 0 ? "微信充值{$actPrice}元," : "支付宝充值{$actPrice}元";
+            $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
+            $curl = new curl\Curl();
+            $curl->get($url);
+        }
+    }
+
+    public static function hdScanPayReport($order)
+    {
+        if (empty($order)) {
+            return false;
+        }
+        if ($order->payStatus != 1) {
+            //还没有付款订单不播报
+            return false;
+        }
+        $shopId = $order->shopId ?? 0;
+        $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true);
+        if (!empty($shopExt->lbSn)) {
+            $actPrice = $order->actPrice ?? 0;
+            $payWay = $order->payWay ?? 0;
+            $sound = $payWay == 0 ? "微信收款{$actPrice}元,谢谢惠顾,欢迎下次光临" : "支付宝收款{$actPrice}元,谢谢惠顾,欢迎下次光临";
+            $url = "https://speaker.17laimai.cn/notify.php?id={$shopExt->lbSn}&token=HK1626595800&version={$shopExt->lbVersion}&message=" . $sound;
+            $curl = new curl\Curl();
+            $curl->get($url);
+        }
+    }
+
     //供货商收款声音播放 ssh 20230421
     public static function ghsGatheringReport($order)
     {

+ 2 - 2
biz/stock/classes/GoodsStockRecordClass.php

@@ -130,8 +130,8 @@ class GoodsStockRecordClass extends BaseClass
     //获取某个商品的库存变更记录
     public static function getRecordList($where)
     {
-        $data = self::getList('*', $where, 'addTime DESC');
-        $list = isset($data['list']) && !empty($data['list']) ? $data['list'] : [];
+        $data = self::getList('*', $where, 'addTime DESC,id DESC');
+        $list = !empty($data['list']) ? $data['list'] : [];
         if (empty($list)) {
             return $data;
         }

+ 45 - 0
biz/wx/classes/WxMessageClass.php

@@ -755,6 +755,51 @@ class WxMessageClass extends BaseClass
         }
     }
 
+    public static function hdScanPayInform($shop, $scan)
+    {
+        if (empty($shop)) {
+            return false;
+        }
+        $ptStyle = $shop->ptStyle;
+        $wxBase = WxOpenClass::getWxBase();
+        $wx = $wxBase[$ptStyle] ?? [];
+        $message = self::getAllByCondition(['ptStyle' => $ptStyle], null, '*', 'shortTemplateId');
+        $shortTempId = 'OPENTM207422813';//收入提醒
+        $tempId = $message[$shortTempId]['templateId'] ?? '';
+        if (empty($tempId)) {
+            return false;
+        }
+        $actPrice = $scan->actPrice;
+        $adminList = ShopAdminClass::getRemainAdmin($shop);
+        if (empty($adminList)) {
+            return false;
+        }
+        foreach ($adminList as $admin) {
+            $openId = $admin['openId'] ?? '';
+            if ($ptStyle == dict::getDict('ptStyle', 'ghs')) {
+                $openId = $admin['ghsOpenId'] ?? '';
+            }
+            if (empty($openId)) {
+                continue;
+            }
+            $data = [
+                "touser" => $openId,
+                "template_id" => $tempId,
+                "url" => Yii::$app->params['ghsDomain'],
+                "data" => [
+                    "first" => ["value" => "您有新的收入。", "color" => "#173177"],
+                    "keyword1" => ["value" => $actPrice, "color" => "#173177"],
+                    "keyword2" => ["value" => '二维码收款', "color" => "#173177"],
+                    "keyword3" => ["value" => date("Y-m-d H:i"), "color" => "#173177"],
+                    "remark" => ["value" => "点击查看详情", "color" => "#173177"]
+                ]
+            ];
+            $data['miniprogram']['appid'] = $wx['miniAppId'];
+            $data['miniprogram']['pagepath'] = 'admin/order/scanPay';
+            wxUtil::sendTaskInform($data, $wx, $ptStyle);
+        }
+    }
+
     //审核通过通知 ssh 20210530
     public static function applyPass($shop)
     {

+ 2 - 2
common/components/book.php

@@ -91,9 +91,9 @@ class book
         'chargeStandard' => [
             ['style' => 'info', 'value' => '软件年费1580元,年费需每年付一次,客户通过小程序下单,会扣千分之3.3手续费(即1千元扣3.3元)。',],
             ['style' => 'info', 'value' => '根据你自身门店情况,选择以下套餐。下面列出的套餐,已经过全国100多家鲜花批发店磨合使用,非常成熟好用,请放心购买使用,以下套餐已含第一年年费。',],
-            ['style' => 'miniTitle', 'value' => '软件的研发成本巨大,不管是年费、费率和套餐,都已经最低价,没有谈的空间,不需要再找我们浪费时间,请理解。付费后不支持退货。',],
+            ['style' => 'miniTitle', 'value' => '软件的研发成本巨大,不管是年费、费率和套餐,都已经底价,没有商量的空间,请理解。付费后不支持退货。',],
             ['style' => 'info', 'value' => '首次开通系统,另外赠送30天有效期,保证有足够时间试运营。',],
-            ['style' => 'info', 'value' => '提供上门培训服务,培训时间3天,需报销差旅住宿费用,公司在福建厦门。',],
+            ['style' => 'info', 'value' => '提供上门培训服务,培训时间3天,需报销差旅住宿费用,公司地址在福建厦门。',],
             ['style' => 'smallTitle', 'value' => '仓库版',],
             ['style' => 'info', 'value' => '整套软件功能(一年)',],
             ['style' => 'info', 'value' => '小票机1台',],

+ 0 - 1
common/components/bookJd.php

@@ -8,7 +8,6 @@ class bookJd
     public static $list = [
         ['class' => '开始', 'icon' => '/book/begin.png', 'list' => [
             ['title' => '收费标准', 'id' => 'chargeStandard2'],
-            ['title' => '销花宝是什么', 'id' => 'what'],
             ['title' => '注册和下载APP', 'id' => 'register'],
             ['title' => '添加修改花材和分类(必看)', 'id' => 'flowerManage'],
             ['title' => '批量修改库存', 'id' => 'batchModifyStock'],

+ 2 - 0
common/components/dict.php

@@ -419,6 +419,7 @@ class dict
             'deduct' => ['id' => 77, 'name' => 'deduct'],
             //如果涉及是系统处理和操作,都可以用这个流水类型
             'system' => ['id' => 78, 'name' => 'system'],
+            'scanPay' => ['id' => 79, 'name' => 'scanPay'],
         ],
         "capitalTypeList" => [//流水类型的对应链接,后台收支明细查看时跳转的链接
             0 => ['link' => '/capital/order-detail', 'name' => '网店', 'orderLink' => '/order/detail', 'id' => 0,],
@@ -469,6 +470,7 @@ class dict
             76 => ['link' => '', 'name' => '售后返充', 'id' => 76,],
             77 => ['link' => '', 'name' => '手动减少', 'id' => 77,],
             78 => ['link' => '', 'name' => '系统操作', 'id' => 78,],
+            79 => ['link' => '', 'name' => '扫码付款', 'id' => 79,],
         ],
 
         //用户来源

+ 16 - 0
common/components/orderSn.php

@@ -19,6 +19,7 @@ use bizHd\express\classes\ExpressSnClass;
 use bizHd\goods\classes\GoodsCgSnClass;
 use bizHd\goods\classes\GoodsSnClass;
 use bizHd\ljh\classes\LjhSnClass;
+use bizHd\order\classes\ScanPaySnClass;
 use bizHd\order\classes\SettleSnClass;
 use bizHd\part\classes\PartSnClass;
 use bizHd\pd\classes\PdGoodsSnClass;
@@ -157,6 +158,21 @@ class orderSn
         return $prefix . $id;
     }
 
+    public static function getScanPaySn($params)
+    {
+        $params['id'] = null;
+        $prefix = 'SC_CS';
+        if (getenv('YII_ENV', 'local') == 'production') {
+            $prefix = 'SC';
+        }
+        $respond = ScanPaySnClass::add($params);
+        $id = $respond['id'] ?? 0;
+        if (empty($id)) {
+            util::fail('订单号没有生成');
+        }
+        return $prefix . $id;
+    }
+
     //供货商采购单号 ssh 2021.1.19
     public static function getGhsPurchaseSn()
     {

+ 5 - 0
common/components/payUtil.php

@@ -7,6 +7,7 @@ use biz\wx\classes\WxMessageClass;
 use bizGhs\custom\classes\CustomRechargeClass;
 use bizHd\ljh\classes\LjhApplyClass;
 use bizHd\order\classes\OrderClass;
+use bizHd\order\classes\ScanPayClass;
 use bizHd\purchase\classes\PurchaseClearClass;
 use bizHd\purchase\services\PurchaseService;
 use bizHd\px\services\PxApplyService;
@@ -45,6 +46,10 @@ class payUtil
                 //散客下单
                 OrderClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
                 break;
+            case dict::getDict('capitalType', 'scanPay', 'id'):
+                //扫码付款
+                ScanPayClass::thirdPay($payWay, $orderSn, $totalFee, $attach, $transactionId);
+                break;
             case dict::getDict('capitalType', 'xhRenew', 'id'):
                 //商家续期
                 RenewClass::thirdPay($payWay, $orderSn, $totalFee, $attach);

+ 48 - 4
common/components/printUtil.php

@@ -37,8 +37,19 @@ class printUtil
             'content' => $content,
             'times' => $this->times//打印次数
         );
-        $client = new \HttpClient(self::IP, self::PORT);
-        if (!$client->post(self::PATH, $msgInfo)) {
+        try {
+            $client = new \HttpClient(self::IP, self::PORT);
+            $client->useGzip(false); //禁用 Gzip
+            $rs = $client->post(self::PATH, $msgInfo);
+            //服务器返回的JSON字符串,建议要当做日志记录起来
+            $result = $client->getContent();
+            //echo $result;
+        } catch (\Exception $e) {
+            Yii::error('打印日志:' . $e->getMessage());
+            noticeUtil::push("出现打印标签,内容:{$content},原因:" . $e->getMessage(), '15280215347');
+            return;
+        }
+        if (!$rs) {
             //echo 'error';
         } else {
             //服务器返回的JSON字符串,建议要当做日志记录起来
@@ -47,7 +58,32 @@ class printUtil
         }
     }
 
+    /**
+     * 打印订单
+     */
     public function printMsg($content, $shop = null, $orderSn = '')
+    {
+        $contentLength = strlen($content);
+        if ($contentLength > 5000) {
+            $contents = explode("<BR>", $content);
+            $newContent = '';
+            foreach ($contents as $line) {
+                if (strlen($newContent . $line . "<BR>") > 5000) {
+                    $this->doPrint($newContent, $shop, $orderSn);
+                    $newContent = $line . "<BR>";
+                } else {
+                    $newContent .= $line . "<BR>";
+                }
+            }
+            if (!empty($newContent)) {
+                $this->doPrint($newContent, $shop, $orderSn);
+            }
+        } else {
+            $this->doPrint($content, $shop, $orderSn);
+        }
+    }
+
+    private function doPrint($content, $shop = null, $orderSn = '')
     {
         $time = time();         //请求时间
         $msgInfo = array(
@@ -59,8 +95,16 @@ class printUtil
             'content' => $content,
             'times' => $this->times//打印次数
         );
-        $client = new \HttpClient(self::IP, self::PORT);
-        if (!$client->post(self::PATH, $msgInfo)) {
+        try {
+            $client = new \HttpClient(self::IP, self::PORT);
+            $client->useGzip(false); // 禁用 Gzip
+            $rs = $client->post(self::PATH, $msgInfo);
+        } catch (\Exception $e) {
+            Yii::error('打印日志:' . $e->getMessage());
+            noticeUtil::push($shop->merchantName . $shop->shopName . " 出现订单打印未成功,订单号:{$orderSn},原因:" . $e->getMessage(), '15280215347');
+            return;
+        }
+        if (!$rs) {
             //echo 'error';
         } else {
             //服务器返回的JSON字符串,建议要当做日志记录起来

+ 1 - 1
common/components/qrCodeUtil.php

@@ -221,7 +221,7 @@ class qrCodeUtil
         }
         $behind = $middle . $sjId . '_' . $shopId . '.png';
         $saveFile = $prefix . $behind;
-        if (file_exists($saveFile) == false) {
+        if (!file_exists($saveFile)) {
             \QRcode::png($url, $saveFile, $errorCorrectionLevel, $matrixPointSize, 1);//最后的参数1表示空白间距
             oss::uploadImage($behind, $saveFile);
         }