Explorar el Código

更新4.7开发分支

吴昊天 hace 2 años
padre
commit
8c7e90ce56
Se han modificado 100 ficheros con 909 adiciones y 963 borrados
  1. 1 0
      crmeb/app/adminapi/controller/v1/order/StoreOrder.php
  2. 0 1
      crmeb/app/adminapi/route/route.php
  3. 5 1
      crmeb/app/api/controller/v1/PayController.php
  4. 15 52
      crmeb/app/api/controller/v1/order/OtherOrderController.php
  5. 119 121
      crmeb/app/api/controller/v1/order/StoreOrderController.php
  6. 5 4
      crmeb/app/api/controller/v1/user/UserRechargeController.php
  7. 1 1
      crmeb/app/api/controller/v1/wechat/AuthController.php
  8. 1 3
      crmeb/app/api/route/v1.php
  9. 24 34
      crmeb/app/common.php
  10. 32 3
      crmeb/app/dao/system/config/SystemStorageDao.php
  11. 3 2
      crmeb/app/listener/order/OrderPaySuccess.php
  12. 3 4
      crmeb/app/listener/pay/Notify.php
  13. 29 3
      crmeb/app/services/BaseServices.php
  14. 2 2
      crmeb/app/services/agent/AgentLevelServices.php
  15. 2 2
      crmeb/app/services/agent/AgentManageServices.php
  16. 6 8
      crmeb/app/services/message/SystemNotificationServices.php
  17. 124 143
      crmeb/app/services/message/wechat/MessageServices.php
  18. 8 1
      crmeb/app/services/order/StoreCartServices.php
  19. 4 3
      crmeb/app/services/order/StoreOrderCreateServices.php
  20. 8 2
      crmeb/app/services/order/StoreOrderRefundServices.php
  21. 83 3
      crmeb/app/services/order/StoreOrderServices.php
  22. 1 0
      crmeb/app/services/order/StoreOrderSuccessServices.php
  23. 126 51
      crmeb/app/services/pay/OrderPayServices.php
  24. 10 110
      crmeb/app/services/pay/PayNotifyServices.php
  25. 43 0
      crmeb/app/services/pay/PayServices.php
  26. 34 14
      crmeb/app/services/pay/RechargeServices.php
  27. 22 3
      crmeb/app/services/product/product/StoreProductServices.php
  28. 0 2
      crmeb/app/services/system/admin/SystemRoleServices.php
  29. 1 1
      crmeb/app/services/user/UserBillServices.php
  30. 19 3
      crmeb/app/services/user/UserExtractServices.php
  31. 14 6
      crmeb/app/services/user/UserRechargeServices.php
  32. 2 1
      crmeb/composer.json
  33. 29 1
      crmeb/crmeb/basic/BaseStorage.php
  34. 0 37
      crmeb/crmeb/exceptions/SmsException.php
  35. 0 37
      crmeb/crmeb/exceptions/TemplateException.php
  36. 0 38
      crmeb/crmeb/exceptions/WechatReplyException.php
  37. 10 8
      crmeb/crmeb/services/AliPayService.php
  38. 1 2
      crmeb/crmeb/services/app/MiniProgramService.php
  39. 15 13
      crmeb/crmeb/services/app/WechatService.php
  40. 34 1
      crmeb/crmeb/services/easywechat/v3pay/PayClient.php
  41. 7 23
      crmeb/crmeb/services/pay/extend/allinpay/AllinPay.php
  42. 1 1
      crmeb/crmeb/services/pay/storage/AliPay.php
  43. 21 6
      crmeb/crmeb/services/pay/storage/AllinPay.php
  44. 17 14
      crmeb/crmeb/services/pay/storage/V3WechatPay.php
  45. 0 47
      crmeb/crmeb/traits/ErrorTrait.php
  46. 0 56
      crmeb/crmeb/traits/SearchDaoTrait.php
  47. 0 49
      crmeb/crmeb/traits/ServicesTrait.php
  48. 27 2
      crmeb/crmeb/utils/Queue.php
  49. 0 0
      crmeb/public/.htaccess
  50. 0 1
      crmeb/public/admin/css.worker.js
  51. BIN
      crmeb/public/admin/css.worker.js.gz
  52. 0 2
      crmeb/public/admin/css/app.9b3488d2.css
  53. BIN
      crmeb/public/admin/css/app.9b3488d2.css.gz
  54. 0 1
      crmeb/public/admin/css/chunk-00f06b83.0c7fb962.css
  55. 0 1
      crmeb/public/admin/css/chunk-028811c2.79268db6.css
  56. 0 1
      crmeb/public/admin/css/chunk-02afff9e.7ef03ec2.css
  57. 0 1
      crmeb/public/admin/css/chunk-03149c68.fac0fd59.css
  58. 0 1
      crmeb/public/admin/css/chunk-03c5c4a2.3606733e.css
  59. 0 1
      crmeb/public/admin/css/chunk-058eab4f.5bd359e2.css
  60. BIN
      crmeb/public/admin/css/chunk-058eab4f.5bd359e2.css.gz
  61. 0 1
      crmeb/public/admin/css/chunk-07142a06.c25648f4.css
  62. 0 1
      crmeb/public/admin/css/chunk-07b5ff65.1b08dbb6.css
  63. 0 1
      crmeb/public/admin/css/chunk-081b585b.ce3128fb.css
  64. 0 1
      crmeb/public/admin/css/chunk-08c24f8e.4bc347be.css
  65. 0 1
      crmeb/public/admin/css/chunk-09b3eff2.e60ad228.css
  66. 0 1
      crmeb/public/admin/css/chunk-0a6e99fd.bbf631f1.css
  67. 0 1
      crmeb/public/admin/css/chunk-0c05df09.ec625add.css
  68. BIN
      crmeb/public/admin/css/chunk-0c05df09.ec625add.css.gz
  69. 0 1
      crmeb/public/admin/css/chunk-0ca76063.b9a345b5.css
  70. 0 1
      crmeb/public/admin/css/chunk-0dd5615e.f7a9463b.css
  71. BIN
      crmeb/public/admin/css/chunk-0dd5615e.f7a9463b.css.gz
  72. 0 1
      crmeb/public/admin/css/chunk-0f73c812.1b8d4ade.css
  73. 0 1
      crmeb/public/admin/css/chunk-124c1be4.c486543b.css
  74. 0 1
      crmeb/public/admin/css/chunk-13797d86.5bf9b10b.css
  75. BIN
      crmeb/public/admin/css/chunk-13797d86.5bf9b10b.css.gz
  76. 0 1
      crmeb/public/admin/css/chunk-157b4f48.fb9470f3.css
  77. 0 1
      crmeb/public/admin/css/chunk-16138b40.34dad7de.css
  78. 0 1
      crmeb/public/admin/css/chunk-16dc5aef.4ccdcbdc.css
  79. 0 1
      crmeb/public/admin/css/chunk-186376ec.fa095460.css
  80. BIN
      crmeb/public/admin/css/chunk-186376ec.fa095460.css.gz
  81. 0 1
      crmeb/public/admin/css/chunk-19de70eb.6f86bb2b.css
  82. 0 1
      crmeb/public/admin/css/chunk-1a3b818c.92333ade.css
  83. 0 1
      crmeb/public/admin/css/chunk-1ab64b57.659a336b.css
  84. 0 1
      crmeb/public/admin/css/chunk-1c845e07.a1f0b1ed.css
  85. 0 1
      crmeb/public/admin/css/chunk-1eb2f024.da2c4a96.css
  86. 0 1
      crmeb/public/admin/css/chunk-1f894614.c0a99313.css
  87. 0 1
      crmeb/public/admin/css/chunk-240f368d.2a31843b.css
  88. 0 1
      crmeb/public/admin/css/chunk-24dfe0e6.6ed9fb31.css
  89. 0 1
      crmeb/public/admin/css/chunk-250ad9dd.e242bc05.css
  90. 0 1
      crmeb/public/admin/css/chunk-2560a43a.272729ba.css
  91. 0 1
      crmeb/public/admin/css/chunk-29e98b5f.0357c398.css
  92. 0 1
      crmeb/public/admin/css/chunk-2b359071.e4a7c33a.css
  93. 0 1
      crmeb/public/admin/css/chunk-2b4d3374.62a7578b.css
  94. 0 1
      crmeb/public/admin/css/chunk-2e90bd4b.9805da2f.css
  95. 0 1
      crmeb/public/admin/css/chunk-2eae1aba.e46873bd.css
  96. 0 1
      crmeb/public/admin/css/chunk-2fb735d0.d7bbb8c6.css
  97. 0 1
      crmeb/public/admin/css/chunk-32d3326e.58ba8f69.css
  98. 0 1
      crmeb/public/admin/css/chunk-342f0a0a.1a0666d4.css
  99. 0 1
      crmeb/public/admin/css/chunk-347f00e3.41211080.css
  100. 0 0
      crmeb/public/admin/css/chunk-35aca391.47a587bd.css

+ 1 - 0
crmeb/app/adminapi/controller/v1/order/StoreOrder.php

@@ -81,6 +81,7 @@ class StoreOrder extends AuthController
         ]);
         $where['is_system_del'] = 0;
         $where['pid'] = 0;
+        if ($where['status'] == 1) $where = $where + ['shipping_type' => 1];
         return app('json')->success($this->services->getOrderList($where, ['*'], ['split' => function ($query) {
             $query->field('id,pid');
         }, 'pink', 'invoice', 'division']));

+ 0 - 1
crmeb/app/adminapi/route/route.php

@@ -36,7 +36,6 @@ Route::group(function () {
     Route::get('get_workerman_url', 'PublicController/getWorkerManUrl')->option(['real_name' => '获取客服数据']);
     //测试
     Route::get('index', 'Test/index')->option(['real_name' => '测试地址']);
-    Route::get('h5', 'Test/h5pay')->option(['real_name' => '测试地址2']);
 })->middleware(AllowOriginMiddleware::class);
 
 /**

+ 5 - 1
crmeb/app/api/controller/v1/PayController.php

@@ -13,6 +13,7 @@ namespace app\api\controller\v1;
 
 
 use app\Request;
+use crmeb\services\app\MiniProgramService;
 use crmeb\services\pay\Pay;
 
 /**
@@ -36,8 +37,11 @@ class PayController
                 /** @var Pay $pay */
                 $pay = app()->make(Pay::class, ['ali_pay']);
                 return $pay->handleNotify();
-            case 'wechat':
+            case 'v3wechat':
+                return app()->make(Pay::class, ['v3_wechat_pay'])->handleNotify()->getContent();
             case 'routine':
+                return MiniProgramService::handleNotify();
+            case 'wechat':
                 if (sys_config('pay_wechat_type')) {
                     /** @var Pay $pay */
                     $pay = app()->make(Pay::class, ['v3_wechat_pay']);

+ 15 - 52
crmeb/app/api/controller/v1/order/OtherOrderController.php

@@ -56,7 +56,7 @@ class OtherOrderController
         $uid = $request->uid();
         /** @var UserServices $userService */
         $userService = app()->make(UserServices::class);
-        $user_info = $userService->get($uid);
+        $user_info = $userService->get($uid, ['is_money_level']);
         //会员线下享受折扣
         if ($user_info->is_money_level > 0) {
             //看是否开启线下享受折扣
@@ -115,30 +115,20 @@ class OtherOrderController
 
         $info = compact('order_id');
 
-        $payType = get_pay_type($payType);
+        $payType = app()->make(OrderPayServices::class)->getPayType($payType);
+
+        //支付金额为0
+        if (bcsub((string)$orderInfo['pay_price'], '0', 2) <= 0) {
+            //创建订单jspay支付
+            $payPriceStatus = $OtherOrderServices->zeroYuanPayment($orderInfo);
+            if ($payPriceStatus)//0元支付成功
+                return app('json')->status('success', 410199, $info);
+            else
+                return app('json')->status('pay_error');
+        }
 
         if ($order_id) {
             switch ($payType) {
-                case PayServices::WEIXIN_PAY:
-                    if ($orderInfo['paid']) return app('json')->fail(410174);
-                    //支付金额为0
-                    if (bcsub((string)$orderInfo['pay_price'], '0', 2) <= 0) {
-                        //创建订单jspay支付
-                        $payPriceStatus = $OtherOrderServices->zeroYuanPayment($orderInfo, $uid);
-                        if ($payPriceStatus)//0元支付成功
-                            return app('json')->status('success', 410195, $info);
-                        else
-                            return app('json')->status('pay_error');
-                    } else {
-                        /** @var OrderPayServices $payServices */
-                        $payServices = app()->make(OrderPayServices::class);
-                        $info['jsConfig'] = $payServices->orderPay($orderInfo, $from);
-                        if ($from == 'weixinh5') {
-                            return app('json')->status('wechat_h5_pay', 410196, $info);
-                        } else {
-                            return app('json')->status('wechat_pay', 410196, $info);
-                        }
-                    }
                 case PayServices::YUE_PAY:
                     /** @var YuePayServices $yueServices */
                     $yueServices = app()->make(YuePayServices::class);
@@ -151,39 +141,12 @@ class OtherOrderController
                         else
                             return app('json')->status('pay_error', $pay);
                     }
-                case PayServices::ALIAPY_PAY:
-                    if (!$quitUrl && $from != 'routine' && !request()->isApp()) {
-                        return app('json')->status('pay_error', 410198, $info);
-                    }
-                    //支付金额为0
-                    if (bcsub((string)$orderInfo['pay_price'], '0', 2) <= 0) {
-                        //创建订单jspay支付
-                        $payPriceStatus = $OtherOrderServices->zeroYuanPayment($orderInfo);
-                        if ($payPriceStatus)//0元支付成功
-                            return app('json')->status('success', 410199, $info);
-                        else
-                            return app('json')->status('pay_error');
-                    } else {
-                        /** @var OrderPayServices $payServices */
-                        $payServices = app()->make(OrderPayServices::class);
-                        $info['jsConfig'] = $payServices->alipayOrder($orderInfo, $quitUrl, $from == 'routine');
-                        $payKey = md5($orderInfo['order_id']);
-                        CacheService::set($payKey, ['order_id' => $orderInfo['order_id'], 'other_pay_type' => true], 300);
-                        $info['pay_key'] = $payKey;
-                        return app('json')->status(PayServices::ALIAPY_PAY . '_pay', 410196, $info);
-                    }
                 case PayServices::OFFLINE_PAY:
                     return app('json')->status('success', 410196, $info);
-                case PayServices::ALLIN_PAY:
-                    /** @var OrderPayServices $payServices */
+                default:
                     $payServices = app()->make(OrderPayServices::class);
-                    $info['jsConfig'] = $payServices->orderPay($orderInfo, $payType, [
-                        'returl' => sys_config('site_url') . '/pages/index/index',
-                    ]);
-                    if ($request->isWechat()) {
-                        $info['pay_url'] = AllinPay::UNITODER_H5UNIONPAY;
-                    }
-                    return app('json')->status(PayServices::ALLIN_PAY . '_pay', 410196, $info);
+                    $payInfo = $payServices->beforePay($order->toArray(), $payType, ['quitUrl' => $quitUrl]);
+                    return app('json')->status($payInfo['status'], $payInfo['payInfo']);
             }
         } else return app('json')->fail(410200);
     }

+ 119 - 121
crmeb/app/api/controller/v1/order/StoreOrderController.php

@@ -213,13 +213,7 @@ class StoreOrderController
                 return app('json')->fail(410212);
             }
         }
-        if ($from != 'pc') {
-            if (!$this->services->checkPaytype(get_pay_type($payType))) {
-                return app('json')->fail(410213);
-            }
-        } else {
-            $payType = 'pc';
-        }
+
         $isChannel = $this->getChennel[$from] ?? ($request->isApp() ? 0 : 1);
         $cartInfo = null;
         if ($seckill_id || $combinationId || $bargainId || $advanceId) {
@@ -273,88 +267,91 @@ class StoreOrderController
         if ($invoice_id) {
             $storeOrderInvoiceServices->makeUp($uid, $orderId, (int)$invoice_id);
         }
-        $orderInfo = $orderInfo->toArray();
+
         $info = compact('orderId', 'key');
-        if ($orderId) {
-            switch ($payType) {
-                case PayServices::WEIXIN_PAY:
-                    if ($orderInfo['paid']) return app('json')->fail(410174);
-                    //支付金额为0
-                    if (bcsub((string)$orderInfo['pay_price'], '0', 2) <= 0) {
-                        //创建订单jspay支付
-                        /** @var StoreOrderSuccessServices $success */
-                        $success = app()->make(StoreOrderSuccessServices::class);
-                        $payPriceStatus = $success->zeroYuanPayment($orderInfo, $uid, PayServices::WEIXIN_PAY);
-                        if ($payPriceStatus)//0元支付成功
-                            return app('json')->status('success', 410195, $info);
-                        else
-                            return app('json')->status('pay_error');
-                    } else {
-                        /** @var OrderPayServices $payServices */
-                        $payServices = app()->make(OrderPayServices::class);
-                        if ($from == 'app' && $request->isApp()) {
-                            $from = 'weixin';
-                        }
-                        $info['jsConfig'] = $payServices->orderPay($orderInfo, $from);
-                        if ($from == 'weixinh5') {
-                            return app('json')->status('wechat_h5_pay', 410203, $info);
-                        } else {
-                            return app('json')->status('wechat_pay', 410203, $info);
-                        }
-                    }
-                case PayServices::YUE_PAY:
-                    /** @var YuePayServices $yueServices */
-                    $yueServices = app()->make(YuePayServices::class);
-                    $pay = $yueServices->yueOrderPay($orderInfo, $uid);
-                    if ($pay['status'] === true)
-                        return app('json')->status('success', 410197, $info);
-                    else {
-                        if (is_array($pay))
-                            return app('json')->status($pay['status'], $pay['msg'], $info);
-                        else
-                            return app('json')->status('pay_error', $pay);
-                    }
-                case PayServices::ALIAPY_PAY:
-                    if (!$quitUrl && ($request->isH5() || $request->isWechat())) {
-                        return app('json')->status('pay_error', 410198, $info);
-                    }
-                    [$url, $param] = explode('?', $quitUrl);
-                    $quitUrl = $url . '?order_id=' . $orderInfo['order_id'];
-                    //支付金额为0
-                    if (bcsub((string)$orderInfo['pay_price'], '0', 2) <= 0) {
-                        //创建订单jspay支付
-                        /** @var StoreOrderSuccessServices $success */
-                        $success = app()->make(StoreOrderSuccessServices::class);
-                        $payPriceStatus = $success->zeroYuanPayment($orderInfo, $uid, PayServices::ALIAPY_PAY);
-                        if ($payPriceStatus)//0元支付成功
-                            return app('json')->status('success', 410199, $info);
-                        else
-                            return app('json')->status('pay_error');
-                    } else {
-                        /** @var OrderPayServices $payServices */
-                        $payServices = app()->make(OrderPayServices::class);
-                        $info['jsConfig'] = $payServices->alipayOrder($orderInfo, $quitUrl, $from == 'routine');
-                        $payKey = md5($orderInfo['order_id']);
-                        CacheService::set($payKey, ['order_id' => $orderInfo['order_id'], 'other_pay_type' => false], 300);
-                        $info['pay_key'] = $payKey;
-                        return app('json')->status(PayServices::ALIAPY_PAY . '_pay', 410203, $info);
-                    }
-                case PayServices::OFFLINE_PAY:
-                case 'pc':
-                case 'friend':
-                    return app('json')->status('success', 410203, $info);
-                case PayServices::ALLIN_PAY:
-                    /** @var OrderPayServices $payServices */
-                    $payServices = app()->make(OrderPayServices::class);
-                    $info['jsConfig'] = $payServices->orderPay($orderInfo, $payType, [
-                        'returl' => sys_config('site_url') . '/pages/index/index',
-                    ]);
-                    if ($request->isWechat()) {
-                        $info['pay_url'] = AllinPay::UNITODER_H5UNIONPAY;
-                    }
-                    return app('json')->status(PayServices::ALLIN_PAY . '_pay', 410203, $info);
-            }
-        } else return app('json')->fail(410200);
+
+        return app('json')->status('success', 410203, $info);
+
+//        if ($orderId) {
+//            switch ($payType) {
+//                case PayServices::WEIXIN_PAY:
+//                    if ($orderInfo['paid']) return app('json')->fail(410174);
+//                    //支付金额为0
+//                    if (bcsub((string)$orderInfo['pay_price'], '0', 2) <= 0) {
+//                        //创建订单jspay支付
+//                        /** @var StoreOrderSuccessServices $success */
+//                        $success = app()->make(StoreOrderSuccessServices::class);
+//                        $payPriceStatus = $success->zeroYuanPayment($orderInfo, $uid, PayServices::WEIXIN_PAY);
+//                        if ($payPriceStatus)//0元支付成功
+//                            return app('json')->status('success', 410195, $info);
+//                        else
+//                            return app('json')->status('pay_error');
+//                    } else {
+//                        /** @var OrderPayServices $payServices */
+//                        $payServices = app()->make(OrderPayServices::class);
+//                        if ($from == 'app' && $request->isApp()) {
+//                            $from = 'weixin';
+//                        }
+//                        $info['jsConfig'] = $payServices->orderPay($orderInfo, $from);
+//                        if ($from == 'weixinh5') {
+//                            return app('json')->status('wechat_h5_pay', 410203, $info);
+//                        } else {
+//                            return app('json')->status('wechat_pay', 410203, $info);
+//                        }
+//                    }
+//                case PayServices::YUE_PAY:
+//                    /** @var YuePayServices $yueServices */
+//                    $yueServices = app()->make(YuePayServices::class);
+//                    $pay = $yueServices->yueOrderPay($orderInfo, $uid);
+//                    if ($pay['status'] === true)
+//                        return app('json')->status('success', 410197, $info);
+//                    else {
+//                        if (is_array($pay))
+//                            return app('json')->status($pay['status'], $pay['msg'], $info);
+//                        else
+//                            return app('json')->status('pay_error', $pay);
+//                    }
+//                case PayServices::ALIAPY_PAY:
+//                    if (!$quitUrl && ($request->isH5() || $request->isWechat())) {
+//                        return app('json')->status('pay_error', 410198, $info);
+//                    }
+//                    [$url, $param] = explode('?', $quitUrl);
+//                    $quitUrl = $url . '?order_id=' . $orderInfo['order_id'];
+//                    //支付金额为0
+//                    if (bcsub((string)$orderInfo['pay_price'], '0', 2) <= 0) {
+//                        //创建订单jspay支付
+//                        /** @var StoreOrderSuccessServices $success */
+//                        $success = app()->make(StoreOrderSuccessServices::class);
+//                        $payPriceStatus = $success->zeroYuanPayment($orderInfo, $uid, PayServices::ALIAPY_PAY);
+//                        if ($payPriceStatus)//0元支付成功
+//                            return app('json')->status('success', 410199, $info);
+//                        else
+//                            return app('json')->status('pay_error');
+//                    } else {
+//                        /** @var OrderPayServices $payServices */
+//                        $payServices = app()->make(OrderPayServices::class);
+//                        $info['jsConfig'] = $payServices->alipayOrder($orderInfo, $quitUrl, $from == 'routine');
+//                        $payKey = md5($orderInfo['order_id']);
+//                        CacheService::set($payKey, ['order_id' => $orderInfo['order_id'], 'other_pay_type' => false], 300);
+//                        $info['pay_key'] = $payKey;
+//                        return app('json')->status(PayServices::ALIAPY_PAY . '_pay', 410203, $info);
+//                    }
+//                case PayServices::OFFLINE_PAY:
+//                case 'pc':
+//                case 'friend':
+//                    return app('json')->status('success', 410203, $info);
+//                case PayServices::ALLIN_PAY:
+//                    /** @var OrderPayServices $payServices */
+//                    $payServices = app()->make(OrderPayServices::class);
+//                    $info['jsConfig'] = $payServices->orderPay($orderInfo, $payType, [
+//                        'returl' => sys_config('site_url') . '/pages/index/index',
+//                    ]);
+//                    if ($request->isWechat()) {
+//                        $info['pay_url'] = AllinPay::UNITODER_H5UNIONPAY;
+//                    }
+//                    return app('json')->status(PayServices::ALLIN_PAY . '_pay', 410203, $info);
+//            }
+//        } else return app('json')->fail(410200);
     }
 
     /**
@@ -372,6 +369,23 @@ class StoreOrderController
         return app('json')->success(['cateId' => implode(',', $cateId)]);
     }
 
+    /**
+     * @param $orderId
+     * @param string $type
+     * @return \think\Response
+     * @author 等风来
+     * @email 136327134@qq.com
+     * @date 2023/2/13
+     */
+    public function cashier(Request $request, $orderId, $type = 'order')
+    {
+        if (!$orderId) {
+            return app('json')->fail(100100);
+        }
+
+        return app('json')->success($this->services->getCashierInfo((int)$request->uid(), $orderId, $type));
+    }
+
     /**
      * 订单支付
      * @param Request $request
@@ -433,28 +447,20 @@ class StoreOrderController
                     break;
             }
         }
-        $order['pay_type'] = get_pay_type($paytype); //重新支付选择支付方式
-        switch ($order['pay_type']) {
-            case PayServices::WEIXIN_PAY:
-                $jsConfig = $payServices->orderPay($order->toArray(), $from);
-                if ($from == 'weixinh5') {
-                    return app('json')->status('wechat_h5_pay', ['jsConfig' => $jsConfig, 'order_id' => $order['order_id']]);
-                } elseif ($from == 'weixin' || $from == 'routine') {
-                    return app('json')->status('wechat_pay', ['jsConfig' => $jsConfig, 'order_id' => $order['order_id']]);
-                } elseif ($from == 'pc') {
-                    return app('json')->status('wechat_pc_pay', ['jsConfig' => $jsConfig, 'order_id' => $order['order_id']]);
-                }
-                break;
-            case PayServices::ALIAPY_PAY:
-                if (!$quitUrl && $from != 'routine') {
-                    return app('json')->fail(410198);
-                }
-                $isCode = $from == 'routine' || $from == 'pc';
-                $jsConfig = $payServices->alipayOrder($order->toArray(), $quitUrl, $isCode);
-                if ($isCode && !($jsConfig->invalid ?? false)) $jsConfig->invalid = time() + 60;
-                $payKey = md5($order['order_id']);
-                CacheService::set($payKey, ['order_id' => $order['order_id'], 'other_pay_type' => false], 300);
-                return app('json')->status(PayServices::ALIAPY_PAY . '_pay', 410203, ['jsConfig' => $jsConfig, 'order_id' => $order['order_id'], 'pay_key' => $payKey]);
+
+        //0元支付
+        if (bcsub((string)$orderInfo['pay_price'], '0', 2) <= 0) {
+            //创建订单jspay支付
+            /** @var StoreOrderSuccessServices $success */
+            $success = app()->make(StoreOrderSuccessServices::class);
+            $payPriceStatus = $success->zeroYuanPayment($orderInfo, $uid, $paytype);
+            if ($payPriceStatus)//0元支付成功
+                return app('json')->status('success', 410195, ['order_id' => $orderInfo['order_id'], 'key' => $orderInfo['unique ']]);
+            else
+                return app('json')->status('pay_error');
+        }
+
+        switch ($paytype) {
             case PayServices::YUE_PAY:
                 $pay = $yuePayServices->yueOrderPay($order->toArray(), $request->uid());
                 if ($pay['status'] === true)
@@ -470,18 +476,10 @@ class StoreOrderController
                     return app('json')->status('success', 410203);
                 else
                     return app('json')->status('success', 410216);
-            case PayServices::ALLIN_PAY:
-                /** @var OrderPayServices $payServices */
-                $payServices = app()->make(OrderPayServices::class);
-                $info['jsConfig'] = $payServices->orderPay($order->toArray(), $order['pay_type'], [
-                    'returl' => sys_config('site_url') . '/pages/index/index',
-                ]);
-                if ($request->isWechat()) {
-                    $info['pay_url'] = AllinPay::UNITODER_H5UNIONPAY;
-                }
-                return app('json')->status(PayServices::ALLIN_PAY . '_pay', 410203, $info);
+            default:
+                $payInfo = $payServices->beforePay($order->toArray(), $paytype, ['quitUrl' => $quitUrl]);
+                return app('json')->status($payInfo['status'], $payInfo['payInfo']);
         }
-        return app('json')->fail(410218);
     }
 
     /**

+ 5 - 4
crmeb/app/api/controller/v1/user/UserRechargeController.php

@@ -49,12 +49,13 @@ class UserRechargeController
         if (!in_array($type, [0, 1])) return app('json')->fail(410123);
         if (!in_array($from, [PayServices::WEIXIN_PAY, 'weixinh5', 'routine', PayServices::ALIAPY_PAY])) return app('json')->fail(410123);
         $storeMinRecharge = sys_config('store_user_min_recharge');
-        if ($price < $storeMinRecharge) return app('json')->fail(410124, null, ['money' => $storeMinRecharge]);
+        if (!$recharId && $price < $storeMinRecharge) return app('json')->fail(410124, null, ['money' => $storeMinRecharge]);
         $uid = (int)$request->uid();
-        $re = $this->services->recharge($uid, $price, $recharId, $type, $from);
+        $re = $this->services->recharge($uid, $price, $recharId, $type, $from, true);
         if ($re) {
-            unset($re['msg']);
-            return app('json')->success(410125, $re);
+            $payType = $re['pay_type'];
+            unset($re['pay_type']);
+            return app('json')->status($payType, 410125, $re);
         }
         return app('json')->fail(410126);
     }

+ 1 - 1
crmeb/app/api/controller/v1/wechat/AuthController.php

@@ -79,7 +79,7 @@ class AuthController
      */
     public function notify()
     {
-        $this->services->notify();
+        return $this->services->notify();
     }
 
     /**

+ 1 - 3
crmeb/app/api/route/v1.php

@@ -15,9 +15,6 @@ use think\facade\Config;
 use think\Response;
 
 Route::any('wechat/serve', 'v1.wechat.WechatController/serve');//公众号服务
-Route::any('wechat/notify', 'v1.wechat.WechatController/notify');//公众号支付回调
-Route::any('wechat/v3notify', 'v1.wechat.WechatController/v3notify');//公众号支付回调
-Route::any('routine/notify', 'v1.wechat.AuthController/notify');//小程序支付回调
 Route::any('pay/notify/:type', 'v1.PayController/notify');//支付回调
 Route::get('get_script', 'v1.PublicController/getScript');//获取统计代码
 Route::get('version', 'v1.PublicController/getVersion');//获取统计代码
@@ -166,6 +163,7 @@ Route::group(function () {
     Route::post('order/pay', 'v1.order.StoreOrderController/pay')->name('orderPay'); //订单支付
     Route::post('order/product', 'v1.order.StoreOrderController/product')->name('orderProduct'); //订单商品信息
     Route::post('order/comment', 'v1.order.StoreOrderController/comment')->name('orderComment'); //订单评价
+    Route::get('order/cashier/:orderId/[:type]', 'v1.order.StoreOrderController/cashier')->name('orderCashier'); //订单收银台
     //活动---砍价
     Route::get('bargain/detail/:id', 'v1.activity.StoreBargainController/detail')->name('bargainDetail');//砍价商品详情
     Route::post('bargain/start', 'v1.activity.StoreBargainController/start')->name('bargainStart');//砍价开启

+ 24 - 34
crmeb/app/common.php

@@ -23,38 +23,6 @@ use app\services\system\lang\LangCodeServices;
 use app\services\system\lang\LangCountryServices;
 use think\facade\Config;
 
-if (!function_exists('get_pay_type')) {
-
-    /**
-     * @param string $payType
-     * @return string
-     * @author 等风来
-     * @email 136327134@qq.com
-     * @date 2023/2/9
-     */
-    function get_pay_type(string $payType)
-    {
-//        $allinPay = (int)sys_config('allin_pay_status') == 1;
-//
-//        //微信支付没有开启,通联支付开启,用户访问端在小程序或者公众号的时候,使用通联微信H5支付
-//        if ($payType == PayServices::WEIXIN_PAY) {
-//            $wechat_pay_type = (int)sys_config('wechat_pay_type', 0);
-//            if ($wechat_pay_type == 1 && $allinPay && (request()->isRoutine() || request()->isWechat())) {
-//                $payType = PayServices::ALLIN_PAY;
-//            }
-//        }
-//
-//        //支付宝没有开启,通联支付开了,用户使用支付宝支付,并且在app端访问的时候,使用通联app支付宝支付
-//        if ($payType == PayServices::ALIAPY_PAY) {
-//            $alipay_pay_type = (int)sys_config('alipay_pay_type', 0);
-//            if ($alipay_pay_type == 1 && $allinPay && request()->isApp()) {
-//                $payType = PayServices::ALLIN_PAY;
-//            }
-//        }
-
-        return $payType;
-    }
-}
 
 if (!function_exists('is_wechat_pay')) {
     /**
@@ -65,7 +33,18 @@ if (!function_exists('is_wechat_pay')) {
      */
     function is_wecaht_pay()
     {
-        return (int)sys_config('pay_weixin_open') == 1;
+        $wechat_pay_type = (int)sys_config('wechat_pay_type', 0);
+        $wechatPay = (int)sys_config('pay_weixin_open') == 1;
+        $allinPay = (int)sys_config('allin_pay_status') == 1;
+
+        if ($wechat_pay_type == 0 && $wechatPay) {
+            return true;
+        } elseif ($wechat_pay_type == 1 && $allinPay) {
+            if ((request()->isRoutine() || request()->isWechat())) {
+                return true;
+            }
+        }
+        return false;
     }
 }
 
@@ -78,7 +57,18 @@ if (!function_exists('is_ali_pay')) {
      */
     function is_ali_pay()
     {
-        return (int)sys_config('ali_pay_status') == 1;
+        $alipay_pay_type = (int)sys_config('alipay_pay_type', 0);
+        $aliPay = (int)sys_config('ali_pay_status') == 1;
+        $allinPay = (int)sys_config('allin_pay_status') == 1;
+
+        if ($alipay_pay_type == 0 && $aliPay) {
+            return true;
+        } elseif ($alipay_pay_type == 1 && $allinPay) {
+            if (request()->isApp()) {
+                return true;
+            }
+        }
+        return false;
     }
 }
 

+ 32 - 3
crmeb/app/dao/system/config/SystemStorageDao.php

@@ -14,7 +14,6 @@ namespace app\dao\system\config;
 
 use app\dao\BaseDao;
 use app\model\system\config\SystemStorage;
-use crmeb\traits\SearchDaoTrait;
 
 /**
  * Class SystemStorageDao
@@ -23,8 +22,6 @@ use crmeb\traits\SearchDaoTrait;
 class SystemStorageDao extends BaseDao
 {
 
-    use SearchDaoTrait;
-
     /**
      * @return string
      */
@@ -33,6 +30,38 @@ class SystemStorageDao extends BaseDao
         return SystemStorage::class;
     }
 
+    /**
+     * 获取列表
+     * @param array $where
+     * @param array|string[] $field
+     * @param int $page
+     * @param int $limit
+     * @param null $sort
+     * @param array $with
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public function getList(array $where = [], array $field = ['*'], int $page = 0, int $limit = 0, $sort = null, array $with = [])
+    {
+        return $this->search($where)->field($field)->when($page && $limit, function ($query) use ($page, $limit) {
+            $query->page($page, $limit);
+        })->when($sort, function ($query) use ($sort) {
+            if (is_array($sort)) {
+                foreach ($sort as $v => $k) {
+                    if (is_numeric($v)) {
+                        $query->order($k, 'desc');
+                    } else {
+                        $query->order($v, $k);
+                    }
+                }
+            } else {
+                $query->order($sort, 'desc');
+            }
+        })->with($with)->select()->toArray();
+    }
+
     /**
      * @param array $where
      * @return \crmeb\basic\BaseModel|mixed|\think\Model

+ 3 - 2
crmeb/app/listener/order/OrderPaySuccess.php

@@ -14,6 +14,7 @@ use app\services\order\StoreOrderDeliveryServices;
 use app\services\order\StoreOrderInvoiceServices;
 use app\services\order\StoreOrderServices;
 use app\services\order\StoreOrderStatusServices;
+use app\services\pay\PayServices;
 use app\services\product\product\StoreProductCouponServices;
 use app\services\product\sku\StoreProductAttrValueServices;
 use app\services\product\sku\StoreProductVirtualServices;
@@ -63,14 +64,14 @@ class OrderPaySuccess implements ListenerInterface
         $orderInvoiceServices->update(['order_id' => $orderInfo['id']], ['is_pay' => 1]);
 
         //虚拟商品自动发货
-        if($orderInfo['virtual_type'] > 0){
+        if ($orderInfo['virtual_type'] > 0) {
             /** @var StoreOrderDeliveryServices $orderDeliveryServices */
             $orderDeliveryServices = app()->make(StoreOrderDeliveryServices::class);
             $orderDeliveryServices->virtualSend($orderInfo);
         }
 
         // 写入资金流水
-        if ($orderInfo['pay_type'] == 'weixin' || $orderInfo['pay_type'] == 'alipay') {
+        if ($orderInfo['pay_type'] == 'weixin' || $orderInfo['pay_type'] == 'alipay' || $orderInfo['pay_type'] == PayServices::ALLIN_PAY) {
             /** @var UserServices $userServices */
             $userServices = app()->make(UserServices::class);
             $userInfo = $userServices->get($orderInfo['uid']);

+ 3 - 4
crmeb/app/listener/pay/Notify.php

@@ -30,17 +30,16 @@ class Notify
      */
     public function handle($event)
     {
-        [$notify] = $event;
+        [$notify, $payType] = $event;
 
         if (isset($notify['attach']) && $notify['attach']) {
             if (($count = strpos($notify['out_trade_no'], '_')) !== false) {
                 $notify['out_trade_no'] = substr($notify['out_trade_no'], $count + 1);
             }
-            return (new Hook(PayNotifyServices::class, 'wechat'))->listen($notify['attach'], $notify['out_trade_no'], $notify['transaction_id']);
+            return (new Hook(PayNotifyServices::class, 'wechat'))->listen($notify['attach'], $notify['out_trade_no'], $notify['transaction_id'], $payType);
         }
 
-        if($notify['attach'] === 'wechat' && isset($notify['out_trade_no']))
-        {
+        if ($notify['attach'] === 'wechat' && isset($notify['out_trade_no'])) {
             /** @var WechatMessageServices $wechatMessageService */
             $wechatMessageService = app()->make(WechatMessageServices::class);
             $wechatMessageService->setOnceMessage($notify, $notify['openid'], 'payment_success', $notify['out_trade_no']);

+ 29 - 3
crmeb/app/services/BaseServices.php

@@ -11,27 +11,53 @@
 
 namespace app\services;
 
-use crmeb\traits\ServicesTrait;
 use crmeb\utils\JwtAuth;
 use think\facade\Db;
 use think\facade\Config;
 use think\facade\Route as Url;
+use think\Model;
 
 /**
  * Class BaseServices
  * @package app\services
+ * @method array|Model|null get($id, ?array $field = []) 获取一条数据
+ * @method array|Model|null getOne(array $where, ?string $field = '*') 获取一条数据(不走搜素器)
+ * @method string|null batchUpdate(array $ids, array $data, ?string $key = null) 批量修改
+ * @method float sum(array $where, string $field, bool $search = false) 求和
+ * @method mixed update($id, array $data, ?string $field = '') 修改数据
+ * @method bool be($map, string $field = '') 查询一条数据是否存在
+ * @method mixed value(array $where, string $field) 获取指定条件下的数据
+ * @method int count(array $where = []) 读取数据条数
+ * @method int getCount(array $where = []) 获取某些条件总数(不走搜素器)
+ * @method array getColumn(array $where, string $field, string $key = '') 获取某个字段数组(不走搜素器)
+ * @method mixed delete($id, ?string $key = null) 删除
+ * @method mixed save(array $data) 保存数据
+ * @method mixed saveAll(array $data) 批量保存数据
+ * @method bool bcInc($key, string $incField, string $inc, string $keyField = null, int $acc = 2) 高精度加法
+ * @method bool bcDec($key, string $decField, string $dec, string $keyField = null, int $acc = 2) 高精度 减法
+ * @method mixed decStockIncSales(array $where, int $num, string $stock = 'stock', string $sales = 'sales') 减库存加销量
+ * @method mixed incStockDecSales(array $where, int $num, string $stock = 'stock', string $sales = 'sales') 加库存减销量
  */
 abstract class BaseServices
 {
 
-    use ServicesTrait;
-
     /**
      * 模型注入
      * @var object
      */
     protected $dao;
 
+    /**
+     * @return \crmeb\utils\Cache
+     * @author 等风来
+     * @email 136327134@qq.com
+     * @date 2023/2/8
+     */
+    public function cacheDriver()
+    {
+        return new \crmeb\utils\Cache($this->dao->getTableName());
+    }
+
     /**
      * 获取分页配置
      * @param bool $isPage

+ 2 - 2
crmeb/app/services/agent/AgentLevelServices.php

@@ -328,11 +328,11 @@ class AgentLevelServices extends BaseServices
     {
         /** @var UserServices $userServices */
         $userServices = app()->make(UserServices::class);
-        $userInfo = $userServices->getUserInfo($uid);
+        $userInfo = $userServices->getUserInfo($uid, 'uid');
         if (!$userInfo) {
             throw new AdminException(400214);
         }
-        $levelInfo = $this->getLevelInfo($id);
+        $levelInfo = $this->getLevelInfo($id, 'id');
         if (!$levelInfo) {
             throw new AdminException(400442);
         }

+ 2 - 2
crmeb/app/services/agent/AgentManageServices.php

@@ -66,7 +66,7 @@ class AgentManageServices extends BaseServices
                 $item['new_money'] = bcsub((string)$item['brokerage_price'], (string)$item['broken_commission'], 2);
             else
                 $item['new_money'] = 0;
-            $item['brokerage_money'] = $item['brokerage_price'];
+            $item['brokerage_money'] = bcadd((string)$item['brokerage_price'], (string)$item['extract_count_price'], 2);
             unset($item['extract'], $item['order'], $item['bill'], $item['spreadUser'], $item['spreadCount']);
             if (strpos($item['headimgurl'], '/statics/system_images/') !== false) {
                 $item['headimgurl'] = set_file_url($item['headimgurl']);
@@ -373,7 +373,7 @@ class AgentManageServices extends BaseServices
     {
         /** @var UserServices $userServices */
         $userServices = app()->make(UserServices::class);
-        if (!$userServices->getUserInfo($uid)) {
+        if (!$userServices->getUserInfo($uid, 'uid')) {
             throw new AdminException(100026);
         }
         if ($userServices->update($uid, ['spread_open' => 0]) !== false)

+ 6 - 8
crmeb/app/services/message/SystemNotificationServices.php

@@ -86,14 +86,12 @@ class SystemNotificationServices extends BaseServices
                 $info['content'] = $info['sms_text'];
                 break;
             case 'is_wechat':
-                $wechat = $TemplateMessageServices->getOne(['id' => $info['wechat_id'], 'type' => 1]);
-                $info['templage_message_id'] = $wechat['id'] ?? '';
-                $info['tempkey'] = $wechat['tempkey'] ?? '';
-                $info['tempid'] = $wechat['tempid'] ?? '';
-                $info['content'] = $wechat['content'] ?? '';
-                break;
             case 'is_routine':
-                $wechat = $TemplateMessageServices->getOne(['id' => $info['routine_id'], 'type' => 0]);
+                if ('is_wechat' === $type) {
+                    $wechat = $TemplateMessageServices->getOne(['id' => $info['wechat_id'], 'type' => 1]);
+                } else {
+                    $wechat = $TemplateMessageServices->getOne(['id' => $info['routine_id'], 'type' => 0]);
+                }
                 $info['templage_message_id'] = $wechat['id'] ?? '';
                 $info['tempkey'] = $wechat['tempkey'] ?? '';
                 $info['tempid'] = $wechat['tempid'] ?? '';
@@ -115,7 +113,7 @@ class SystemNotificationServices extends BaseServices
     {
         $type = $data['type'];
         $id = $data['id'];
-        $info = $this->dao->get($id);
+        $info = $this->dao->get($id, 'id');
         if (!$info) {
             throw new AdminException(100026);
         }

+ 124 - 143
crmeb/app/services/message/wechat/MessageServices.php

@@ -59,150 +59,131 @@ class MessageServices extends BaseServices
                 $is_new = $wechatUser->saveUser($message->FromUserName);
                 $uid = $wechatUser->getFieldValue($message->FromUserName, 'openid', 'uid', ['user_type', '<>', 'h5']);
                 $userInfo = $userService->get($uid);
-                if (strtolower($thirdType[0]) == 'spread') {
-                    try {
-                        if ($spreadUid == $uid) {
-                            $response = '自己不能推荐自己';
-                        } else if (!$userInfo) {
-                            $response = '用户不存在';
-                        } else if (!$spreadInfo) {
-                            $response = '上级用户不存在';
-                        } else if ($userInfo['spread_uid']) {
-                            $response = '已有推荐人!';
-                        } else if (!$loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new)) {
-                            $response = '绑定推荐人失败!';
-                        }
-                        $wechatNews['title'] = sys_config('site_name');
-                        $wechatNews['image'] = sys_config('wap_login_logo');
-                        $wechatNews['url'] = $baseUrl . '/pages/index/index';
-                        $loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
-                        $messages = WechatService::newsMessage($wechatNews);
-                        WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
-                    } catch (\Exception $e) {
-                        $response = $e->getMessage();
-                    }
-                } elseif (strtolower($thirdType[0]) == 'agent') {
-                    try {
-                        if ($spreadUid == $uid) {
-                            $response = '自己不能推荐自己';
-                        } else if (!$userInfo) {
-                            $response = '用户不存在';
-                        } else if (!$spreadInfo) {
-                            $response = '上级用户不存在';
-                        } else if ($userInfo->is_division) {
-                            $response = '您是事业部,不能绑定成为别人的员工';
-                        } else if ($userInfo->is_agent) {
-                            $response = '您是代理商,不能绑定成为别人的员工';
-                        } else if ($loginService->updateUserInfo(['code' => $spreadUid, 'is_staff' => 1], $userInfo, $is_new)) {
-                            $response = '绑定店员成功!';
-                        }
-                    } catch (\Exception $e) {
-                        $response = $e->getMessage();
-                    }
-                } elseif (strtolower($thirdType[0]) == 'wechatqrcode') {
-                    /** @var WechatQrcodeServices $wechatQrcodeService */
-                    $wechatQrcodeService = app()->make(WechatQrcodeServices::class);
-                    try {
-                        //wechatqrcode类型的二维码数据中,third_id为渠道码的id
-                        $qrcodeInfo = $wechatQrcodeService->qrcodeInfo($qrInfo['third_id']);
-                        $spreadUid = $qrcodeInfo['uid'];
-                        $spreadInfo = $userService->get($spreadUid);
-                        $is_new = $wechatUser->saveUser($message->FromUserName);
-                        $uid = $wechatUser->getFieldValue($message->FromUserName, 'openid', 'uid', ['user_type', '<>', 'h5']);
-                        $userInfo = $userService->get($uid);
-                        if ($qrcodeInfo['status'] == 0 || $qrcodeInfo['is_del'] == 1 || ($qrcodeInfo['end_time'] < time() && $qrcodeInfo['end_time'] > 0)) {
-                            $response = '二维码已失效';
-                        } else if ($spreadUid == $uid) {
-                            $response = '自己不能推荐自己';
-                        } else if (!$userInfo) {
-                            $response = '用户不存在';
-                        } else if (!$spreadInfo) {
-                            $response = '上级用户不存在';
-                        } else if ($loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new)) {
-                            //写入扫码记录,返回内容
-                            $response = $wechatQrcodeService->wechatQrcodeRecord($qrcodeInfo, $userInfo, $spreadInfo);
-                        }
-                    } catch (\Exception $e) {
-                        $response = $e->getMessage();
-                    }
-                } elseif (strtolower($thirdType[0]) == 'product') {
-                    try {
-                        /** @var StoreProductServices $productService */
-                        $productService = app()->make(StoreProductServices::class);
-                        $productInfo = $productService->get($thirdType[1] ?? 0);
-                        $wechatNews['title'] = $productInfo->store_name;
-                        $wechatNews['image'] = $productInfo->image;
-                        $wechatNews['description'] = $productInfo->store_info;
-                        $wechatNews['url'] = $baseUrl . '/pages/goods_details/index?id=' . $thirdType[1];
-                        $loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
-                        $messages = WechatService::newsMessage($wechatNews);
-                        WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
-                    } catch (\Exception $e) {
-                        $response = $e->getMessage();
-                    }
-                } elseif (strtolower($thirdType[0]) == 'combination') {
-                    try {
-                        /** @var StoreCombinationServices $combinationService */
-                        $combinationService = app()->make(StoreCombinationServices::class);
-                        $productInfo = $combinationService->get($thirdType[1] ?? 0);
-                        $wechatNews['title'] = $productInfo->title;
-                        $wechatNews['image'] = $productInfo->image;
-                        $wechatNews['description'] = $productInfo->info;
-                        $wechatNews['url'] = $baseUrl . '/pages/activity/goods_combination_details/index?id=' . $thirdType[1];
-                        $loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
-                        $messages = WechatService::newsMessage($wechatNews);
-                        WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
-                    } catch (\Exception $e) {
-                        $response = $e->getMessage();
-                    }
-                } elseif (strtolower($thirdType[0]) == 'seckill') {
-                    try {
-                        /** @var StoreSeckillServices $seckillService */
-                        $seckillService = app()->make(StoreSeckillServices::class);
-                        $productInfo = $seckillService->get($thirdType[1] ?? 0);
-                        $wechatNews['title'] = $productInfo->title;
-                        $wechatNews['image'] = $productInfo->image;
-                        $wechatNews['description'] = $productInfo->info;
-                        $wechatNews['url'] = $baseUrl . '/pages/activity/goods_seckill_details/index?id=' . $thirdType[1];
-                        $loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
-                        $messages = WechatService::newsMessage($wechatNews);
-                        WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
-                    } catch (\Exception $e) {
-                        $response = $e->getMessage();
-                    }
-                } elseif (strtolower($thirdType[0]) == 'bargain') {
-                    try {
-                        /** @var StoreBargainServices $bargainService */
-                        $bargainService = app()->make(StoreBargainServices::class);
-                        $productInfo = $bargainService->get($thirdType[1] ?? 0);
-                        $wechatNews['title'] = $productInfo->title;
-                        $wechatNews['image'] = $productInfo->image;
-                        $wechatNews['description'] = $productInfo->info;
-                        $wechatNews['url'] = $baseUrl . '/pages/activity/goods_bargain_details/index?id=' . $thirdType[1] . '&bargain=' . $thirdType[2];
-                        $loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
-                        $messages = WechatService::newsMessage($wechatNews);
-                        WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
-                    } catch (\Exception $e) {
-                        $response = $e->getMessage();
-                    }
-                } elseif (strtolower($thirdType[0]) == 'pink') {
-                    try {
-                        /** @var StorePinkServices $pinkService */
-                        $pinkService = app()->make(StorePinkServices::class);
-                        /** @var StoreCombinationServices $combinationService */
-                        $combinationService = app()->make(StoreCombinationServices::class);
-                        $pinktInfo = $pinkService->get($thirdType[1]);
-                        $productInfo = $combinationService->get($pinktInfo->cid);
-                        $wechatNews['title'] = $productInfo->title;
-                        $wechatNews['image'] = $productInfo->image;
-                        $wechatNews['description'] = $productInfo->info;
-                        $wechatNews['url'] = $baseUrl . '/pages/activity/goods_combination_status/index?id=' . $thirdType[1];
-                        $loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
-                        $messages = WechatService::newsMessage($wechatNews);
-                        WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
-                    } catch (\Exception $e) {
-                        $response = $e->getMessage();
+                try {
+                    switch (strtolower($thirdType[0])) {
+                        case 'spread':
+                            if ($spreadUid == $uid) {
+                                $response = '自己不能推荐自己';
+                            } else if (!$userInfo) {
+                                $response = '用户不存在';
+                            } else if (!$spreadInfo) {
+                                $response = '上级用户不存在';
+                            } else if ($userInfo['spread_uid']) {
+                                $response = '已有推荐人!';
+                            } else if (!$loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new)) {
+                                $response = '绑定推荐人失败!';
+                            }
+                            $wechatNews['title'] = sys_config('site_name');
+                            $wechatNews['image'] = sys_config('wap_login_logo');
+                            $wechatNews['url'] = $baseUrl . '/pages/index/index';
+                            $loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
+                            $messages = WechatService::newsMessage($wechatNews);
+                            WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
+                            break;
+                        case 'agent':
+                            if ($spreadUid == $uid) {
+                                $response = '自己不能推荐自己';
+                            } else if (!$userInfo) {
+                                $response = '用户不存在';
+                            } else if (!$spreadInfo) {
+                                $response = '上级用户不存在';
+                            } else if ($userInfo->is_division) {
+                                $response = '您是事业部,不能绑定成为别人的员工';
+                            } else if ($userInfo->is_agent) {
+                                $response = '您是代理商,不能绑定成为别人的员工';
+                            } else if ($loginService->updateUserInfo(['code' => $spreadUid, 'is_staff' => 1], $userInfo, $is_new)) {
+                                $response = '绑定店员成功!';
+                            }
+                            break;
+                        case 'wechatqrcode':
+                            /** @var WechatQrcodeServices $wechatQrcodeService */
+                            $wechatQrcodeService = app()->make(WechatQrcodeServices::class);
+                            //wechatqrcode类型的二维码数据中,third_id为渠道码的id
+                            $qrcodeInfo = $wechatQrcodeService->qrcodeInfo($qrInfo['third_id']);
+                            $spreadUid = $qrcodeInfo['uid'];
+                            $spreadInfo = $userService->get($spreadUid);
+                            $is_new = $wechatUser->saveUser($message->FromUserName);
+                            $uid = $wechatUser->getFieldValue($message->FromUserName, 'openid', 'uid', ['user_type', '<>', 'h5']);
+                            $userInfo = $userService->get($uid);
+                            if ($qrcodeInfo['status'] == 0 || $qrcodeInfo['is_del'] == 1 || ($qrcodeInfo['end_time'] < time() && $qrcodeInfo['end_time'] > 0)) {
+                                $response = '二维码已失效';
+                            } else if ($spreadUid == $uid) {
+                                $response = '自己不能推荐自己';
+                            } else if (!$userInfo) {
+                                $response = '用户不存在';
+                            } else if (!$spreadInfo) {
+                                $response = '上级用户不存在';
+                            } else if ($loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new)) {
+                                //写入扫码记录,返回内容
+                                $response = $wechatQrcodeService->wechatQrcodeRecord($qrcodeInfo, $userInfo, $spreadInfo);
+                            }
+                            break;
+                        case 'product':
+                            /** @var StoreProductServices $productService */
+                            $productService = app()->make(StoreProductServices::class);
+                            $productInfo = $productService->get($thirdType[1] ?? 0);
+                            $wechatNews['title'] = $productInfo->store_name;
+                            $wechatNews['image'] = $productInfo->image;
+                            $wechatNews['description'] = $productInfo->store_info;
+                            $wechatNews['url'] = $baseUrl . '/pages/goods_details/index?id=' . $thirdType[1];
+                            $loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
+                            $messages = WechatService::newsMessage($wechatNews);
+                            WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
+                            break;
+                        case 'combination':
+                            /** @var StoreCombinationServices $combinationService */
+                            $combinationService = app()->make(StoreCombinationServices::class);
+                            $productInfo = $combinationService->get($thirdType[1] ?? 0);
+                            $wechatNews['title'] = $productInfo->title;
+                            $wechatNews['image'] = $productInfo->image;
+                            $wechatNews['description'] = $productInfo->info;
+                            $wechatNews['url'] = $baseUrl . '/pages/activity/goods_combination_details/index?id=' . $thirdType[1];
+                            $loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
+                            $messages = WechatService::newsMessage($wechatNews);
+                            WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
+                            break;
+                        case 'seckill':
+                            /** @var StoreSeckillServices $seckillService */
+                            $seckillService = app()->make(StoreSeckillServices::class);
+                            $productInfo = $seckillService->get($thirdType[1] ?? 0);
+                            $wechatNews['title'] = $productInfo->title;
+                            $wechatNews['image'] = $productInfo->image;
+                            $wechatNews['description'] = $productInfo->info;
+                            $wechatNews['url'] = $baseUrl . '/pages/activity/goods_seckill_details/index?id=' . $thirdType[1];
+                            $loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
+                            $messages = WechatService::newsMessage($wechatNews);
+                            WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
+                            break;
+                        case 'bargain':
+                            /** @var StoreBargainServices $bargainService */
+                            $bargainService = app()->make(StoreBargainServices::class);
+                            $productInfo = $bargainService->get($thirdType[1] ?? 0);
+                            $wechatNews['title'] = $productInfo->title;
+                            $wechatNews['image'] = $productInfo->image;
+                            $wechatNews['description'] = $productInfo->info;
+                            $wechatNews['url'] = $baseUrl . '/pages/activity/goods_bargain_details/index?id=' . $thirdType[1] . '&bargain=' . $thirdType[2];
+                            $loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
+                            $messages = WechatService::newsMessage($wechatNews);
+                            WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
+                            break;
+                        case 'pink':
+                            /** @var StorePinkServices $pinkService */
+                            $pinkService = app()->make(StorePinkServices::class);
+                            /** @var StoreCombinationServices $combinationService */
+                            $combinationService = app()->make(StoreCombinationServices::class);
+                            $pinktInfo = $pinkService->get($thirdType[1]);
+                            $productInfo = $combinationService->get($pinktInfo->cid);
+                            $wechatNews['title'] = $productInfo->title;
+                            $wechatNews['image'] = $productInfo->image;
+                            $wechatNews['description'] = $productInfo->info;
+                            $wechatNews['url'] = $baseUrl . '/pages/activity/goods_combination_status/index?id=' . $thirdType[1];
+                            $loginService->updateUserInfo(['code' => $spreadUid], $userInfo, $is_new);
+                            $messages = WechatService::newsMessage($wechatNews);
+                            WechatService::staffService()->message($messages)->to($message->FromUserName)->send();
+                            break;
                     }
+                } catch (\Throwable $e) {
+                    $response = $e->getMessage();
                 }
             } else {
                 //扫码不生成用户流程

+ 8 - 1
crmeb/app/services/order/StoreCartServices.php

@@ -444,7 +444,7 @@ class StoreCartServices extends BaseServices
         /** @var StoreProductServices $productServices */
         $productServices = app()->make(StoreProductServices::class);
 
-        if (!$productServices->isValidProduct((int)$productId)) {
+        if (!$productServices->isValidProduct((int)$productId, 'id')) {
             throw new ApiException(410295);
         }
         if (!($unique && $attrValueServices->getAttrvalueCount($productId, $unique, 0))) {
@@ -540,7 +540,14 @@ class StoreCartServices extends BaseServices
      * @param int $uid
      * @param array $cartList
      * @param array $addr
+     * @param int $shipping_type
      * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 吴汐
+     * @email 442384644@qq.com
+     * @date 2023/02/16
      */
     public function handleCartList(int $uid, array $cartList, array $addr = [], int $shipping_type = 1)
     {

+ 4 - 3
crmeb/app/services/order/StoreOrderCreateServices.php

@@ -64,7 +64,7 @@ class StoreOrderCreateServices extends BaseServices
         $snowflake = new \Godruoyi\Snowflake\Snowflake();
 
         if (Config::get('cache.default') == 'file') {
-            //32位 
+            //32位
             if (PHP_INT_SIZE == 4) {
                 $id = abs($snowflake->id());
             } else {
@@ -768,8 +768,8 @@ class StoreOrderCreateServices extends BaseServices
 
                 //指定返佣金额
                 if (isset($productInfo['is_sub']) && $productInfo['is_sub'] == 1) {
-                    $oneBrokerage = $storeBrokerageRatio > 0 ? bcmul((string)($productInfo['attrInfo']['brokerage'] ?? '0'), $cartNum, 2) : 0;
-                    $twoBrokerage = $storeBrokerageTwo > 0 ? bcmul((string)($productInfo['attrInfo']['brokerage_two'] ?? '0'), $cartNum, 2) : 0;
+                    $oneBrokerage = bcmul((string)($productInfo['attrInfo']['brokerage'] ?? '0'), $cartNum, 2);
+                    $twoBrokerage = bcmul((string)($productInfo['attrInfo']['brokerage_two'] ?? '0'), $cartNum, 2);
                 } else {
                     if ($price) {
                         //一级返佣比例 小于等于零时直接返回 不返佣
@@ -794,6 +794,7 @@ class StoreOrderCreateServices extends BaseServices
             $cart['agent_brokerage'] = $agentBrokerage;
             $cart['division_brokerage'] = $divisionBrokerage;
         }
+
         return [$cartInfo, [$spread_one_uid, $spread_two_uid]];
     }
 }

+ 8 - 2
crmeb/app/services/order/StoreOrderRefundServices.php

@@ -274,10 +274,10 @@ class StoreOrderRefundServices extends BaseServices
 
             return $splitOrderInfo;
         });
+        //处理开票
+        app()->make(StoreOrderInvoiceServices::class)->update(['order_id' => $order['id']], ['is_refund' => 1]);
         //订单退款记录
         ProductLogJob::dispatch(['refund', ['uid' => $order['uid'], 'order_id' => $order['id']]]);
-        //订单同意退款事件
-        event('order.refund', [$refundData, $order, 'order_refund']);
         event('notice.notice', [['data' => $refundData, 'order' => $order], 'order_refund']);
         return true;
     }
@@ -286,6 +286,12 @@ class StoreOrderRefundServices extends BaseServices
      * 商家同意用户退货
      * @param $id
      * @return bool
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 吴汐
+     * @email 442384644@qq.com
+     * @date 2023/02/16
      */
     public function agreeExpress($id)
     {

+ 83 - 3
crmeb/app/services/order/StoreOrderServices.php

@@ -23,6 +23,7 @@ use app\services\product\product\StoreProductLogServices;
 use app\services\system\attachment\SystemAttachmentServices;
 use app\services\system\store\SystemStoreServices;
 use app\services\user\UserInvoiceServices;
+use app\services\user\UserRechargeServices;
 use app\services\user\UserServices;
 use app\services\product\product\StoreProductReplyServices;
 use app\services\user\UserAddressServices;
@@ -31,6 +32,7 @@ use app\services\user\UserLevelServices;
 use app\services\wechat\WechatUserServices;
 use crmeb\exceptions\AdminException;
 use crmeb\exceptions\ApiException;
+use crmeb\exceptions\PayException;
 use crmeb\services\CacheService;
 use crmeb\services\FormBuilder as Form;
 use crmeb\services\printer\Printer;
@@ -497,6 +499,9 @@ class StoreOrderServices extends BaseServices
                     case PayServices::ALIAPY_PAY:
                         $item['pay_type_name'] = '支付宝支付';
                         break;
+                    case PayServices::ALLIN_PAY:
+                        $item['pay_type_name'] = '通联支付';
+                        break;
                     default:
                         $item['pay_type_name'] = '其他支付';
                         break;
@@ -1856,7 +1861,7 @@ HTML;
     {
         /** @var UserServices $userServices */
         $userServices = app()->make(UserServices::class);
-        $user = $userServices->getUserInfo($uid);
+        $user = $userServices->getUserInfo($uid, 'uid');
         if (!$user) {
             throw new AdminException(100026);
         }
@@ -2290,7 +2295,7 @@ HTML;
         if (!$orderInfo) {
             throw new ApiException(410264);
         }
-        return $payServices->alipayOrder($orderInfo->toArray(), $quitUrl);
+        return $payServices->beforePay($orderInfo->toArray(), PayServices::ALIAPY_PAY, ['quitUrl' => $quitUrl]);
     }
 
     /**
@@ -2392,7 +2397,7 @@ HTML;
         if ($orderData['uid'] != $orderData['pay_uid']) {
             /** @var UserServices $userServices */
             $userServices = app()->make(UserServices::class);
-            $payUser = $userServices->get($orderData['pay_uid']);
+            $payUser = $userServices->get($orderData['pay_uid'], ['nickname', 'avatar']);
             $orderData['help_info'] = [
                 'pay_uid' => $orderData['pay_uid'],
                 'pay_nickname' => $payUser['nickname'],
@@ -2472,4 +2477,79 @@ HTML;
         }
         return true;
     }
+
+    /**
+     * @param string $orderId
+     * @param string $type
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author 等风来
+     * @email 136327134@qq.com
+     * @date 2023/2/13
+     */
+    public function getCashierInfo(int $uid, string $orderId, string $type)
+    {
+        //支付类型开关
+        $data = [
+            'ali_pay_status' => is_ali_pay(),
+            'wechat_pay_status' => is_wecaht_pay(),
+            'offline_pay_status' => (int)sys_config('offline_pay_status') == 1,
+            'friend_pay_status' => (int)sys_config('friend_pay_status') == 1,
+            'yue_pay_status' => (int)sys_config('balance_func_status') && (int)sys_config('yue_pay_status') == 1,
+        ];
+
+        $data['order_id'] = $orderId;
+        $data['pay_price'] = '0';
+        $data['now_money'] = app()->make(UserServices::class)->value(['uid' => $uid], 'now_money');
+
+        switch ($type) {
+            case 'order':
+                $info = $this->dao->get(['order_id' => $orderId], ['pay_price', 'add_time', 'combination_id', 'seckill_id', 'bargain_id']);
+                if (!$info) {
+                    throw new PayException('您支付的订单不存在');
+                }
+                $orderCancelTime = (int)sys_config('order_cancel_time', 0);
+                $orderActivityTime = (int)sys_config('order_activity_time', 0);
+                if ($info->combination_id) {
+                    $time = ((int)sys_config('order_pink_time', 0) ?: $orderActivityTime) * 60 * 60 + ((int)$info->add_time);
+                } else if ($info->seckill_id) {
+                    $time = ((int)sys_config('order_seckill_time', 0) ?: $orderActivityTime) * 60 * 60 + ((int)$info->add_time);
+                } else if ($info->bargain_id) {
+                    $time = ((int)sys_config('order_bargain_time', 0) ?: $orderActivityTime) * 60 * 60 + ((int)$info->add_time);
+                } else {
+                    $time = $orderCancelTime * 60 * 60 + ((int)$info->add_time);
+                }
+
+                if ($time < 0) {
+                    $time = 0;
+                }
+
+                $data['pay_price'] = $info['pay_price'];
+                $data['invalid_time'] = $time;
+
+                break;
+            case 'svip':
+                $info = app()->make(OtherOrderServices::class)->get(['order_id' => $orderId], ['pay_price', 'add_time']);
+                if (!$info) {
+                    throw new PayException('您支付的订单不存在');
+                }
+                $data['pay_price'] = $info['pay_price'];
+                $data['invalid_time'] = $info->add_time + 86400;
+                break;
+            case 'recharge':
+                $info = app()->make(UserRechargeServices::class)->get(['order_id' => $orderId], ['price', 'add_time']);
+                if (!$info) {
+                    throw new PayException('您支付的订单不存在');
+                }
+                $data['pay_price'] = $info['price'];
+                $data['invalid_time'] = $info->add_time + 86400;
+                break;
+            default:
+                throw new PayException('暂不支持其他类型订单支付');
+        }
+
+        return $data;
+    }
 }

+ 1 - 0
crmeb/app/services/order/StoreOrderSuccessServices.php

@@ -69,6 +69,7 @@ class StoreOrderSuccessServices extends BaseServices
     {
         $updata = ['paid' => 1, 'pay_type' => $paytype, 'pay_time' => time()];
         $orderInfo['pay_time'] = $updata['pay_time'];
+        $orderInfo['pay_type'] = $paytype;
         if ($other && isset($other['trade_no'])) {
             $updata['trade_no'] = $other['trade_no'];
         }

+ 126 - 51
crmeb/app/services/pay/OrderPayServices.php

@@ -17,7 +17,10 @@ use app\services\order\StoreOrderCartInfoServices;
 use app\services\order\StoreOrderServices;
 use app\services\wechat\WechatUserServices;
 use crmeb\exceptions\ApiException;
+use crmeb\services\CacheService;
+use crmeb\services\pay\extend\allinpay\AllinPay;
 use crmeb\utils\Str;
+use think\exception\ValidateException;
 
 /**
  * 订单发起支付
@@ -38,16 +41,81 @@ class OrderPayServices
     }
 
     /**
-     * 订单发起支付
+     * 获取支付方式
+     * @param string $payType
+     * @return string
+     * @author 等风来
+     * @email 136327134@qq.com
+     * @date 2023/2/15
+     */
+    public function getPayType(string $payType)
+    {
+        $allinPay = (int)sys_config('allin_pay_status') == 1;
+
+        //微信支付没有开启,通联支付开启,用户访问端在小程序或者公众号的时候,使用通联微信H5支付
+        if ($payType == PayServices::WEIXIN_PAY) {
+            $wechat_pay_type = (int)sys_config('wechat_pay_type', 0);
+            if ($wechat_pay_type == 1 && $allinPay && (request()->isRoutine() || request()->isWechat())) {
+                $payType = PayServices::ALLIN_PAY;
+            }
+        }
+
+        //支付宝没有开启,通联支付开了,用户使用支付宝支付,并且在app端访问的时候,使用通联app支付宝支付
+        if ($payType == PayServices::ALIAPY_PAY) {
+            $alipay_pay_type = (int)sys_config('alipay_pay_type', 0);
+            if ($alipay_pay_type == 1 && $allinPay && request()->isApp()) {
+                $payType = PayServices::ALLIN_PAY;
+            }
+        }
+
+        return $payType;
+    }
+
+    /**
+     * 获取返回类型
+     * @param string $payType
+     * @return string
+     * @author 等风来
+     * @email 136327134@qq.com
+     * @date 2023/2/15
+     */
+    public function payStatus(string $payType)
+    {
+        if ($payType == PayServices::WEIXIN_PAY) {
+            if (request()->isH5()) {
+                $payStstus = 'wechat_h5_pay';
+            } else if (request()->isPc()) {
+                $payStstus = 'wechat_pc_pay';
+            } else {
+                $payStstus = 'wechat_pay';
+            }
+        } else if ($payType == PayServices::ALIAPY_PAY) {
+            $payStstus = 'alipay_pay';
+        } else if ($payType == PayServices::ALLIN_PAY) {
+            $payStstus = 'allinpay_pay';
+        } else {
+            throw new ValidateException('获取支付返回类型失败');
+        }
+        return $payStstus;
+    }
+
+    /**
+     * 发起支付前
      * @param array $orderInfo
      * @param string $payType
-     * @return array|string
+     * @param array $options
+     * @return array
      * @throws \think\db\exception\DataNotFoundException
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
+     * @author 等风来
+     * @email 136327134@qq.com
+     * @date 2023/2/15
      */
-    public function orderPay(array $orderInfo, string $payType, array $options = [])
+    public function beforePay(array $orderInfo, string $payType, array $options = [])
     {
+        $payType = $this->getPayType($payType);
+
         if ($orderInfo['paid']) {
             throw new ApiException(410174);
         }
@@ -55,27 +123,34 @@ class OrderPayServices
             throw new ApiException(410274);
         }
 
-        $openid = '';
-        if (!in_array($payType, ['weixinh5', 'pc', 'allinpay']) && !request()->isApp()) {
-            if ($payType === 'weixin') {
-                $userType = 'wechat';
-            } else {
-                $userType = $payType;
-            }
-            /** @var WechatUserServices $services */
-            $services = app()->make(WechatUserServices::class);
-            $openid = $services->uidToOpenid($orderInfo['pay_uid'] ?? $orderInfo['uid'], $userType);
-            if (!$openid) {
-                throw new ApiException(410275);
-            }
+        switch ($payType) {
+            case PayServices::WEIXIN_PAY:
+                $openid = '';
+                if (request()->isWechat() || request()->isRoutine()) {
+                    if (request()->isWechat()) {
+                        $userType = 'wechat';
+                    } else {
+                        $userType = 'routine';
+                    }
+                    /** @var WechatUserServices $services */
+                    $services = app()->make(WechatUserServices::class);
+                    $openid = $services->uidToOpenid($orderInfo['pay_uid'] ?? $orderInfo['uid'], $userType);
+                    if (!$openid) {
+                        throw new ApiException(410275);
+                    }
+                }
+                $options['openid'] = $openid;
+                break;
         }
+
+
         $site_name = sys_config('site_name');
         if (isset($orderInfo['member_type'])) {
             $body = Str::substrUTf8($site_name . '--' . $orderInfo['member_type'], 20);
             $successAction = "member";
             /** @var OtherOrderServices $otherOrderServices */
             $otherOrderServices = app()->make(OtherOrderServices::class);
-            $otherOrderServices->update($orderInfo['id'], ['pay_type' => 'alipay']);
+            $otherOrderServices->update($orderInfo['id'], ['pay_type' => $payType]);
         } else {
             /** @var StoreOrderCartInfoServices $orderInfoServices */
             $orderInfoServices = app()->make(StoreOrderCartInfoServices::class);
@@ -84,52 +159,52 @@ class OrderPayServices
             $successAction = "product";
             /** @var StoreOrderServices $orderServices */
             $orderServices = app()->make(StoreOrderServices::class);
-            $orderServices->update($orderInfo['id'], ['pay_type' => 'weixin']);
+            $orderServices->update($orderInfo['id'], ['pay_type' => $payType]);
         }
 
         if (!$body) {
             throw new ApiException(410276);
         }
 
-        return $this->payServices->setOptions($options)->pay($payType, $openid, $orderInfo['order_id'], $orderInfo['pay_price'], $successAction, $body);
+        //发起支付
+        $jsConfig = $this->payServices->payV2($payType, $orderInfo['order_id'], $orderInfo['pay_price'], $successAction, $body, $options);
+
+        //发起支付后处理返回参数
+        $payInfo = $this->afterPay($orderInfo, $jsConfig, $payType);
+        $statusType = $this->payStatus($payType);
+
+        return [
+            'status' => $statusType,
+            'payInfo' => $payInfo,
+        ];
     }
 
     /**
-     * 支付宝支付
-     * @param array $orderInfo
-     * @param string $quitUrl
-     * @return array|string
+     * 支付发起后处理返回参数
+     * @param $order
+     * @param $jsConfig
+     * @param string $payType
+     * @param array $options
+     * @return array
+     * @author 等风来
+     * @email 136327134@qq.com
+     * @date 2023/2/15
      */
-    public function alipayOrder(array $orderInfo, string $quitUrl, bool $isCode = false)
+    public function afterPay($order, $jsConfig, string $payType, array $options = [])
     {
-        if ($orderInfo['paid']) {
-            throw new ApiException(410174);
-        }
-        if ($orderInfo['pay_price'] <= 0) {
-            throw new ApiException(410274);
-        }
-        $site_name = sys_config('site_name');
-        if (isset($orderInfo['member_type'])) {
-            $body = Str::substrUTf8($site_name . '--' . $orderInfo['member_type'], 30);
-            $successAction = "member";
-            /** @var OtherOrderServices $otherOrderServices */
-            $otherOrderServices = app()->make(OtherOrderServices::class);
-            $otherOrderServices->update($orderInfo['id'], ['pay_type' => 'alipay']);
-        } else {
-            /** @var StoreOrderCartInfoServices $orderInfoServices */
-            $orderInfoServices = app()->make(StoreOrderCartInfoServices::class);
-            $body = $orderInfoServices->getCarIdByProductTitle((int)$orderInfo['id']);
-            $body = Str::substrUTf8($site_name . '--' . $body, 30);
-            $successAction = "product";
-            /** @var StoreOrderServices $orderServices */
-            $orderServices = app()->make(StoreOrderServices::class);
-            $orderServices->update($orderInfo['id'], ['pay_type' => 'alipay']);
-        }
-
-        if (!$body) {
-            throw new ApiException(410276);
+        $payKey = md5($order['order_id']);
+        switch ($payType) {
+            case PayServices::ALIAPY_PAY:
+                $isCode = $options['isCode'] ?? '';
+                if ($isCode && !($jsConfig->invalid ?? false)) $jsConfig->invalid = time() + 60;
+                CacheService::set($payKey, ['order_id' => $order['order_id'], 'other_pay_type' => false], 300);
+                break;
+            case PayServices::ALLIN_PAY:
+                if (request()->isWechat()) {
+                    $jsConfig['pay_url'] = AllinPay::UNITODER_H5UNIONPAY;
+                }
         }
 
-        return $this->payServices->pay('alipay', $quitUrl, $orderInfo['order_id'], $orderInfo['pay_price'], $successAction, $body, $isCode);
+        return ['jsConfig' => $jsConfig, 'order_id' => $order['order_id'], 'pay_key' => $payKey];
     }
 }

+ 10 - 110
crmeb/app/services/pay/PayNotifyServices.php

@@ -16,7 +16,7 @@ use app\services\order\StoreOrderSuccessServices;
 use app\services\user\UserRechargeServices;
 
 /**
- * 支付成功回调
+ * 支付成功回调 所有的异步通知回调都会走下面的三个方法,不在取分微信/支付宝支付回调
  * Class PayNotifyServices
  * @package app\services\pay
  */
@@ -24,11 +24,11 @@ class PayNotifyServices
 {
 
     /**
-     * 微信支付-订单支付成功之后
+     * 订单支付成功之后
      * @param string|null $order_id 订单id
      * @return bool
      */
-    public function wechatProduct(string $order_id = null, string $trade_no = null)
+    public function wechatProduct(string $order_id = null, string $trade_no = null, string $payType = PayServices::WEIXIN_PAY)
     {
         try {
             /** @var StoreOrderSuccessServices $services */
@@ -36,35 +36,35 @@ class PayNotifyServices
             $orderInfo = $services->getOne(['order_id' => $order_id]);
             if (!$orderInfo) return true;
             if ($orderInfo->paid) return true;
-            return $services->paySuccess($orderInfo->toArray(), PayServices::WEIXIN_PAY, ['trade_no' => $trade_no]);
+            return $services->paySuccess($orderInfo->toArray(), $payType, ['trade_no' => $trade_no]);
         } catch (\Exception $e) {
             return false;
         }
     }
 
     /**
-     * 微信支付-充值成功后
+     * 充值成功后
      * @param string|null $order_id 订单id
      * @return bool
      */
-    public function wechatUserRecharge(string $order_id = null, string $trade_no = null)
+    public function wechatUserRecharge(string $order_id = null, string $trade_no = null, string $payType = PayServices::WEIXIN_PAY)
     {
         try {
             /** @var UserRechargeServices $userRecharge */
             $userRecharge = app()->make(UserRechargeServices::class);
             if ($userRecharge->be(['order_id' => $order_id, 'paid' => 1])) return true;
-            return $userRecharge->rechargeSuccess($order_id, ['trade_no' => $trade_no]);
+            return $userRecharge->rechargeSuccess($order_id, ['trade_no' => $trade_no, 'pay_type' => $payType]);
         } catch (\Exception $e) {
             return false;
         }
     }
 
     /**
-     * 微信支付-购买会员
+     * 购买会员
      * @param string|null $order_id
      * @return bool
      */
-    public function wechatMember(string $order_id = null, string $trade_no = null)
+    public function wechatMember(string $order_id = null, string $trade_no = null, string $payType = PayServices::WEIXIN_PAY)
     {
         try {
             /** @var OtherOrderServices $services */
@@ -72,110 +72,10 @@ class PayNotifyServices
             $orderInfo = $services->getOne(['order_id' => $order_id]);
             if (!$orderInfo) return true;
             if ($orderInfo->paid) return true;
-            return $services->paySuccess($orderInfo->toArray());
+            return $services->paySuccess($orderInfo->toArray(), $payType, ['trade_no' => $trade_no]);
         } catch (\Exception $e) {
             return false;
         }
     }
 
-    /**
-     * 支付宝支付-异步回调处理事件
-     * @param string|null $order_id
-     * @param string|null $trade_no
-     * @return bool
-     */
-    public function aliyunProduct(string $order_id = null, string $trade_no = null)
-    {
-        if (!$order_id || !$trade_no) {
-            return false;
-        }
-        try {
-            /** @var StoreOrderSuccessServices $services */
-            $services = app()->make(StoreOrderSuccessServices::class);
-            $orderInfo = $services->getOne(['order_id' => $order_id]);
-            if (!$orderInfo) return true;
-            if ($orderInfo->paid) return true;
-            return $services->paySuccess($orderInfo->toArray(), PayServices::ALIAPY_PAY, ['trade_no' => $trade_no]);
-        } catch (\Throwable $e) {
-            return false;
-        }
-    }
-
-    /**
-     * 支付宝支付-购买会员卡
-     * @param string|null $order_id
-     * @param string|null $trade_no
-     * @return bool
-     */
-    public function aliyunMember(string $order_id = null, string $trade_no = null)
-    {
-        if (!$order_id || !$trade_no) {
-            return false;
-        }
-        try {
-            /** @var OtherOrderServices $services */
-            $services = app()->make(OtherOrderServices::class);
-            $orderInfo = $services->getOne(['order_id' => $order_id]);
-            if (!$orderInfo) return true;
-            if ($orderInfo->paid) return true;
-            return $services->paySuccess($orderInfo->toArray(), PayServices::ALIAPY_PAY, ['trade_no' => $trade_no]);
-        } catch (\Throwable $e) {
-            return false;
-        }
-    }
-
-    /**
-     * 通联支付-订单支付成功之后
-     * @param string|null $order_id 订单id
-     * @return bool
-     */
-    public function allinProduct(string $order_id = null, string $trade_no = null)
-    {
-        try {
-            /** @var StoreOrderSuccessServices $services */
-            $services = app()->make(StoreOrderSuccessServices::class);
-            $orderInfo = $services->getOne(['order_id' => $order_id]);
-            if (!$orderInfo) return true;
-            if ($orderInfo->paid) return true;
-            return $services->paySuccess($orderInfo->toArray(), PayServices::ALLIN_PAY, ['trade_no' => $trade_no]);
-        } catch (\Exception $e) {
-            return false;
-        }
-    }
-
-    /**
-     * 通联支付-充值成功后
-     * @param string|null $order_id 订单id
-     * @return bool
-     */
-    public function allinUserRecharge(string $order_id = null, string $trade_no = null)
-    {
-        try {
-            /** @var UserRechargeServices $userRecharge */
-            $userRecharge = app()->make(UserRechargeServices::class);
-            if ($userRecharge->be(['order_id' => $order_id, 'paid' => 1])) return true;
-            return $userRecharge->rechargeSuccess($order_id, ['trade_no' => $trade_no]);
-        } catch (\Exception $e) {
-            return false;
-        }
-    }
-
-    /**
-     * 通联支付-购买会员
-     * @param string|null $order_id
-     * @return bool
-     */
-    public function allinMember(string $order_id = null, string $trade_no = null)
-    {
-        try {
-            /** @var OtherOrderServices $services */
-            $services = app()->make(OtherOrderServices::class);
-            $orderInfo = $services->getOne(['order_id' => $order_id]);
-            if (!$orderInfo) return true;
-            if ($orderInfo->paid) return true;
-            return $services->paySuccess($orderInfo->toArray(), PayServices::ALLIN_PAY);
-        } catch (\Exception $e) {
-            return false;
-        }
-    }
 }

+ 43 - 0
crmeb/app/services/pay/PayServices.php

@@ -95,6 +95,49 @@ class PayServices
         return $this->options[$key] ?? $default;
     }
 
+    /**
+     * 发起支付
+     * @param string $payType
+     * @param string $openid
+     * @param string $orderId
+     * @param string $price
+     * @param string $successAction
+     * @param string $body
+     * @return array|string
+     */
+    public function payV2(string $payType, string $orderId, string $price, string $successAction, string $body, array $options = [])
+    {
+        try {
+
+            //这些全都是微信支付
+            if (in_array($payType, ['routine', 'weixinh5', 'weixin', 'pc', 'store'])) {
+                $payType = 'wechat_pay';
+                //判断是否使用v3
+                if (sys_config('pay_wechat_type') == 1) {
+                    $payType = 'v3_wechat_pay';
+                }
+            } else {
+                if ($payType == 'alipay') {
+                    $payType = 'ali_pay';
+                } elseif ($payType == 'allinpay') {
+                    $payType = 'allin_pay';
+                }
+            }
+
+            /** @var Pay $pay */
+            $pay = app()->make(Pay::class, [$payType]);
+
+
+            return $pay->create($orderId, $price, $successAction, $body, '', ['pay_new_weixin_open' => (bool)sys_config('pay_new_weixin_open')] + $options);
+
+        } catch (\Exception $e) {
+            if (strpos($e->getMessage(), 'api unauthorized rid') !== false) {
+                throw new ApiException('请在微信支付配置中将小程序商户号选择改为商户号绑定');
+            }
+            throw new ApiException($e->getMessage());
+        }
+    }
+
     /**
      * 发起支付
      * @param string $payType

+ 34 - 14
crmeb/app/services/pay/RechargeServices.php

@@ -17,6 +17,7 @@ use app\model\user\UserRecharge;
 use app\services\user\UserRechargeServices;
 use app\services\wechat\WechatUserServices;
 use crmeb\exceptions\ApiException;
+use Darabonba\GatewaySpi\Models\InterceptorContext\request;
 
 /**
  *
@@ -44,29 +45,40 @@ class RechargeServices
         if ($recharge['paid'] == 1) {
             throw new ApiException(410174);
         }
-        $userType = '';
+        $payType = '';
         switch ($recharge['recharge_type']) {
             case 'weixin':
             case 'weixinh5':
-                $userType = 'wechat';
-                break;
             case 'routine':
-                $userType = 'routine';
+                $payType = PayServices::WEIXIN_PAY;
                 break;
             case PayServices::ALIAPY_PAY:
-                $userType = PayServices::ALIAPY_PAY;
+                $payType = PayServices::ALIAPY_PAY;
                 break;
         }
 
-        $userType = get_pay_type($userType);
+        $payType = app()->make(OrderPayServices::class)->getPayType($payType);
 
-        if (!$userType) {
+        if (!$payType) {
             throw new ApiException(410278);
         }
-        /** @var WechatUserServices $wechatUser */
-        $wechatUser = app()->make(WechatUserServices::class);
-        $openid = $wechatUser->uidToOpenid((int)$recharge['uid'], $userType);
-        if (in_array($recharge['recharge_type'], ['weixin', 'routine']) && !request()->isApp()) {
+
+        if ($recharge['recharge_type'] == PayServices::WEIXIN_PAY && !request()->isH5()) {
+
+            /** @var WechatUserServices $wechatUser */
+            $wechatUser = app()->make(WechatUserServices::class);
+            if (request()->isApp()) {
+                $userType = 'app';
+            } else if (request()->isRoutine()) {
+                $userType = 'routine';
+            } else if (request()->isWechat()) {
+                $userType = 'wechat';
+            } else {
+                throw new ApiException(410275);
+            }
+
+            $openid = $wechatUser->uidToOpenid((int)$recharge['uid'], $userType);
+
             if (!$openid) {
                 throw new ApiException(410275);
             }
@@ -76,11 +88,19 @@ class RechargeServices
 
         $res = $this->pay->pay($recharge['recharge_type'], $openid, $recharge['order_id'], $recharge['price'], 'user_recharge', '用户充值');
 
-        if ($userType === PayServices::ALLIN_PAY) {
-            $res['pay_type'] = $userType;
+        if ($payType == PayServices::WEIXIN_PAY) {
+            if (request()->isH5()) {
+                $payStstus = 'wechat_h5_pay';
+            } else {
+                $payStstus = 'wechat_pay';
+            }
+        } else if ($payType == PayServices::ALIAPY_PAY) {
+            $payStstus = 'alipay_pay';
+        } else if ($payType == PayServices::ALLIN_PAY) {
+            $payStstus = 'allinpay_pay';
         }
 
-        return $res;
+        return ['jsConfig' => $res, 'order_id' => $recharge['order_id'], 'pay_type' => strtoupper($payStstus)];
     }
 
 }

+ 22 - 3
crmeb/app/services/product/product/StoreProductServices.php

@@ -648,15 +648,34 @@ class StoreProductServices extends BaseServices
 
                 //采集商品下载图片
                 if ($type == -1) {
+                    $s_image_down = $d_image_down = [];
                     //下载商品轮播图
                     foreach ($slider_image as $s_image) {
-                        ProductCopyJob::dispatch('copySliderImage', [$res->id, $s_image, count($slider_image)]);
+                        if (sys_config('queue_open', 0) == 1) {
+                            ProductCopyJob::dispatch('copySliderImage', [$res->id, $s_image, count($slider_image)]);
+                        } else {
+                            //下载图片
+                            $s_image_down[] = app()->make(CopyTaobaoServices::class)->downloadCopyImage($s_image);
+                        }
                     }
+
+                    //下载商品详情图
                     preg_match_all('#<img.*?src="([^"]*)"[^>]*>#i', $description, $match);
                     foreach ($match[1] as $d_image) {
-                        ProductCopyJob::dispatch('copyDescriptionImage', [$res->id, $description, $d_image, count($match[1])]);
+                        if (sys_config('queue_open', 0) == 1) {
+                            ProductCopyJob::dispatch('copyDescriptionImage', [$res->id, $description, $d_image, count($match[1])]);
+                        } else {
+                            if (!is_int(strpos($d_image, 'http'))) $d_image = 'http://' . ltrim($d_image, '\//');
+                            $d_image_down[] = $d_img = app()->make(CopyTaobaoServices::class)->downloadCopyImage($d_image);
+                            $description = str_replace($d_image, $d_img, $description);
+                        }
                     }
 
+                    if (sys_config('queue_open', 0) == 0) {
+                        $this->update($res->id, ['slider_image' => $s_image_down ? json_encode($s_image_down) : '', 'image' => $s_image_down[0]]);
+                        app()->make(StoreProductAttrValueServices::class)->update(['product_id' => $res->id], ['image' => $s_image_down[0]]);
+                        $storeDescriptionServices->saveDescription((int)$res->id, $description);
+                    }
                 }
             }
         });
@@ -1938,7 +1957,7 @@ class StoreProductServices extends BaseServices
      */
     public function getCode(int $id, string $userType, $user)
     {
-        if (!$id || !$this->isValidProduct($id)) {
+        if (!$id || !$this->isValidProduct($id, 'id')) {
             throw new ApiException(410294);
         }
         if ($userType == 'routine') {

+ 0 - 2
crmeb/app/services/system/admin/SystemRoleServices.php

@@ -17,8 +17,6 @@ use app\Request;
 use app\services\BaseServices;
 use app\services\system\SystemMenusServices;
 use crmeb\exceptions\AuthException;
-use think\facade\Cache;
-
 
 /**
  * Class SystemRoleServices

+ 1 - 1
crmeb/app/services/user/UserBillServices.php

@@ -780,7 +780,7 @@ class UserBillServices extends BaseServices
         $userExtract = app()->make(UserExtractServices::class);
         $extractSumList = $userExtract->getUsersSumList($uids);
         foreach ($list as &$item) {
-            $item['sum_number'] = $item['income'] > $item['pay'] ? bcsub($item['income'], $item['pay'], 2) : 0;
+            $item['sum_number'] = $item['income'];
             $item['nickname'] = $item['nickname'] . "|" . ($item['phone'] ? $item['phone'] . "|" : '') . $item['uid'];
             $item['extract_price'] = $extractSumList[$item['uid']] ?? 0;
             $item['time'] = $item['time'] ? date('Y-m-d H:i:s', $item['time']) : '';

+ 19 - 3
crmeb/app/services/user/UserExtractServices.php

@@ -23,7 +23,10 @@ use crmeb\exceptions\ApiException;
 use crmeb\services\FormBuilder as Form;
 use crmeb\services\app\WechatService;
 use crmeb\services\pay\Pay;
+use crmeb\services\wechat\Payment;
 use crmeb\services\workerman\ChannelService;
+use EasyWeChat\Payment\Order;
+use think\exception\ValidateException;
 use think\facade\Route as Url;
 
 /**
@@ -182,12 +185,24 @@ class UserExtractServices extends BaseServices
         }
 
         $insertData = ['order_id' => $order_id, 'nickname' => $nickname, 'phone' => $phone];
-        
+
         //自动提现到零钱
         if ($userExtract['extract_type'] == 'weixin' && sys_config('brokerage_type', 0)) {
 
             $openid = $wechatServices->uidToOpenid($userExtract['uid'], 'wechat');
-            if (!$openid) $openid = $wechatServices->uidToOpenid($userExtract['uid'], 'routine');
+            $type = Order::JSAPI;
+            if (!$openid) {
+                $openid = $wechatServices->uidToOpenid($userExtract['uid'], 'routine');
+                $type = 'mini';
+            }
+            if (!$openid) {
+                $openid = $wechatServices->uidToOpenid((int)$userExtract['uid'], 'app');
+                $type = Order::APP;
+            }
+
+            if (!$openid) {
+                throw new ValidateException('该用户暂不支持企业付款到零钱,请手动转账');
+            }
 
             /** @var StoreOrderCreateServices $services */
             $services = app()->make(StoreOrderCreateServices::class);
@@ -197,6 +212,7 @@ class UserExtractServices extends BaseServices
             if (sys_config('pay_wechat_type')) {
                 $pay = new Pay('v3_wechat_pay');
                 $res = $pay->merchantPay($openid, $insertData['order_id'], $userExtract['extract_price'], [
+                    'type' => $type,
                     'batch_name' => '提现佣金到零钱',
                     'batch_remark' => '您于' . date('Y-m-d H:i:s') . '提现.' . $userExtract['extract_price'] . '元'
                 ]);
@@ -362,7 +378,7 @@ class UserExtractServices extends BaseServices
     {
         /** @var UserServices $userService */
         $userService = app()->make(UserServices::class);
-        $user = $userService->getUserInfo($uid);
+        $user = $userService->getUserInfo($uid, 'brokerage_price,uid');
         if (!$user) {
             throw new ApiException(100026);
         }

+ 14 - 6
crmeb/app/services/user/UserRechargeServices.php

@@ -15,6 +15,7 @@ namespace app\services\user;
 use app\dao\user\UserRechargeDao;
 use app\services\BaseServices;
 use app\services\order\StoreOrderCreateServices;
+use app\services\pay\PayServices;
 use app\services\pay\RechargeServices;
 use app\services\statistic\CapitalFlowServices;
 use app\services\system\config\SystemGroupDataServices;
@@ -106,12 +107,15 @@ class UserRechargeServices extends BaseServices
                 case 'routine':
                     $item['_recharge_type'] = '小程序充值';
                     break;
-                case 'weixin':
+                case PayServices::WEIXIN_PAY:
                     $item['_recharge_type'] = '公众号充值';
                     break;
                 case 'system':
                     $item['_recharge_type'] = '系统充值';
                     break;
+                case PayServices::ALIAPY_PAY:
+                    $item['_recharge_type'] = '支付宝充值';
+                    break;
                 default:
                     $item['_recharge_type'] = '其他充值';
                     break;
@@ -235,9 +239,9 @@ class UserRechargeServices extends BaseServices
                 $refund_data['order_id'] = $UserRecharge['order_id'];
                 /** @var WechatUserServices $wechatUserServices */
                 $wechatUserServices = app()->make(WechatUserServices::class);
-                $refund_data['open_id'] = $wechatUserServices->uidToOpenid((int)$UserRecharge['uid'],'routine') ?? '';
+                $refund_data['open_id'] = $wechatUserServices->uidToOpenid((int)$UserRecharge['uid'], 'routine') ?? '';
                 $refund_data['pay_new_weixin_open'] = sys_config('pay_new_weixin_open');
-                /** @var StoreOrderCreateServices $storeOrderCreateServices  */
+                /** @var StoreOrderCreateServices $storeOrderCreateServices */
                 $storeOrderCreateServices = app()->make(StoreOrderCreateServices::class);
                 $refund_data['refund_no'] = $storeOrderCreateServices->getNewOrderId('tk');
                 $pay->refund($UserRecharge['order_id'], $refund_data);
@@ -379,7 +383,7 @@ class UserRechargeServices extends BaseServices
      * @param int $uid
      * @return mixed
      */
-    public function recharge(int $uid, $price, $recharId, $type, $from)
+    public function recharge(int $uid, $price, $recharId, $type, $from, bool $renten = false)
     {
         /** @var UserServices $userServices */
         $userServices = app()->make(UserServices::class);
@@ -398,6 +402,7 @@ class UserRechargeServices extends BaseServices
                         throw new ApiException(400682);
                     } else {
                         $paid_price = $data['give_money'] ?? 0;
+                        $price = $data['price'] ?? 0;
                     }
                 }
                 $recharge_data = [];
@@ -419,6 +424,9 @@ class UserRechargeServices extends BaseServices
                 } catch (\Exception $e) {
                     throw new ApiException($e->getMessage());
                 }
+                if ($renten) {
+                    return $order_info;
+                }
                 return ['msg' => '', 'type' => $from, 'data' => $order_info];
             case 1: //佣金转入余额
                 $this->importNowMoney($uid, $price);
@@ -432,7 +440,7 @@ class UserRechargeServices extends BaseServices
      * //TODO用户充值成功后
      * @param $orderId
      */
-    public function rechargeSuccess($orderId,array $other = [])
+    public function rechargeSuccess($orderId, array $other = [])
     {
         $order = $this->dao->getOne(['order_id' => $orderId, 'paid' => 0]);
         if (!$order) {
@@ -445,7 +453,7 @@ class UserRechargeServices extends BaseServices
             throw new ApiException(410032);
         }
         $price = bcadd((string)$order['price'], (string)$order['give_price'], 2);
-        if (!$this->dao->update($order['id'], ['paid' => 1, 'pay_time' => time() ,'trade_no'=> $other['trade_no'] ?? ''], 'id')) {
+        if (!$this->dao->update($order['id'], ['paid' => 1, 'recharge_type' => $other['pay_type'], 'pay_time' => time(), 'trade_no' => $other['trade_no'] ?? ''], 'id')) {
             throw new ApiException(410286);
         }
         $now_money = bcadd((string)$user['now_money'], (string)$price, 2);

+ 2 - 1
crmeb/composer.json

@@ -60,7 +60,8 @@
         }
     },
     "config": {
-        "preferred-install": "dist"
+        "preferred-install": "dist",
+        "platform-check": false
     },
     "scripts": {
         "post-autoload-dump": [

+ 29 - 1
crmeb/crmeb/basic/BaseStorage.php

@@ -18,7 +18,6 @@ namespace crmeb\basic;
  */
 abstract class BaseStorage
 {
-    use \crmeb\traits\ErrorTrait;
 
     /**
      * 驱动名称
@@ -32,6 +31,12 @@ abstract class BaseStorage
      */
     protected $configFile;
 
+    /**
+     * 错误信息
+     * @var string
+     */
+    protected $error;
+
     /**
      * BaseStorage constructor.
      * @param string $name 驱动名
@@ -45,6 +50,29 @@ abstract class BaseStorage
         $this->initialize($config);
     }
 
+
+    /**
+     * 设置错误信息
+     * @param string|null $error
+     * @return bool
+     */
+    protected function setError(?string $error = null)
+    {
+        $this->error = $error ?: '未知错误';
+        return false;
+    }
+
+    /**
+     * 获取错误信息
+     * @return string
+     */
+    public function getError()
+    {
+        $error = $this->error;
+        $this->error = null;
+        return $error;
+    }
+
     /**
      * 初始化
      * @param array $config

+ 0 - 37
crmeb/crmeb/exceptions/SmsException.php

@@ -1,37 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
-// +----------------------------------------------------------------------
-// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
-// +----------------------------------------------------------------------
-// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
-// +----------------------------------------------------------------------
-// | Author: CRMEB Team <admin@crmeb.com>
-// +----------------------------------------------------------------------
-
-namespace crmeb\exceptions;
-
-/**
- * Class AuthException
- * @package crmeb\exceptions
- */
-class SmsException extends \RuntimeException
-{
-    public function __construct($message, $replace = [], $code = 0, \Throwable $previous = null)
-    {
-        if (is_array($message)) {
-            $errInfo = $message;
-            $message = $errInfo[1] ?? '未知错误';
-            if ($code === 0) {
-                $code = $errInfo[0] ?? 400;
-            }
-        }
-
-        if (is_numeric($message)) {
-            $code = $message;
-            $message = getLang($message, $replace);
-        }
-
-        parent::__construct($message, $code, $previous);
-    }
-}

+ 0 - 37
crmeb/crmeb/exceptions/TemplateException.php

@@ -1,37 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
-// +----------------------------------------------------------------------
-// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
-// +----------------------------------------------------------------------
-// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
-// +----------------------------------------------------------------------
-// | Author: CRMEB Team <admin@crmeb.com>
-// +----------------------------------------------------------------------
-
-namespace crmeb\exceptions;
-
-/**
- * Class TemplateException
- * @package crmeb\exceptions
- */
-class TemplateException extends \RuntimeException
-{
-    public function __construct($message, $replace = [], $code = 0, \Throwable $previous = null)
-    {
-        if (is_array($message)) {
-            $errInfo = $message;
-            $message = $errInfo[1] ?? '未知错误';
-            if ($code === 0) {
-                $code = $errInfo[0] ?? 400;
-            }
-        }
-
-        if (is_numeric($message)) {
-            $code = $message;
-            $message = getLang($message, $replace);
-        }
-
-        parent::__construct($message, $code, $previous);
-    }
-}

+ 0 - 38
crmeb/crmeb/exceptions/WechatReplyException.php

@@ -1,38 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
-// +----------------------------------------------------------------------
-// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
-// +----------------------------------------------------------------------
-// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
-// +----------------------------------------------------------------------
-// | Author: CRMEB Team <admin@crmeb.com>
-// +----------------------------------------------------------------------
-
-namespace crmeb\exceptions;
-
-/**
- * 微信消息回复错误
- * Class WechatReplyException
- * @package crmeb\exceptions
- */
-class WechatReplyException extends \RuntimeException
-{
-    public function __construct($message, $replace = [], $code = 0, \Throwable $previous = null)
-    {
-        if (is_array($message)) {
-            $errInfo = $message;
-            $message = $errInfo[1] ?? '未知错误';
-            if ($code === 0) {
-                $code = $errInfo[0] ?? 400;
-            }
-        }
-
-        if (is_numeric($message)) {
-            $code = $message;
-            $message = getLang($message, $replace);
-        }
-
-        parent::__construct($message, $code, $previous);
-    }
-}

+ 10 - 8
crmeb/crmeb/services/AliPayService.php

@@ -12,6 +12,7 @@
 namespace crmeb\services;
 
 use Alipay\EasySDK\Payment\Wap\Models\AlipayTradeWapPayResponse;
+use app\services\pay\PayServices;
 use crmeb\utils\Hook;
 use think\facade\Event;
 use think\facade\Log;
@@ -201,15 +202,16 @@ class AliPayService
     {
         return self::instance()->notify(function ($notify) {
             if (isset($notify->out_trade_no)) {
-                if (isset($notify->attach) && $notify->attach) {
-                    if (($count = strpos($notify->out_trade_no, '_')) !== false) {
-                        $notify->trade_no = $notify->out_trade_no;
-                        $notify->out_trade_no = substr($notify->out_trade_no, $count + 1);
-                    }
-                    return (new Hook(PayNotifyServices::class, 'aliyun'))->listen($notify->attach, $notify->out_trade_no, $notify->trade_no);
-                }
-                return false;
+
+                $data = [
+                    'attach' => $notify->attach,
+                    'out_trade_no' => $notify->out_trade_no,
+                    'transaction_id' => $notify->trade_no
+                ];
+
+                return Event::until('pay.notify', [$data, PayServices::ALIAPY_PAY]);
             }
+            return false;
         });
     }
 

+ 1 - 2
crmeb/crmeb/services/app/MiniProgramService.php

@@ -17,7 +17,6 @@ use app\services\pay\PayNotifyServices;
 use crmeb\services\easywechat\Application;
 use EasyWeChat\Payment\Order;
 use think\facade\Log;
-use think\facade\Route as Url;
 use crmeb\utils\Hook;
 use think\facade\Cache;
 
@@ -113,7 +112,7 @@ class MiniProgramService
             'key' => trim($payment['pay_weixin_key']),
             'cert_path' => substr(public_path(parse_url($payment['pay_weixin_client_cert'])['path']), 0, strlen(public_path(parse_url($payment['pay_weixin_client_cert'])['path'])) - 1),
             'key_path' => substr(public_path(parse_url($payment['pay_weixin_client_key'])['path']), 0, strlen(public_path(parse_url($payment['pay_weixin_client_key'])['path'])) - 1),
-            'notify_url' => trim($wechat['site_url']) . Url::buildUrl('/api/routine/notify')
+            'notify_url' => trim($wechat['site_url']) . '/api/pay/notify/routine'
         ];
         return $config;
     }

+ 15 - 13
crmeb/crmeb/services/app/WechatService.php

@@ -13,6 +13,7 @@ namespace crmeb\services\app;
 
 use app\services\message\wechat\MessageServices;
 use app\services\order\StoreOrderServices;
+use app\services\pay\PayServices;
 use app\services\wechat\WechatMessageServices;
 use app\services\wechat\WechatReplyServices;
 use crmeb\exceptions\AdminException;
@@ -80,7 +81,7 @@ class WechatService
                 'key' => trim($payment['pay_weixin_key']),
                 'cert_path' => substr(public_path(parse_url($payment['pay_weixin_client_cert'])['path']), 0, strlen(public_path(parse_url($payment['pay_weixin_client_cert'])['path'])) - 1),
                 'key_path' => substr(public_path(parse_url($payment['pay_weixin_client_key'])['path']), 0, strlen(public_path(parse_url($payment['pay_weixin_client_key'])['path'])) - 1),
-                'notify_url' => trim(sys_config('site_url')) . '/api/wechat/notify'
+                'notify_url' => trim(sys_config('site_url')) . '/api/pay/notify/wechat'
             ];
         }
         return $config;
@@ -167,7 +168,7 @@ class WechatService
                             $data['out_trade_no'] = $message['order_info']['trade_no'];
                             $data['transaction_id'] = $message['order_info']['transaction_id'];
                             $data['opneid'] = $message['FromUserName'];
-                            if (Event::until('pay.notify', [$data])) {
+                            if (Event::until('pay.notify', [$data, PayServices::WEIXIN_PAY])) {
                                 $response = 'success';
                             } else {
                                 $response = 'faild';
@@ -619,18 +620,19 @@ class WechatService
     public static function handleNotify()
     {
         return self::paymentService()->handleNotify(function ($notify, $successful) {
-            if ($successful && isset($notify->out_trade_no)) {
-                if (isset($notify->attach) && $notify->attach) {
-                    if (($count = strpos($notify->out_trade_no, '_')) !== false) {
-                        $notify->out_trade_no = substr($notify->out_trade_no, $count + 1);
-                    }
-                    return (new Hook(PayNotifyServices::class, 'wechat'))->listen($notify->attach, $notify->out_trade_no, $notify->transaction_id);
-                }
-                /** @var WechatMessageServices $wechatMessageService */
-                $wechatMessageService = app()->make(WechatMessageServices::class);
-                $wechatMessageService->setOnceMessage($notify, $notify->openid, 'payment_success', $notify->out_trade_no);
-                return false;
+
+            if ($successful) {
+
+                $data = [
+                    'attach' => $notify->attach,
+                    'out_trade_no' => $notify->out_trade_no,
+                    'transaction_id' => $notify->transaction_id
+                ];
+
+                return Event::until('pay.notify', [$data, PayServices::WEIXIN_PAY]);
             }
+
+            return false;
         });
     }
 

+ 34 - 1
crmeb/crmeb/services/easywechat/v3pay/PayClient.php

@@ -15,6 +15,8 @@ namespace crmeb\services\easywechat\v3pay;
 
 
 use crmeb\exceptions\PayException;
+use crmeb\services\wechat\Payment;
+use EasyWeChat\Payment\Order;
 
 /**
  * v3支付
@@ -38,6 +40,24 @@ class PayClient extends BaseClient
     //退款查询接口
     const API_REFUND_QUERY_URL = 'v3/refund/domestic/refunds/{out_refund_no}';
 
+    /**
+     * @var string
+     */
+    protected $type = Order::JSAPI;
+
+    /**
+     * @param string $type
+     * @return $this
+     * @author 等风来
+     * @email 136327134@qq.com
+     * @date 2023/2/10
+     */
+    public function setType(string $type)
+    {
+        $this->type = $type;
+        return $this;
+    }
+
     /**
      * 公众号jsapi支付下单
      * @param string $outTradeNo
@@ -208,8 +228,21 @@ class PayClient extends BaseClient
 
         $amount = (int)bcmul($amount, 100, 0);
 
+        $appid = null;
+        if ($this->type === Order::JSAPI) {
+            $appid = $this->app['config']['wechat']['appid'];
+        } else if ($this->type === 'mini') {
+            $appid = $this->app['config']['miniprog']['appid'];
+        } else if ($this->type === Order::APP) {
+            $appid = $this->app['config']['app']['appid'];
+        }
+
+        if (!$appid) {
+            throw new PayException('暂时只支持微信用户、小程序用户、APP微信登录用户提现');
+        }
+
         $data = [
-            'appid' => $this->app['config']['wechat']['appid'],
+            'appid' => $appid,
             'out_batch_no' => $outBatchNo,
             'batch_name' => $batchName,
             'batch_remark' => $remark,

+ 7 - 23
crmeb/crmeb/services/pay/extend/allinpay/AllinPay.php

@@ -193,28 +193,12 @@ class AllinPay extends Client
      * @email 136327134@qq.com
      * @date 2023/1/15
      */
-    public function pcPay(string $trxamt, string $orderId, string $body, string $returl)
+    public function pcPay(string $trxamt, string $orderId, string $body, string $remark, bool $isWechat = true)
     {
-        $totalFee = (int)bcmul($trxamt, '100');
-
-        $data = [
-            'paytype' => 'B2C',
-            'trxamt' => $totalFee,
-            'orderid' => $orderId,
-            'notifyurl' => $this->notifyUrl,
-            'goodsinf' => $body,
-            'validtime' => $this->validtime,
-            'returl' => $returl,
-            'cusid' => $this->cusid,
-            'appid' => $this->appid,
-            'signtype' => $this->signType,
-            'randomstr' => uniqid(),
-            'charset' => 'UTF-8'
-        ];
-
-        $data['sign'] = $this->sign($data);
-
-        return $data;
+        $this->api = self::UNITODER_PAY_API;
+        $this->payType = $isWechat ? 'W01' : 'A01';
+        $this->version = self::VERSION_NUM_11;
+        return $this->create($trxamt, $orderId, $body, null, null, null, '', $remark);
     }
 
     /**
@@ -270,11 +254,11 @@ class AllinPay extends Client
 
         $data['cusid'] = $this->cusid;
         $data['appid'] = $this->appid;
-        $data['signtype'] = 'RSA';
+        $data['signtype'] = $this->signType;
         $data['randomstr'] = uniqid();
         $data['sign'] = $this->sign($data);
 
-        return $this->send(self::UNITODER_QPAY_AGREEAPPLY, ['data' => $data]);
+        return $this->request(self::UNITODER_QPAY_AGREEAPPLY, $data);
     }
 
 

+ 1 - 1
crmeb/crmeb/services/pay/storage/AliPay.php

@@ -46,7 +46,7 @@ class AliPay extends BasePay implements PayInterface
     public function create(string $orderId, string $totalFee, string $attach, string $body, string $detail, array $options = [])
     {
         $code = false;
-        if (request()->isPC() || request()->isRoutine() || !empty($options['isCode'])) {
+        if (request()->isPC() || request()->isRoutine()) {
             $code = true;
         }
 

+ 21 - 6
crmeb/crmeb/services/pay/storage/AllinPay.php

@@ -15,12 +15,14 @@ namespace crmeb\services\pay\storage;
 
 
 use app\services\pay\PayNotifyServices;
+use app\services\pay\PayServices;
 use crmeb\exceptions\PayException;
 use crmeb\services\pay\BasePay;
 use crmeb\services\pay\PayInterface;
 use crmeb\services\pay\extend\allinpay\AllinPay as AllinPayService;
 use crmeb\utils\Hook;
 use EasyWeChat\Payment\Order;
+use think\facade\Event;
 
 /**
  * 通联支付
@@ -74,6 +76,13 @@ class AllinPay extends BasePay implements PayInterface
     {
         $this->authSetPayType();
 
+        $options['returl'] = sys_config('site_url') . '/pages/index/index';
+        if ($options['returl']) {
+            $options['returl'] = str_replace('http://', 'https://', $options['returl']);
+        }
+        $options['appid'] = sys_config('routine_appId');
+
+
         $notifyUrl = trim(sys_config('site_url')) . '/api/pay/notify/allin' . $attach;
         $this->pay->setNotifyUrl($notifyUrl);
 
@@ -86,6 +95,8 @@ class AllinPay extends BasePay implements PayInterface
                 } else {
                     return $this->pay->h5Pay($totalFee, $orderId, $body, $options['returl'] ?? '', $attach);
                 }
+            case Order::NATIVE:
+                return $this->pay->pcPay($totalFee, $orderId, $body, $attach, !empty($options['wechat']));
             default:
                 throw new PayException('通联支付:支付类型错误或者暂不支持此环境下支付');
         }
@@ -125,14 +136,18 @@ class AllinPay extends BasePay implements PayInterface
     public function handleNotify(string $attach = '')
     {
         $attach = str_replace('allin', '', $attach);
+
         return $this->pay->handleNotify(function ($notify) use ($attach) {
+
             if (isset($notify['cusorderid'])) {
-                $notify['trade_no'] = $notify['trxid'];
-                $notify['out_trade_no'] = $notify['cusorderid'];
-                if (($count = strpos($notify['cusorderid'], '_')) !== false) {
-                    $notify['out_trade_no'] = substr($notify['cusorderid'], $count + 1);
-                }
-                return (new Hook(PayNotifyServices::class, 'allin'))->listen($attach, $notify['out_trade_no'], $notify['trade_no']);
+
+                $data = [
+                    'attach' => $attach,
+                    'out_trade_no' => $notify['cusorderid'],
+                    'transaction_id' => $notify['trxid']
+                ];
+
+                return Event::until('pay.notify', [$data, PayServices::ALLIN_PAY]);
             }
             return false;
         });

+ 17 - 14
crmeb/crmeb/services/pay/storage/V3WechatPay.php

@@ -14,6 +14,7 @@
 namespace crmeb\services\pay\storage;
 
 use app\services\pay\PayNotifyServices;
+use app\services\pay\PayServices;
 use app\services\wechat\WechatMessageServices;
 use crmeb\exceptions\PayException;
 use crmeb\services\app\MiniProgramService;
@@ -22,6 +23,7 @@ use crmeb\services\pay\BasePay;
 use crmeb\services\pay\PayInterface;
 use crmeb\utils\Hook;
 use EasyWeChat\Payment\Order;
+use think\facade\Event;
 use think\facade\Log;
 
 /**
@@ -68,7 +70,7 @@ class V3WechatPay extends BasePay implements PayInterface
                 'serial_no' => sys_config('pay_weixin_serial_no'),
                 'cert_path' => public_path() . $this->getPemPath(sys_config('pay_weixin_client_cert')),
                 'key_path' => public_path() . $this->getPemPath(sys_config('pay_weixin_client_key')),
-                'notify_url' => trim(sys_config('site_url')) . '/api/wechat/v3notify',
+                'notify_url' => trim(sys_config('site_url')) . '/api/pay/notify/v3wechat',
             ]
         ];
         $this->instance = new Application($config);
@@ -148,7 +150,7 @@ class V3WechatPay extends BasePay implements PayInterface
      */
     public function merchantPay(string $openid, string $orderId, string $amount, array $options = [])
     {
-        $res = $this->instance->v3pay->batches(
+        $res = $this->instance->v3pay->setType($options['type'])->batches(
             $orderId,
             $amount,
             $options['batch_name'],
@@ -198,19 +200,20 @@ class V3WechatPay extends BasePay implements PayInterface
     public function handleNotify()
     {
         return $this->instance->v3pay->handleNotify(function ($notify, $successful) {
-            Log::error('支付回调:' . json_encode($notify));
-            if ($successful && isset($notify->out_trade_no)) {
-                if (isset($notify->attach) && $notify->attach) {
-                    if (($count = strpos($notify->out_trade_no, '_')) !== false) {
-                        $notify->out_trade_no = substr($notify->out_trade_no, $count + 1);
-                    }
-                    return (new Hook(PayNotifyServices::class, 'wechat'))->listen($notify->attach, $notify->out_trade_no, $notify->transaction_id);
-                }
-                /** @var WechatMessageServices $wechatMessageService */
-                $wechatMessageService = app()->make(WechatMessageServices::class);
-                $wechatMessageService->setOnceMessage($notify, $notify->openid, 'payment_success', $notify->out_trade_no);
-                return false;
+
+            Log::info('支付回调:' . json_encode($notify));
+
+            if ($successful) {
+                $data = [
+                    'attach' => $notify->attach,
+                    'out_trade_no' => $notify->out_trade_no,
+                    'transaction_id' => $notify->transaction_id
+                ];
+
+                return Event::until('pay.notify', [$data, PayServices::WEIXIN_PAY]);
             }
+
+            return false;
         });
     }
 }

+ 0 - 47
crmeb/crmeb/traits/ErrorTrait.php

@@ -1,47 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
-// +----------------------------------------------------------------------
-// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
-// +----------------------------------------------------------------------
-// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
-// +----------------------------------------------------------------------
-// | Author: CRMEB Team <admin@crmeb.com>
-// +----------------------------------------------------------------------
-namespace crmeb\traits;
-
-/**
- *
- * Class BaseError
- * @package crmeb\basic
- */
-trait ErrorTrait
-{
-    /**
-     * 错误信息
-     * @var string
-     */
-    protected $error;
-
-    /**
-     * 设置错误信息
-     * @param string|null $error
-     * @return bool
-     */
-    protected function setError(?string $error = null)
-    {
-        $this->error = $error ?: '未知错误';
-        return false;
-    }
-
-    /**
-     * 获取错误信息
-     * @return string
-     */
-    public function getError()
-    {
-        $error = $this->error;
-        $this->error = null;
-        return $error;
-    }
-}

+ 0 - 56
crmeb/crmeb/traits/SearchDaoTrait.php

@@ -1,56 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
-// +----------------------------------------------------------------------
-// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
-// +----------------------------------------------------------------------
-// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
-// +----------------------------------------------------------------------
-// | Author: CRMEB Team <admin@crmeb.com>
-// +----------------------------------------------------------------------
-
-namespace crmeb\traits;
-
-use app\dao\BaseDao;
-
-/**
- * 基础查询
- * Trait SearchDaoTrait
- * @package crmeb\traits
- * @mixin BaseDao
- */
-trait SearchDaoTrait
-{
-
-    /**
-     * 获取列表
-     * @param array $where
-     * @param array|string[] $field
-     * @param int $page
-     * @param int $limit
-     * @param null $sort
-     * @param array $with
-     * @return array
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-    public function getList(array $where = [], array $field = ['*'], int $page = 0, int $limit = 0, $sort = null, array $with = [])
-    {
-        return $this->search($where)->field($field)->when($page && $limit, function ($query) use ($page, $limit) {
-            $query->page($page, $limit);
-        })->when($sort, function ($query) use ($sort) {
-            if (is_array($sort)) {
-                foreach ($sort as $v => $k) {
-                    if (is_numeric($v)) {
-                        $query->order($k, 'desc');
-                    } else {
-                        $query->order($v, $k);
-                    }
-                }
-            } else {
-                $query->order($sort, 'desc');
-            }
-        })->with($with)->select()->toArray();
-    }
-}

+ 0 - 49
crmeb/crmeb/traits/ServicesTrait.php

@@ -1,49 +0,0 @@
-<?php
-// +----------------------------------------------------------------------
-// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
-// +----------------------------------------------------------------------
-// | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
-// +----------------------------------------------------------------------
-// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
-// +----------------------------------------------------------------------
-// | Author: CRMEB Team <admin@crmeb.com>
-// +----------------------------------------------------------------------
-namespace crmeb\traits;
-
-use think\Model;
-
-/**
- * Trait ServicesTrait
- * @package crmeb\traits
- * @method array|Model|null get($id, ?array $field = []) 获取一条数据
- * @method array|Model|null getOne(array $where, ?string $field = '*') 获取一条数据(不走搜素器)
- * @method string|null batchUpdate(array $ids, array $data, ?string $key = null) 批量修改
- * @method float sum(array $where, string $field, bool $search = false) 求和
- * @method mixed update($id, array $data, ?string $field) 修改数据
- * @method bool be($map, string $field = '') 查询一条数据是否存在
- * @method mixed value(array $where, string $field) 获取指定条件下的数据
- * @method int count(array $where = []) 读取数据条数
- * @method int getCount(array $where = []) 获取某些条件总数(不走搜素器)
- * @method array getColumn(array $where, string $field, string $key = '') 获取某个字段数组(不走搜素器)
- * @method mixed delete($id, ?string $key = null) 删除
- * @method mixed save(array $data) 保存数据
- * @method mixed saveAll(array $data) 批量保存数据
- * @method bool bcInc($key, string $incField, string $inc, string $keyField = null, int $acc = 2) 高精度加法
- * @method bool bcDec($key, string $decField, string $dec, string $keyField = null, int $acc = 2) 高精度 减法
- * @method mixed decStockIncSales(array $where, int $num, string $stock = 'stock', string $sales = 'sales') 减库存加销量
- * @method mixed incStockDecSales(array $where, int $num, string $stock = 'stock', string $sales = 'sales') 加库存减销量
- */
-trait ServicesTrait
-{
-
-    /**
-     * @return \crmeb\utils\Cache
-     * @author 等风来
-     * @email 136327134@qq.com
-     * @date 2023/2/8
-     */
-    public function cacheDriver()
-    {
-        return new \crmeb\utils\Cache($this->dao->getTableName());
-    }
-}

+ 27 - 2
crmeb/crmeb/utils/Queue.php

@@ -11,7 +11,6 @@
 
 namespace crmeb\utils;
 
-use crmeb\traits\ErrorTrait;
 use think\facade\Config;
 use think\facade\Queue as QueueThink;
 use think\facade\Log;
@@ -29,7 +28,33 @@ use think\facade\Log;
 class Queue
 {
 
-    use ErrorTrait;
+    /**
+     * 错误信息
+     * @var string
+     */
+    protected $error;
+
+    /**
+     * 设置错误信息
+     * @param string|null $error
+     * @return bool
+     */
+    protected function setError(?string $error = null)
+    {
+        $this->error = $error ?: '未知错误';
+        return false;
+    }
+
+    /**
+     * 获取错误信息
+     * @return string
+     */
+    public function getError()
+    {
+        $error = $this->error;
+        $this->error = null;
+        return $error;
+    }
 
     /**
      * 任务执行

+ 0 - 0
crmeb/public/.htaccess


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css.worker.js


BIN
crmeb/public/admin/css.worker.js.gz


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 2
crmeb/public/admin/css/app.9b3488d2.css


BIN
crmeb/public/admin/css/app.9b3488d2.css.gz


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-00f06b83.0c7fb962.css


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-028811c2.79268db6.css


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-02afff9e.7ef03ec2.css


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-03149c68.fac0fd59.css


+ 0 - 1
crmeb/public/admin/css/chunk-03c5c4a2.3606733e.css

@@ -1 +0,0 @@
-.rulesBox[data-v-75a46b5e]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center;-ms-flex-wrap:wrap;flex-wrap:wrap}.attrFrom[data-v-75a46b5e] .ivu-form-item{margin-bottom:0!important}

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-058eab4f.5bd359e2.css


BIN
crmeb/public/admin/css/chunk-058eab4f.5bd359e2.css.gz


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-07142a06.c25648f4.css


+ 0 - 1
crmeb/public/admin/css/chunk-07b5ff65.1b08dbb6.css

@@ -1 +0,0 @@
-.list[data-v-23ea9663]{height:80%;min-height:500px}.pictrue[data-v-23ea9663]{width:100%;max-width:300px;height:360px}.right[data-v-23ea9663]{padding-right:75px}.left[data-v-23ea9663]{padding-left:75px}.num[data-v-23ea9663]{margin-bottom:24px;color:#515a6e;font-weight:600;font-size:72px;line-height:72px}.desc[data-v-23ea9663]{margin-bottom:16px;color:#808695;font-size:20px;line-height:28px}

+ 0 - 1
crmeb/public/admin/css/chunk-081b585b.ce3128fb.css

@@ -1 +0,0 @@
-.QRpic[data-v-20c3b42e]{width:180px;height:180px}.QRpic img[data-v-20c3b42e]{width:100%;height:100%}

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-08c24f8e.4bc347be.css


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-09b3eff2.e60ad228.css


+ 0 - 1
crmeb/public/admin/css/chunk-0a6e99fd.bbf631f1.css

@@ -1 +0,0 @@
-.tabBox_img[data-v-7027361e]{width:36px;height:36px;border-radius:4px;cursor:pointer}.tabBox_img img[data-v-7027361e]{width:100%;height:100%}

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-0c05df09.ec625add.css


BIN
crmeb/public/admin/css/chunk-0c05df09.ec625add.css.gz


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-0ca76063.b9a345b5.css


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-0dd5615e.f7a9463b.css


BIN
crmeb/public/admin/css/chunk-0dd5615e.f7a9463b.css.gz


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-0f73c812.1b8d4ade.css


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-124c1be4.c486543b.css


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-13797d86.5bf9b10b.css


BIN
crmeb/public/admin/css/chunk-13797d86.5bf9b10b.css.gz


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-157b4f48.fb9470f3.css


+ 0 - 1
crmeb/public/admin/css/chunk-16138b40.34dad7de.css

@@ -1 +0,0 @@
-.box[data-v-82e63fd6]{width:100%;height:100%;background:#fff}[data-v-82e63fd6] .ivu-card-body{min-height:700px}[data-v-82e63fd6] .conter .pictrueList{max-width:100%}

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-16dc5aef.4ccdcbdc.css


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-186376ec.fa095460.css


BIN
crmeb/public/admin/css/chunk-186376ec.fa095460.css.gz


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-19de70eb.6f86bb2b.css


+ 0 - 1
crmeb/public/admin/css/chunk-1a3b818c.92333ade.css

@@ -1 +0,0 @@
-.ivu-form-label-left[data-v-405c4d5d] .ivu-form-item-label{text-align:right}.tabform .export[data-v-405c4d5d]{margin-left:10px}.red[data-v-405c4d5d]{color:#ff5722}.green[data-v-405c4d5d]{color:#009688}.ivu-mt[data-v-405c4d5d] .ivu-select-placeholder{height:32px}

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-1ab64b57.659a336b.css


+ 0 - 1
crmeb/public/admin/css/chunk-1c845e07.a1f0b1ed.css

@@ -1 +0,0 @@
-.tabBox_img[data-v-35cf4bf8]{width:36px;height:36px;border-radius:4px;cursor:pointer}.tabBox_img img[data-v-35cf4bf8]{width:100%;height:100%}.prize[data-v-35cf4bf8]{display:-webkit-box;display:-ms-flexbox;display:flex;-webkit-box-align:center;-ms-flex-align:center;align-items:center}.prize img[data-v-35cf4bf8]{width:36px;height:36px;border-radius:4px;cursor:pointer;margin-right:5px}.trips[data-v-35cf4bf8]{color:#ccc}

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-1eb2f024.da2c4a96.css


+ 0 - 1
crmeb/public/admin/css/chunk-1f894614.c0a99313.css

@@ -1 +0,0 @@
-.tabBox_img[data-v-160a2f5e]{width:36px;height:36px;border-radius:4px;cursor:pointer}.tabBox_img img[data-v-160a2f5e]{width:100%;height:100%}

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-240f368d.2a31843b.css


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-24dfe0e6.6ed9fb31.css


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-250ad9dd.e242bc05.css


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-2560a43a.272729ba.css


+ 0 - 1
crmeb/public/admin/css/chunk-29e98b5f.0357c398.css

@@ -1 +0,0 @@
-.tabBox_img[data-v-3abfb812]{width:36px;height:36px;border-radius:4px;cursor:pointer}.tabBox_img img[data-v-3abfb812]{width:100%;height:100%}

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-2b359071.e4a7c33a.css


+ 0 - 1
crmeb/public/admin/css/chunk-2b4d3374.62a7578b.css

@@ -1 +0,0 @@
-.tabBox_img[data-v-ea11ee44]{width:36px;height:36px;border-radius:4px;cursor:pointer}.tabBox_img img[data-v-ea11ee44]{width:100%;height:100%}

+ 0 - 1
crmeb/public/admin/css/chunk-2e90bd4b.9805da2f.css

@@ -1 +0,0 @@
-.input[data-v-7c5354e2]{width:400px}

+ 0 - 1
crmeb/public/admin/css/chunk-2eae1aba.e46873bd.css

@@ -1 +0,0 @@
-[data-v-49837f74] .ivu-tag-cyan .ivu-tag-text{color:#19be6b!important}.ivu-tag-cyan[data-v-49837f74]{background:rgba(25,190,170,.1);border-color:#19be6b!important}.tabBox_img[data-v-49837f74]{width:36px;height:36px;border-radius:4px;cursor:pointer}.tabBox_img img[data-v-49837f74]{width:100%;height:100%}

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-2fb735d0.d7bbb8c6.css


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-32d3326e.58ba8f69.css


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-342f0a0a.1a0666d4.css


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 0 - 1
crmeb/public/admin/css/chunk-347f00e3.41211080.css


+ 0 - 0
crmeb/public/admin/css/chunk-35aca391.47a587bd.css


Algunos archivos no se mostraron porque demasiados archivos cambiaron en este cambio