Procházet zdrojové kódy

【程序目录】更新v5.2.1版本

evoxwht před 2 roky
rodič
revize
98abf89b2a
100 změnil soubory, kde provedl 718 přidání a 1900 odebrání
  1. 2 2
      crmeb/.version
  2. 151 1644
      crmeb/app/adminapi/controller/UpgradeController.php
  3. 8 8
      crmeb/app/adminapi/controller/v1/agent/AgentLevel.php
  4. 4 0
      crmeb/app/adminapi/controller/v1/file/SystemAttachmentCategory.php
  5. 1 0
      crmeb/app/adminapi/controller/v1/marketing/StoreBargain.php
  6. 2 0
      crmeb/app/adminapi/controller/v1/marketing/StoreCouponIssue.php
  7. 1 0
      crmeb/app/adminapi/controller/v1/marketing/StoreSeckill.php
  8. 62 23
      crmeb/app/adminapi/controller/v1/order/StoreOrder.php
  9. 4 1
      crmeb/app/adminapi/controller/v1/setting/SystemConfig.php
  10. 18 6
      crmeb/app/adminapi/controller/v1/setting/SystemCrud.php
  11. 1 1
      crmeb/app/adminapi/controller/v1/setting/SystemRole.php
  12. 2 0
      crmeb/app/adminapi/route/order.php
  13. 2 1
      crmeb/app/api/controller/v1/order/StoreOrderController.php
  14. 1 0
      crmeb/app/api/controller/v1/store/StoreCartController.php
  15. 2 1
      crmeb/app/common.php
  16. 1 1
      crmeb/app/dao/order/StoreOrderDao.php
  17. 1 1
      crmeb/app/dao/product/product/StoreProductLogDao.php
  18. 2 0
      crmeb/app/dao/user/UserBrokerageDao.php
  19. 10 0
      crmeb/app/model/activity/coupon/StoreCouponIssue.php
  20. 2 2
      crmeb/app/services/activity/bargain/StoreBargainServices.php
  21. 1 1
      crmeb/app/services/activity/combination/StoreCombinationServices.php
  22. 13 0
      crmeb/app/services/activity/coupon/StoreCouponIssueServices.php
  23. 36 41
      crmeb/app/services/agent/AgentLevelServices.php
  24. 3 0
      crmeb/app/services/agent/AgentManageServices.php
  25. 1 1
      crmeb/app/services/agent/DivisionAgentApplyServices.php
  26. 16 0
      crmeb/app/services/order/StoreCartServices.php
  27. 12 8
      crmeb/app/services/order/StoreOrderComputedServices.php
  28. 61 16
      crmeb/app/services/order/StoreOrderCreateServices.php
  29. 1 0
      crmeb/app/services/order/StoreOrderRefundServices.php
  30. 126 19
      crmeb/app/services/order/StoreOrderServices.php
  31. 6 2
      crmeb/app/services/order/StoreOrderTakeServices.php
  32. 58 33
      crmeb/app/services/other/export/ExportServices.php
  33. 1 1
      crmeb/app/services/pc/OrderServices.php
  34. 1 0
      crmeb/app/services/product/product/CopyTaobaoServices.php
  35. 1 1
      crmeb/app/services/product/product/StoreProductServices.php
  36. 3 0
      crmeb/app/services/product/sku/StoreProductAttrServices.php
  37. 4 1
      crmeb/app/services/system/SystemMenusServices.php
  38. 22 22
      crmeb/app/services/system/UpgradeServices.php
  39. 3 0
      crmeb/app/services/system/attachment/SystemAttachmentServices.php
  40. 1 1
      crmeb/app/services/system/config/SystemConfigServices.php
  41. 2 2
      crmeb/app/services/system/lang/LangCodeServices.php
  42. 1 1
      crmeb/app/services/user/UserBillServices.php
  43. 13 12
      crmeb/app/services/user/UserRechargeServices.php
  44. 1 1
      crmeb/app/services/user/UserServices.php
  45. 5 3
      crmeb/app/services/user/UserSignServices.php
  46. 3 2
      crmeb/app/services/wechat/WechatUserServices.php
  47. 1 1
      crmeb/crmeb/services/FileService.php
  48. 1 8
      crmeb/crmeb/services/SystemConfigService.php
  49. 5 5
      crmeb/crmeb/services/app/MiniProgramService.php
  50. 4 1
      crmeb/crmeb/utils/Canvas.php
  51. 1 1
      crmeb/crmeb/utils/DownloadImage.php
  52. 6 1
      crmeb/crmeb/utils/Translate.php
  53. 1 1
      crmeb/public/admin/css.worker.js
  54. 1 1
      crmeb/public/admin/editor.worker.js
  55. 1 1
      crmeb/public/admin/html.worker.js
  56. 1 1
      crmeb/public/admin/index.html
  57. 1 1
      crmeb/public/admin/json.worker.js
  58. 0 1
      crmeb/public/admin/system_static/css/app.176ec911.css
  59. 1 0
      crmeb/public/admin/system_static/css/app.232e71fd.css
  60. 0 0
      crmeb/public/admin/system_static/css/chunk-00655988.6ed9fb31.css
  61. 0 1
      crmeb/public/admin/system_static/css/chunk-01461622.1098cd10.css
  62. 1 1
      crmeb/public/admin/system_static/css/chunk-2a1551d0.6442138e.css
  63. 0 0
      crmeb/public/admin/system_static/css/chunk-02077a46.5a5b6f08.css
  64. 1 0
      crmeb/public/admin/system_static/css/chunk-024eff44.ff0a8596.css
  65. 1 0
      crmeb/public/admin/system_static/css/chunk-0322990a.0e99d3e7.css
  66. 0 1
      crmeb/public/admin/system_static/css/chunk-033cc77a.eeab2c78.css
  67. 0 0
      crmeb/public/admin/system_static/css/chunk-03eeaf0a.015ae8dc.css
  68. 0 1
      crmeb/public/admin/system_static/css/chunk-046498a8.98bd250f.css
  69. 1 0
      crmeb/public/admin/system_static/css/chunk-054ceee2.42b60f9c.css
  70. 0 1
      crmeb/public/admin/system_static/css/chunk-05c82e7c.0f4894db.css
  71. 1 0
      crmeb/public/admin/system_static/css/chunk-061b084e.cd13fc3d.css
  72. 1 0
      crmeb/public/admin/system_static/css/chunk-0643a4f2.e5125496.css
  73. 1 1
      crmeb/public/admin/system_static/css/chunk-7a4913de.c6be2663.css
  74. 1 0
      crmeb/public/admin/system_static/css/chunk-064d51c3.4e1572a5.css
  75. 1 0
      crmeb/public/admin/system_static/css/chunk-0688ae90.5b71a1cf.css
  76. 1 0
      crmeb/public/admin/system_static/css/chunk-071887cb.68de37ff.css
  77. 0 1
      crmeb/public/admin/system_static/css/chunk-075215e2.3d9f8610.css
  78. 1 0
      crmeb/public/admin/system_static/css/chunk-081c9142.78c3202d.css
  79. 1 1
      crmeb/public/admin/system_static/css/chunk-88073580.50ba8057.css
  80. 0 1
      crmeb/public/admin/system_static/css/chunk-0a2fde4e.548e94e4.css
  81. 0 1
      crmeb/public/admin/system_static/css/chunk-0a5259ae.b8a8a02d.css
  82. 0 1
      crmeb/public/admin/system_static/css/chunk-0b026fe8.53eb8477.css
  83. 0 1
      crmeb/public/admin/system_static/css/chunk-0bd0e879.c849c1ba.css
  84. 1 1
      crmeb/public/admin/system_static/css/chunk-9f697dde.b7d88feb.css
  85. 1 0
      crmeb/public/admin/system_static/css/chunk-0dfd6ce5.654d0859.css
  86. 1 0
      crmeb/public/admin/system_static/css/chunk-0e9fe7d9.8d0bf5f4.css
  87. 0 0
      crmeb/public/admin/system_static/css/chunk-0f1100c7.2a5ea5e7.css
  88. 1 0
      crmeb/public/admin/system_static/css/chunk-0f31d873.267957b0.css
  89. 1 0
      crmeb/public/admin/system_static/css/chunk-0fe5659e.9af0ccac.css
  90. 0 1
      crmeb/public/admin/system_static/css/chunk-102ae29a.1888ad6b.css
  91. 0 1
      crmeb/public/admin/system_static/css/chunk-12af24b5.92287fd9.css
  92. 1 1
      crmeb/public/admin/system_static/css/chunk-147099df.79ccad36.css
  93. 0 0
      crmeb/public/admin/system_static/css/chunk-12faac12.9ec65ea6.css
  94. 1 0
      crmeb/public/admin/system_static/css/chunk-1334fe21.4d8bf09c.css
  95. 1 0
      crmeb/public/admin/system_static/css/chunk-1378e6e4.306eb365.css
  96. 1 1
      crmeb/public/admin/system_static/css/chunk-22b4cd9b.d3f412cb.css
  97. 0 0
      crmeb/public/admin/system_static/css/chunk-14a3aaa0.af3b01f2.css
  98. 0 1
      crmeb/public/admin/system_static/css/chunk-151dd58b.9e8f70ba.css
  99. 1 0
      crmeb/public/admin/system_static/css/chunk-15477b66.deefe305.css
  100. 0 0
      crmeb/public/admin/system_static/css/chunk-15f7d94c.77da8061.css

+ 2 - 2
crmeb/.version

@@ -1,5 +1,5 @@
-version=CRMEB-KY v5.2.0
-version_code=520
+version=CRMEB-KY v5.2.1
+version_code=521
 platform=gitee
 app_id=ze7x9rxsv09l6pvsyo
 app_key=fuF7U9zaybLa5gageVQzxtxQMFnvU2OI

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 151 - 1644
crmeb/app/adminapi/controller/UpgradeController.php


+ 8 - 8
crmeb/app/adminapi/controller/v1/agent/AgentLevel.php

@@ -69,13 +69,13 @@ class AgentLevel extends AuthController
             ['name', ''],
             ['grade', 0],
             ['image', ''],
-            ['one_brokerage', 0],
-            ['two_brokerage', 0],
+            ['one_brokerage_percent', 0],
+            ['two_brokerage_percent', 0],
             ['status', 0]]);
         if (!$data['name']) return app('json')->fail(400200);
         if (!$data['grade']) return app('json')->fail(400201);
         if (!$data['image']) return app('json')->fail(400202);
-        if ($data['two_brokerage'] > $data['one_brokerage']) {
+        if ($data['two_brokerage_percent'] > $data['one_brokerage_percent']) {
             return app('json')->fail(400203);
         }
         $grade = $this->services->get(['grade' => $data['grade'], 'is_del' => 0]);
@@ -121,13 +121,13 @@ class AgentLevel extends AuthController
             ['name', ''],
             ['grade', 0],
             ['image', ''],
-            ['one_brokerage', 0],
-            ['two_brokerage', 0],
+            ['one_brokerage_percent', 0],
+            ['two_brokerage_percent', 0],
             ['status', 0]]);
         if (!$data['name']) return app('json')->fail(400200);
         if (!$data['grade']) return app('json')->fail(400201);
         if (!$data['image']) return app('json')->fail(400202);
-        if ($data['two_brokerage'] > $data['one_brokerage']) {
+        if ($data['two_brokerage_percent'] > $data['one_brokerage_percent']) {
             return app('json')->fail(400203);
         }
         if (!$levelInfo = $this->services->getLevelInfo((int)$id)) return app('json')->fail(400206);
@@ -139,8 +139,8 @@ class AgentLevel extends AuthController
         $levelInfo->name = $data['name'];
         $levelInfo->grade = $data['grade'];
         $levelInfo->image = $data['image'];
-        $levelInfo->one_brokerage = $data['one_brokerage'];
-        $levelInfo->two_brokerage = $data['two_brokerage'];
+        $levelInfo->one_brokerage_percent = $data['one_brokerage_percent'];
+        $levelInfo->two_brokerage_percent = $data['two_brokerage_percent'];
         $levelInfo->status = $data['status'];
         $levelInfo->save();
         return app('json')->success(100001);

+ 4 - 0
crmeb/app/adminapi/controller/v1/file/SystemAttachmentCategory.php

@@ -75,6 +75,7 @@ class SystemAttachmentCategory extends AuthController
             ['pid', 0],
             ['name', '']
         ]);
+        if (is_array($data['pid'])) $data['pid'] = end($data['pid']);
         if (!$data['name']) {
             return app('json')->fail(400100);
         }
@@ -108,6 +109,9 @@ class SystemAttachmentCategory extends AuthController
         if (!$data['name']) {
             return app('json')->fail(400100);
         }
+        if ($data['pid'] == $id) {
+            return app('json')->fail('上级分类不能是自己');
+        }
         $info = $this->service->get($id);
         $count = $this->service->count(['pid' => $id]);
         if ($count && $info['pid'] != $data['pid']) return app('json')->fail(400105);

+ 1 - 0
crmeb/app/adminapi/controller/v1/marketing/StoreBargain.php

@@ -87,6 +87,7 @@ class StoreBargain extends AuthController
             ['postage', 0],//邮费
             ['custom_form', ''],
             ['virtual_type', 0],
+            ['is_commission', 0],
         ]);
         $this->validate($data, \app\adminapi\validate\marketing\StoreBargainValidate::class, 'save');
         if ($data['section_time']) {

+ 2 - 0
crmeb/app/adminapi/controller/v1/marketing/StoreCouponIssue.php

@@ -43,6 +43,7 @@ class StoreCouponIssue extends AuthController
             ['coupon_title', ''],
             ['receive_type', ''],
             ['type', ''],
+            ['coupon_type', ''],
         ]);
         $list = $this->services->getCouponIssueList($where);
         return app('json')->success($list);
@@ -55,6 +56,7 @@ class StoreCouponIssue extends AuthController
     public function saveCoupon()
     {
         $data = $this->request->postMore([
+            ['id', 0],
             ['coupon_title', ''],
             ['coupon_price', 0.00],
             ['use_min_price', 0.00],

+ 1 - 0
crmeb/app/adminapi/controller/v1/marketing/StoreSeckill.php

@@ -87,6 +87,7 @@ class StoreSeckill extends AuthController
             ['postage', 0],//邮费
             ['custom_form', ''],
             ['virtual_type', 0],
+            ['is_commission', 0],
         ]);
         $this->validate($data, \app\adminapi\validate\marketing\StoreSeckillValidate::class, 'save');
         $this->services->saveData($id, $data);

+ 62 - 23
crmeb/app/adminapi/controller/v1/order/StoreOrder.php

@@ -14,6 +14,7 @@ use app\adminapi\controller\AuthController;
 use app\adminapi\validate\order\StoreOrderValidate;
 use app\jobs\OrderExpressJob;
 use app\services\serve\ServeServices;
+use app\services\wechat\WechatUserServices;
 use crmeb\services\FileService;
 use app\services\order\{StoreOrderCartInfoServices,
     StoreOrderDeliveryServices,
@@ -452,7 +453,7 @@ class StoreOrder extends AuthController
         if (!$id) {
             return app('json')->fail(100100);
         }
-        return app('json')->success($services->refundOrderForm((int)$id));
+        return app('json')->success($services->refundOrderForm((int)$id, 'order'));
     }
 
     /**
@@ -467,7 +468,6 @@ class StoreOrder extends AuthController
     {
         $data = $this->request->postMore([
             ['refund_price', 0],
-            ['type', 1]
         ]);
         if (!$id) {
             return app('json')->fail(100100);
@@ -476,44 +476,63 @@ class StoreOrder extends AuthController
         if (!$order) {
             return app('json')->fail(400118);
         }
+
+        $refundData = [
+            'refund_reason' => '后台主动退款',
+            'refund_explain' => '后台主动退款',
+            'refund_img' => json_encode([]),
+        ];
+
+        $res = $services->applyRefund((int)$id, $order['uid'], $order, [], 1, (float)$data['refund_price'], $refundData);
+
+        if (!$res) {
+            return app('json')->fail('退款单生成失败');
+        }
+
+        $orderRefund = $services->get(['store_order_id' => $id]);
+
+
+        $data['refund_status'] = 2;
+        $data['refund_type'] = 6;
+        $data['refunded_time'] = time();
+
         //0元退款
-        if ($order['pay_price'] == 0 && in_array($order['refund_status'], [0, 1])) {
+        if ($orderRefund['refund_price'] == 0 && in_array($orderRefund['refund_type'], [1, 5])) {
             $refund_price = 0;
         } else {
-            if ($order['pay_price'] == $order['refund_price']) {
-                return app('json')->fail(400147);
-            }
             if (!$data['refund_price']) {
                 return app('json')->fail(400146);
             }
-            $refund_price = $data['refund_price'];
-            $data['refund_price'] = bcadd($data['refund_price'], $order['refund_price'], 2);
-            $bj = bccomp((string)$order['pay_price'], (string)$data['refund_price'], 2);
-            if ($bj < 0) {
-                return app('json')->fail(400148);
+            if ($orderRefund['refund_price'] == $orderRefund['refunded_price']) {
+                return app('json')->fail(400147);
             }
+            $refund_price = $data['refund_price'];
         }
-        if ($data['type'] == 1) {
-            $data['refund_status'] = 2;
-        } else if ($data['type'] == 2) {
-            $data['refund_status'] = 0;
+
+        $data['refunded_price'] = bcadd($data['refund_price'], $orderRefund['refunded_price'], 2);
+        $bj = bccomp((string)$orderRefund['refund_price'], (string)$data['refunded_price'], 2);
+        if ($bj < 0) {
+            return app('json')->fail(400148);
         }
-        $data['refund_type'] = 6;
-        $type = $data['type'];
-        unset($data['type']);
+
         $refund_data['pay_price'] = $order['pay_price'];
         $refund_data['refund_price'] = $refund_price;
         if ($order['refund_price'] > 0) {
+            mt_srand();
             $refund_data['refund_id'] = $order['order_id'] . rand(100, 999);
         }
-        //退款处理
-        $services->payOrderRefund($type, $order, $refund_data);
+        ($order['pid'] > 0) ? $refund_data['order_id'] = $this->services->value(['id' => (int)$order['pid']], 'order_id') : $refund_data['order_id'] = $order['order_id'];
+        /** @var WechatUserServices $wechatUserServices */
+        $wechatUserServices = app()->make(WechatUserServices::class);
+        $refund_data['open_id'] = $wechatUserServices->uidToOpenid((int)$order['uid'], 'routine') ?? '';
+        $refund_data['refund_no'] = $orderRefund['order_id'];
         //修改订单退款状态
-        if ($this->services->update($id, $data)) {
-            $services->storeProductOrderRefundY($data, $order, $refund_price);
+        unset($data['refund_price']);
+        if ($services->agreeRefund($orderRefund['id'], $refund_data)) {
+            $services->update($orderRefund['id'], $data);
             return app('json')->success(400149);
         } else {
-            $services->storeProductOrderRefundYFasle((int)$id, $refund_price);
+            $services->storeProductOrderRefundYFasle((int)$orderRefund['id'], $refund_price);
             return app('json')->fail(400150);
         }
     }
@@ -883,4 +902,24 @@ class StoreOrder extends AuthController
         }
         return app('json')->success('批量发货成功');
     }
+
+    /**
+     * 配货单
+     * @param $order_id
+     * @return \think\Response
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author: 吴汐
+     * @email: 442384644@qq.com
+     * @date: 2023/10/11
+     */
+    public function printShipping($order_id)
+    {
+        if (!$order_id) {
+            return app('json')->fail('参数错误');
+        }
+        $data = $this->services->printShippingData($order_id);
+        return app('json')->success($data);
+    }
 }

+ 4 - 1
crmeb/app/adminapi/controller/v1/setting/SystemConfig.php

@@ -340,7 +340,7 @@ class SystemConfig extends AuthController
             if (!is_int($post['sign_give_point']) || $post['sign_give_point'] < 0) return app('json')->fail('签到赠送积分请填写大于等于0的整数');
         }
         if (isset($post['sign_give_exp'])) {
-            if (!is_int($post['sign_give_exp']) || $post['sign_give_exp'] < 0) return app('json')->fail('签到赠送经验请填写大于等于0的整数');
+            if ((int)$post['sign_give_exp'] < 0) return app('json')->fail('签到赠送经验请填写大于等于0的整数');
         }
         if (isset($post['integral_frozen'])) {
             if (!ctype_digit($post['integral_frozen']) || $post['integral_frozen'] < 0) return app('json')->fail('积分冻结天数请填写大于等于0的整数');
@@ -358,6 +358,9 @@ class SystemConfig extends AuthController
         if (isset($post['customer_phone'])) {
             if (!ctype_digit($post['customer_phone']) || strlen($post['customer_phone']) > 11) return app('json')->fail('客服手机号为11位数字');
         }
+        if (isset($post['refund_time_available'])) {
+            if (!ctype_digit($post['refund_time_available'])) return app('json')->fail('售后期限必须为大于0的整数');
+        }
 
         foreach ($post as $k => $v) {
             $config_one = $this->services->getOne(['menu_name' => $k]);

+ 18 - 6
crmeb/app/adminapi/controller/v1/setting/SystemCrud.php

@@ -20,12 +20,15 @@ use app\services\system\log\SystemFileServices;
 use app\services\system\SystemCrudDataService;
 use app\services\system\SystemCrudServices;
 use app\services\system\SystemMenusServices;
+use app\services\system\SystemRouteServices;
 use crmeb\services\CacheService;
 use crmeb\services\crud\enum\FormTypeEnum;
 use crmeb\services\crud\Make;
 use crmeb\services\crud\Service;
 use crmeb\services\FileService;
 use think\facade\App;
+use think\facade\Db;
+use think\facade\Env;
 use think\helper\Str;
 use think\Response;
 
@@ -548,13 +551,20 @@ class SystemCrud extends AuthController
             return app('json')->fail(100026);
         }
 
-        $services->transaction(function () use ($services, $info) {
-            if ($info->menu_ids) {
-                $services->deleteMenus($info->menu_ids);
-            }
+        $menusServices = app()->make(SystemMenusServices::class);
+        if ($info->menu_ids) {
+            $menusServices->deleteMenus($info->menu_ids);
+        }
+        if ($info->menu_id) {
+            $menusServices->deleteMenus([$info->menu_id]);
+        }
 
-            $info->delete();
-        });
+        $routeServices = app()->make(SystemRouteServices::class);
+        if ($info->route_ids) {
+            $routeServices->deleteRoutes($info->route_ids);
+        }
+
+        Db::query("DROP TABLE `" . Env::get('database.prefix', 'eb_') . $info->table_name . "`");
 
         if ($info->make_path) {
             $errorFile = [];
@@ -577,6 +587,8 @@ class SystemCrud extends AuthController
             }
         }
 
+        $info->delete();
+
 
         return app('json')->success(100002);
     }

+ 1 - 1
crmeb/app/adminapi/controller/v1/setting/SystemRole.php

@@ -106,7 +106,7 @@ class SystemRole extends AuthController
         if (!$role) {
             return app('json')->fail(100100);
         }
-        $menus = $services->getMenus($this->adminInfo['level'] == 0 ? [] : $this->adminInfo['roles']);
+        $menus = $services->getMenus($this->adminInfo['level'] == 0 ? [] : $this->adminInfo['roles'], explode(',', $role['rules']));
         return app('json')->success(['role' => $role->toArray(), 'menus' => $menus]);
     }
 

+ 2 - 0
crmeb/app/adminapi/route/order.php

@@ -112,6 +112,8 @@ Route::group('order', function () {
     Route::get('delivery/list', 'v1.order.DeliveryService/get_delivery_list')->option(['real_name' => '订单列表获取配送员']);
     //电子面单模板列表
     Route::get('expr/temp', 'v1.order.StoreOrder/expr_temp')->option(['real_name' => '电子面单模板列表']);
+    //打印发货单
+    Route::get('print/shipping/:order_id', 'v1.order.StoreOrder/printShipping')->option(['real_name' => '打印发货单']);
 
     //更多操作打印电子面单
     Route::get('order_dump/:order_id', 'v1.order.StoreOrder/order_dump')->option(['real_name' => '更多操作打印电子面单']);

+ 2 - 1
crmeb/app/api/controller/v1/order/StoreOrderController.php

@@ -559,7 +559,8 @@ class StoreOrderController
             'unique' => $unique,
             'product_id' => $productId,
             'add_time' => time(),
-            'reply_type' => 'product'
+            'reply_type' => 'product',
+            'suk' => $cartInfo['cart_info']['productInfo']['attrInfo']['suk']
         ]);
 
         $res = $replyServices->save($group);

+ 1 - 0
crmeb/app/api/controller/v1/store/StoreCartController.php

@@ -87,6 +87,7 @@ class StoreCartController
         } elseif ($where['advanceId']) {
             $type = 6;
         }
+        if ($type == 0) $cartService->checkVipGoodsBuy($request->user(), $where['productId']);
         $res = $cartService->setCart($request->uid(), $where['productId'], $where['cartNum'], $where['uniqueId'], $type, $new, $where['combinationId'], $where['secKillId'], $where['bargainId'], $where['advanceId']);
         if (!$res) return app('json')->fail(100022);
         else  return app('json')->success(['cartId' => $res]);

+ 2 - 1
crmeb/app/common.php

@@ -220,7 +220,8 @@ if (!function_exists('make_path')) {
         } catch (\Exception $e) {
             if ($force)
                 throw new \Exception($e->getMessage());
-            return '无法创建文件夹,请检查您的上传目录权限:' . app()->getRootPath() . 'public' . DS . 'uploads' . DS . 'attach' . DS;
+//            return '无法创建文件夹,请检查您的上传目录权限:' . app()->getRootPath() . 'public' . DS . 'uploads' . DS . 'attach' . DS;
+            return '';
         }
 
     }

+ 1 - 1
crmeb/app/dao/order/StoreOrderDao.php

@@ -174,7 +174,7 @@ class StoreOrderDao extends BaseDao
             }
         })->when($realName && !$fieldKey, function ($query) use ($where) {
             $query->where(function ($que) use ($where) {
-                $que->whereLike('order_id|real_name', '%' . $where['real_name'] . '%')->whereOr('uid', 'in', function ($q) use ($where) {
+                $que->whereLike('order_id|real_name|user_phone', '%' . $where['real_name'] . '%')->whereOr('uid', 'in', function ($q) use ($where) {
                     $q->name('user')->whereLike('nickname|uid|phone', '%' . $where['real_name'] . '%')->field(['uid'])->select();
                 })->whereOr('id', 'in', function ($que) use ($where) {
                     $que->name('store_order_cart_info')->whereIn('product_id', function ($q) use ($where) {

+ 1 - 1
crmeb/app/dao/product/product/StoreProductLogDao.php

@@ -38,7 +38,7 @@ class StoreProductLogDao extends BaseDao
                 'SUM(pay_num) as pay',
                 'SUM(pay_price * pay_num) as price',
                 'SUM(cost_price) as cost',
-                'ROUND((SUM(pay_price)-SUM(cost_price))/SUM(cost_price),2) as profit',
+                'ROUND((SUM(pay_price)-SUM(cost_price))/SUM(pay_price),2) as profit',
                 'SUM(collect_num) as collect',
                 'ROUND((COUNT(distinct(pay_uid))-1)/COUNT(distinct(uid)),2) as changes',
                 'COUNT(distinct(pay_uid))-1 as repeats'

+ 2 - 0
crmeb/app/dao/user/UserBrokerageDao.php

@@ -73,6 +73,7 @@ class UserBrokerageDao extends BaseDao
     public function brokerageRankList(array $where, int $page = 0, int $limit = 0)
     {
         //SUM(IF(pm=1,`number`,-`number`))
+        if ($where['pm'] == 1) $where['not_type'] = ['extract_fail'];
         return $this->search($where)->field('uid,SUM(number) as brokerage_price')->with(['user' => function ($query) {
             $query->field('uid,avatar,nickname');
         }])->order('brokerage_price desc')->group('uid')->when($page && $limit, function ($query) use ($page, $limit) {
@@ -88,6 +89,7 @@ class UserBrokerageDao extends BaseDao
      */
     public function getBrokerageSumColumn(array $where)
     {
+        if ($where['pm'] == 1) $where['not_type'] = ['extract_fail'];
         if (isset($where['uid']) && is_array($where['uid'])) {
             return $this->search($where)->group('uid')->column('sum(number) as num', 'uid');
         } else

+ 10 - 0
crmeb/app/model/activity/coupon/StoreCouponIssue.php

@@ -134,4 +134,14 @@ class StoreCouponIssue extends BaseModel
     {
         if ($value) $query->whereLike('coupon_title', '%' . $value . '%');
     }
+
+    /**
+     * 优惠券类型
+     * @param Model $query
+     * @param $value
+     */
+    public function searchCouponTypeAttr($query, $value)
+    {
+        if ($value != '') $query->where('type', $value);
+    }
 }

+ 2 - 2
crmeb/app/services/activity/bargain/StoreBargainServices.php

@@ -871,7 +871,7 @@ class StoreBargainServices extends BaseServices
         }
         /** @var StoreBargainUserServices $services */
         $services = app()->make(StoreBargainUserServices::class);
-        $bargainUser = $services->get(['bargain_id' => $bargainId, 'uid' => $user['uid']], ['price', 'bargain_price_min']);
+        $bargainUser = $services->get(['bargain_id' => $bargainId, 'uid' => $user['uid'], 'status' => 1], ['price', 'bargain_price_min']);
         if (!$bargainUser) {
             throw new ApiException(410304);
         }
@@ -1029,7 +1029,7 @@ class StoreBargainServices extends BaseServices
         [$page, $limit] = $this->getPageValue();
         $where = $where + ['paid' => 1, 'refund_status' => 0, 'is_del' => 0];
         $list = $orderServices->bargainStatisticsOrder($id, $where, $page, $limit);
-        $count = $orderServices->bargainStatisticsOrderCount($where);
+        $count = $orderServices->bargainStatisticsOrderCount($id, $where);
         foreach ($list as &$item) {
             if ($item['status'] == 0) {
                 if ($item['paid'] == 0) {

+ 1 - 1
crmeb/app/services/activity/combination/StoreCombinationServices.php

@@ -662,7 +662,7 @@ class StoreCombinationServices extends BaseServices
         [$page, $limit] = $this->getPageValue();
         $where = $where + ['paid' => 1, 'refund_status' => 0, 'is_del' => 0];
         $list = $orderServices->combinationStatisticsOrder($id, $where, $page, $limit);
-        $count = $orderServices->combinationStatisticsCount($where);
+        $count = $orderServices->combinationStatisticsCount($id, $where);
         foreach ($list as &$item) {
             if ($item['status'] == 0) {
                 if ($item['paid'] == 0) {

+ 13 - 0
crmeb/app/services/activity/coupon/StoreCouponIssueServices.php

@@ -89,6 +89,19 @@ class StoreCouponIssueServices extends BaseServices
      */
     public function saveCoupon($data)
     {
+        if ($data['id']) {
+            $res = $this->dao->update($data['id'], [
+                'coupon_title' => $data['coupon_title'],
+                'title' => $data['coupon_title'],
+                'total_count' => $data['total_count'],
+                'remain_count' => $data['total_count'],
+                'receive_limit' => $data['receive_limit'],
+                'status' => $data['status'],
+            ]);
+            if (!$res) throw new AdminException(100007);
+            return (int)$data['id'];
+        }
+
         if ($data['start_time'] && $data['start_use_time']) {
 
             if ($data['start_time'] < date('Y-m-d 00:00:00')) {

+ 36 - 41
crmeb/app/services/agent/AgentLevelServices.php

@@ -210,46 +210,41 @@ class AgentLevelServices extends BaseServices
 
     /**
      * 分销等级上浮
-     * @param int $uid
-     * @param array $userInfo
+     * @param $storeBrokerageRatio
+     * @param $storeBrokerageTwo
+     * @param $spread_one_uid
+     * @param $spread_two_uid
      * @return array|int[]
      * @throws \think\db\exception\DataNotFoundException
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    public function getAgentLevelBrokerage(int $uid, $userInfo = [])
+    public function getAgentLevelBrokerage($storeBrokerageRatio, $storeBrokerageTwo, $spread_one_uid, $spread_two_uid)
     {
-        $one_brokerage_up = $two_brokerage_up = $spread_one_uid = $spread_two_uid = 0;
-        if (!$uid) {
-            return [$one_brokerage_up, $two_brokerage_up, $spread_one_uid, $spread_two_uid];
-        }
-        //商城分销是否开启
-        if (!sys_config('brokerage_func_status')) {
-            return [$one_brokerage_up, $two_brokerage_up, $spread_one_uid, $spread_two_uid];
-        }
         /** @var UserServices $userServices */
         $userServices = app()->make(UserServices::class);
-        if (!$userInfo) {
-            $userInfo = $userServices->getUserInfo($uid);
-        }
-        if (!$userInfo) {
-            return [$one_brokerage_up, $two_brokerage_up, $spread_one_uid, $spread_two_uid];
+        $one_agent_level = $userServices->value(['uid' => $spread_one_uid], 'agent_level') ?? 0;
+        $two_agent_level = $userServices->value(['uid' => $spread_two_uid], 'agent_level') ?? 0;
+
+        if ($one_agent_level) {
+            $oneLevelInfo = $this->getLevelInfo($one_agent_level);
+            if ($oneLevelInfo['one_brokerage_percent'] == '0.00') {
+                $storeBrokerageRatio = $storeBrokerageRatio + (($storeBrokerageRatio * $oneLevelInfo['one_brokerage'] ?? 0) / 100);
+            } else {
+                $storeBrokerageRatio = $oneLevelInfo['one_brokerage_percent'];
+            }
         }
-        //获取上级uid || 开启自购返回自己uid
-        $spread_one_uid = $userServices->getSpreadUid($uid, $userInfo);
-        $one_agent_level = 0;
-        $two_agent_level = 0;
-        $spread_two_uid = 0;
-        if ($spread_one_uid > 0 && $one_user_info = $userServices->getUserInfo($spread_one_uid)) {
-            $one_agent_level = $one_user_info['agent_level'] ?? 0;
-            $spread_two_uid = $userServices->getSpreadUid($spread_one_uid, $one_user_info, false);
-            if ($spread_two_uid > 0 && $two_user_info = $userServices->getUserInfo($spread_two_uid)) {
-                $two_agent_level = $two_user_info['agent_level'] ?? 0;
+
+        if ($two_agent_level) {
+            $twoLevelInfo = $this->getLevelInfo($two_agent_level);
+            if ($twoLevelInfo['two_brokerage_percent'] == '0.00') {
+                $storeBrokerageTwo = $storeBrokerageTwo + (($storeBrokerageTwo * $twoLevelInfo['two_brokerage'] ?? 0) / 100);
+            } else {
+                $storeBrokerageTwo = $twoLevelInfo['two_brokerage_percent'];
             }
         }
-        $one_brokerage_up = $one_agent_level ? ($this->getLevelInfo($one_agent_level)['one_brokerage'] ?? 0) : 0;
-        $two_brokerage_up = $two_agent_level ? ($this->getLevelInfo($two_agent_level)['two_brokerage'] ?? 0) : 0;
-        return [$one_brokerage_up, $two_brokerage_up, $spread_one_uid, $spread_two_uid];
+
+        return [$storeBrokerageRatio, $storeBrokerageTwo];
     }
 
     /**
@@ -263,16 +258,16 @@ class AgentLevelServices extends BaseServices
         $field[] = Form::input('name', '等级名称')->maxlength(8)->col(24);
         $field[] = Form::number('grade', '等级', 0)->min(0)->precision(0);
         $field[] = Form::frameImage('image', '背景图', Url::buildUrl(config('app.admin_prefix', 'admin') . '/widget.images/index', array('fodder' => 'image')))->icon('el-icon-picture-outline')->width('950px')->height('560px')->props(['footer' => false]);
-        $field[] = Form::number('one_brokerage', '一级上浮', 0)->appendRule('suffix', [
+        $field[] = Form::number('one_brokerage_percent', '一级佣金比例', 0)->appendRule('suffix', [
             'type' => 'div',
             'class' => 'tips-info',
-            'domProps' => ['innerHTML' => '在分销一级佣金基础上浮(0-1000之间整数)百分比,目前一级返佣比率:10%,上浮5%,则返佣比率:一级返佣比率 * (1 + 一级上浮比率) = 10.50%']
-        ])->max(1000)->precision(0);
-        $field[] = Form::number('two_brokerage', '二级上浮', 0)->appendRule('suffix', [
+            'domProps' => ['innerHTML' => '到达该等级之后,一级分佣按照此比例计算佣金']
+        ])->max(100)->precision(2);
+        $field[] = Form::number('two_brokerage_percent', '二级佣金比例', 0)->appendRule('suffix', [
             'type' => 'div',
             'class' => 'tips-info',
-            'domProps' => ['innerHTML' => '在分销二级佣金基础上浮(0-1000之间整数)百分比,目前二级返佣比率:10%,上浮2%,则返佣比率:二级返佣比率 * (1 + 二级上浮比率) = 5.10%']
-        ])->min(0)->max(1000)->precision(0);
+            'domProps' => ['innerHTML' => '到达该等级之后,二级分佣按照此比例计算佣金']
+        ])->min(0)->max(100)->precision(2);
         $field[] = Form::radio('status', '是否显示', 1)->options([['value' => 1, 'label' => '显示'], ['value' => 0, 'label' => '隐藏']]);
         return create_form('添加分销员等级', $field, Url::buildUrl('/agent/level'), 'POST');
     }
@@ -293,16 +288,16 @@ class AgentLevelServices extends BaseServices
         $field[] = Form::input('name', '等级名称', $levelInfo['name'])->maxlength(8)->col(24);
         $field[] = Form::number('grade', '等级', $levelInfo['grade'])->min(0)->precision(0);
         $field[] = Form::frameImage('image', '背景图', Url::buildUrl(config('app.admin_prefix', 'admin') . '/widget.images/index', array('fodder' => 'image')), $levelInfo['image'])->icon('el-icon-picture-outline')->width('950px')->height('560px')->props(['footer' => false]);
-        $field[] = Form::number('one_brokerage', '一级上浮', $levelInfo['one_brokerage'])->appendRule('suffix', [
+        $field[] = Form::number('one_brokerage_percent', '一级佣金比例', $levelInfo['one_brokerage_percent'])->appendRule('suffix', [
             'type' => 'div',
             'class' => 'tips-info',
-            'domProps' => ['innerHTML' => '在分销一级佣金基础上浮(0-1000之间整数)百分比,目前一级返佣比率:10%,上浮5%,则返佣比率:一级返佣比率 * (1 + 一级上浮比率) = 10.50%']
-        ])->min(0)->max(1000)->precision(0);
-        $field[] = Form::number('two_brokerage', '二级上浮', $levelInfo['two_brokerage'])->appendRule('suffix', [
+            'domProps' => ['innerHTML' => '到达该等级之后,一级分佣按照此比例计算佣金']
+        ])->max(100)->precision(2);
+        $field[] = Form::number('two_brokerage_percent', '二级佣金比例', $levelInfo['two_brokerage_percent'])->appendRule('suffix', [
             'type' => 'div',
             'class' => 'tips-info',
-            'domProps' => ['innerHTML' => '在分销二级佣金基础上浮(0-1000之间整数)百分比,目前二级返佣比率:10%,上浮2%,则返佣比率:二级返佣比率 * (1 + 二级上浮比率) = 5.10%']
-        ])->min(0)->max(1000)->precision(0);
+            'domProps' => ['innerHTML' => '到达该等级之后,二级分佣按照此比例计算佣金']
+        ])->min(0)->max(100)->precision(2);
         $field[] = Form::radio('status', '是否显示', $levelInfo['status'])->options([['value' => 1, 'label' => '显示'], ['value' => 0, 'label' => '隐藏']]);
 
         return create_form('编辑分销员等级', $field, Url::buildUrl('/agent/level/' . $id), 'PUT');

+ 3 - 0
crmeb/app/services/agent/AgentManageServices.php

@@ -47,6 +47,8 @@ class AgentManageServices extends BaseServices
         $data = $userServices->getAgentUserList($where, '*', $is_page);
         /** @var UserBrokerageServices $frozenPrices */
         $frozenPrices = app()->make(UserBrokerageServices::class);
+        /** @var StoreOrderServices $orderServices */
+        $orderServices = app()->make(StoreOrderServices::class);
         foreach ($data['list'] as &$item) {
             $item['headimgurl'] = $item['avatar'];
             $item['extract_count_price'] = $item['extract'][0]['extract_count_price'] ?? 0;
@@ -71,6 +73,7 @@ class AgentManageServices extends BaseServices
             if (strpos($item['headimgurl'], '/statics/system_images/') !== false) {
                 $item['headimgurl'] = set_file_url($item['headimgurl']);
             }
+            $item['spread_order'] = $orderServices->get(['spread_uid' => $item['uid'], 'paid' => 1, 'refund_status' => 0, 'pid' => 0], ['sum(pay_price) as order_price','count(id) as order_count']);
         }
         return $data;
     }

+ 1 - 1
crmeb/app/services/agent/DivisionAgentApplyServices.php

@@ -14,9 +14,9 @@ use crmeb\exceptions\AdminException;
 use crmeb\exceptions\ApiException;
 use crmeb\services\FormBuilder as Form;
 use app\services\other\UploadService;
+use think\facade\Config;
 use think\facade\Log;
 use think\facade\Route;
-use think\facade\Config;
 
 class DivisionAgentApplyServices extends BaseServices
 {

+ 16 - 0
crmeb/app/services/order/StoreCartServices.php

@@ -726,4 +726,20 @@ class StoreCartServices extends BaseServices
         }
         return true;
     }
+
+    /**
+     * 判断是否非付费会员购买会员专属商品
+     * @param $user
+     * @param $pid
+     * @return bool
+     * @author: 吴汐
+     * @email: 442384644@qq.com
+     * @date: 2023/10/30
+     */
+    public function checkVipGoodsBuy($user, $pid)
+    {
+        $is_vip_product = app()->make(StoreProductServices::class)->value(['id' => $pid], 'vip_product');
+        if ($is_vip_product == 1 && $user['is_money_level'] == 0) throw new ApiException('此商品为付费会员专属,您无权购买');
+        return true;
+    }
 }

+ 12 - 8
crmeb/app/services/order/StoreOrderComputedServices.php

@@ -305,9 +305,8 @@ class StoreOrderComputedServices extends BaseServices
      * @param array $userInfo
      * @return array
      */
-    public function getOrderPriceGroup($storeFreePostage, $cartInfo, $addr, $userInfo = [])
+    public function getOrderPriceGroup($storeFreePostage, $cartInfo, $addr, $userInfo = [], $shipping_type = 1)
     {
-        $sumPrice = $totalPrice = $costPrice = $vipPrice = 0;
         $storePostage = 0;
         $storePostageDiscount = 0;
         $isStoreFreePostage = false;//是否满额包邮
@@ -321,12 +320,17 @@ class StoreOrderComputedServices extends BaseServices
         // 判断商品包邮和固定运费
         foreach ($cartInfo as $key => &$item) {
             $item['postage_price'] = 0;
-            if ($item['productInfo']['freight'] == 1) {
-                $item['postage_price'] = 0;
-            } elseif ($item['productInfo']['freight'] == 2) {
-                $item['postage_price'] = bcmul((string)$item['productInfo']['postage'], (string)$item['cart_num'], 2);
-                $item['origin_postage_price'] = bcmul((string)$item['productInfo']['postage'], (string)$item['cart_num'], 2);
-                $storePostage = bcadd((string)$storePostage, (string)$item['postage_price'], 2);
+            if ($shipping_type == 1) {
+                if ($item['productInfo']['freight'] == 1) {
+                    $item['postage_price'] = 0;
+                } elseif ($item['productInfo']['freight'] == 2) {
+                    $item['postage_price'] = bcmul((string)$item['productInfo']['postage'], (string)$item['cart_num'], 2);
+                    $item['origin_postage_price'] = bcmul((string)$item['productInfo']['postage'], (string)$item['cart_num'], 2);
+                    $storePostage = bcadd((string)$storePostage, (string)$item['postage_price'], 2);
+                }
+                if ($sumPrice >= $storeFreePostage) {
+                    $item['postage_price'] = $item['origin_postage_price'] = $storePostage = 0;
+                }
             }
         }
         $postageArr = [];

+ 61 - 16
crmeb/app/services/order/StoreOrderCreateServices.php

@@ -450,9 +450,15 @@ class StoreOrderCreateServices extends BaseServices
             $isCommission = 0;
             if ($order['combination_id']) {
                 //检测拼团是否参与返佣
-                /** @var StoreCombinationServices $combinationServices */
-                $combinationServices = app()->make(StoreCombinationServices::class);
-                $isCommission = $combinationServices->value(['id' => $order['combination_id']], 'is_commission');
+                $isCommission = app()->make(StoreCombinationServices::class)->value(['id' => $order['combination_id']], 'is_commission');
+            }
+            if ($order['seckill_id']) {
+                //检测秒杀是否参与返佣
+                $isCommission = app()->make(StoreSeckillServices::class)->value(['id' => $order['seckill_id']], 'is_commission');
+            }
+            if ($order['bargain_id']) {
+                //检测砍价是否参与返佣
+                $isCommission = app()->make(StoreBargainServices::class)->value(['id' => $order['bargain_id']], 'is_commission');
             }
             if ($cartInfo && (!$activity || $isCommission)) {
                 /** @var StoreOrderComputedServices $orderComputed */
@@ -510,7 +516,7 @@ class StoreOrderCreateServices extends BaseServices
             }
         }
         try {
-            [$cartInfo, $spread_ids] = $this->computeOrderProductBrokerage($uid, $cartInfo, $orderInfo);
+            [$cartInfo, $spread_ids] = $this->computeOrderProductBrokerage($uid, $cartInfo);
         } catch (\Throwable $e) {
             Log::error('订单商品结算失败,File:' . $e->getFile() . ',Line:' . $e->getLine() . ',Message:' . $e->getMessage());
             throw new ApiException(410248);
@@ -767,19 +773,10 @@ class StoreOrderCreateServices extends BaseServices
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    public function computeOrderProductBrokerage(int $uid, array $cartInfo, $orderInfo)
+    public function computeOrderProductBrokerage(int $uid, array $cartInfo)
     {
-        /** @var AgentLevelServices $agentLevelServices */
-        $agentLevelServices = app()->make(AgentLevelServices::class);
-        [$one_brokerage_up, $two_brokerage_up, $spread_one_uid, $spread_two_uid] = $agentLevelServices->getAgentLevelBrokerage($uid);
-
-        $BrokerageOne = sys_config('store_brokerage_ratio') != '' ? sys_config('store_brokerage_ratio') : 0;
-        $BrokerageTwo = sys_config('store_brokerage_two') != '' ? sys_config('store_brokerage_two') : 0;
-        $storeBrokerageRatio = $BrokerageOne + (($BrokerageOne * $one_brokerage_up) / 100);
-        $storeBrokerageTwo = $BrokerageTwo + (($BrokerageTwo * $two_brokerage_up) / 100);
-        if (sys_config('brokerage_level') == 1) {
-            $storeBrokerageTwo = $spread_two_uid = 0;
-        }
+
+        [$storeBrokerageRatio, $storeBrokerageTwo, $spread_one_uid, $spread_two_uid] = $this->getSpreadDate($uid);
 
         /** @var DivisionServices $divisionService */
         $divisionService = app()->make(DivisionServices::class);
@@ -844,4 +841,52 @@ class StoreOrderCreateServices extends BaseServices
 
         return [$cartInfo, [$spread_one_uid, $spread_two_uid]];
     }
+
+
+    /**
+     * 获取计算好的佣金比例以及返佣人员uid
+     * @param int $uid
+     * @return array|int[]
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author: 吴汐
+     * @email: 442384644@qq.com
+     * @date: 2023/10/8
+     */
+    public function getSpreadDate(int $uid)
+    {
+        //商城分销是否开启,用户uid是否存在,全部返回0
+        if (!sys_config('brokerage_func_status') || !$uid) {
+            return [0, 0, 0, 0];
+        }
+
+        //获取用户信息,获取不到全部返回0
+        /** @var UserServices $userServices */
+        $userServices = app()->make(UserServices::class);
+        $userInfo = $userServices->getUserInfo($uid);
+        if (!$userInfo) {
+            return [0, 0, 0, 0];
+        }
+
+        //获取系统一二级分佣比例
+        $storeBrokerageRatio = sys_config('store_brokerage_ratio') != '' ? sys_config('store_brokerage_ratio') : 0;
+        $storeBrokerageTwo = sys_config('store_brokerage_two') != '' ? sys_config('store_brokerage_two') : 0;
+
+        //获取上级和上上级的uid,开启自购获取自己和上级的uid
+        $spread_one_uid = $userServices->getSpreadUid($uid, $userInfo);
+        $spread_two_uid = 0;
+        if ($spread_one_uid > 0 && $one_user_info = $userServices->getUserInfo($spread_one_uid)) {
+            $spread_two_uid = $userServices->getSpreadUid($spread_one_uid, $one_user_info, false);
+        }
+
+        //计算分销等级之后的佣金比例
+        [$storeBrokerageRatio, $storeBrokerageTwo] = app()->make(AgentLevelServices::class)->getAgentLevelBrokerage($storeBrokerageRatio, $storeBrokerageTwo, $spread_one_uid, $spread_two_uid);
+
+        //判断返佣层级为一级时,将二级用户uid和二级分佣比例改为0
+        if (sys_config('brokerage_level') == 1) {
+            $storeBrokerageTwo = $spread_two_uid = 0;
+        }
+        return [$storeBrokerageRatio, $storeBrokerageTwo, $spread_one_uid, $spread_two_uid];
+    }
 }

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

@@ -602,6 +602,7 @@ class StoreOrderRefundServices extends BaseServices
         $order['nickname'] = $userInfo['nickname'];
         $order['phone'] = $userInfo['phone'];
         if (in_array($order['pay_type'], ['weixin', 'alipay', 'allinpay', 'offline'])) {
+            $order['refund_price'] = $refund_price;
             $capitalFlowServices->setFlow($order, 'refund');
         }
 

+ 126 - 19
crmeb/app/services/order/StoreOrderServices.php

@@ -17,6 +17,7 @@ use app\services\activity\combination\StorePinkServices;
 use app\services\activity\seckill\StoreSeckillServices;
 use app\services\BaseServices;
 use app\services\other\PosterServices;
+use app\services\other\UploadService;
 use app\services\pay\OrderPayServices;
 use app\services\pay\PayServices;
 use app\services\product\product\StoreProductLogServices;
@@ -34,13 +35,14 @@ use app\services\wechat\WechatUserServices;
 use crmeb\exceptions\AdminException;
 use crmeb\exceptions\ApiException;
 use crmeb\exceptions\PayException;
+use crmeb\services\app\MiniProgramService;
 use crmeb\services\CacheService;
 use crmeb\services\easywechat\orderShipping\MiniOrderService;
 use crmeb\services\FormBuilder as Form;
 use crmeb\services\printer\Printer;
 use crmeb\services\SystemConfigService;
 use crmeb\utils\Arr;
-use think\exception\ValidateException;
+use Guzzle\Http\EntityBody;
 use think\facade\Log;
 
 /**
@@ -1648,7 +1650,7 @@ HTML;
         }
         /** @var StoreOrderComputedServices $computedServices */
         $computedServices = app()->make(StoreOrderComputedServices::class);
-        $priceGroup = $computedServices->getOrderPriceGroup($storeFreePostage, $validCartInfo, $addr, $user);
+        $priceGroup = $computedServices->getOrderPriceGroup($storeFreePostage, $validCartInfo, $addr, $user, $shipping_type);
         $validCartInfo = $priceGroup['cartInfo'] ?? $validCartInfo;
         $other = [
             'offlinePostage' => sys_config('offline_postage'),
@@ -2438,22 +2440,61 @@ HTML;
             $storeServices = app()->make(SystemStoreServices::class);
             $order['system_store'] = $storeServices->getStoreDispose($order['store_id']);
         }
+        $order['code'] = '';
         if (($order['shipping_type'] === 2 || $order['delivery_uid'] != 0) && $order['verify_code']) {
-            $name = $order['verify_code'] . '.jpg';
-            /** @var SystemAttachmentServices $attachmentServices */
-            $attachmentServices = app()->make(SystemAttachmentServices::class);
-            $imageInfo = $attachmentServices->getInfo(['name' => $name]);
-            $siteUrl = sys_config('site_url');
-            if (!$imageInfo) {
-                $imageInfo = PosterServices::getQRCodePath($order['verify_code'], $name);
-                if (is_array($imageInfo)) {
-                    $attachmentServices->attachmentAdd($imageInfo['name'], $imageInfo['size'], $imageInfo['type'], $imageInfo['dir'], $imageInfo['thumb_path'], 1, $imageInfo['image_type'], $imageInfo['time'], 2);
+//            $name = $order['verify_code'] . '.jpg';
+//            /** @var SystemAttachmentServices $attachmentServices */
+//            $attachmentServices = app()->make(SystemAttachmentServices::class);
+//            $imageInfo = $attachmentServices->getInfo(['name' => $name]);
+//            $siteUrl = sys_config('site_url');
+//            if (!$imageInfo) {
+//                $imageInfo = PosterServices::getQRCodePath($order['verify_code'], $name);
+//                if (is_array($imageInfo)) {
+//                    $attachmentServices->attachmentAdd($imageInfo['name'], $imageInfo['size'], $imageInfo['type'], $imageInfo['dir'], $imageInfo['thumb_path'], 1, $imageInfo['image_type'], $imageInfo['time'], 2);
+//                    $url = $imageInfo['dir'];
+//                } else
+//                    $url = '';
+//            } else $url = $imageInfo['att_dir'];
+//            if (isset($imageInfo['image_type']) && $imageInfo['image_type'] == 1) $url = $siteUrl . $url;
+//            $order['code'] = $url;
+            try {
+                $verifyName = 'verify_code_' . $order['verify_code'] . '.jpg';
+                $data = 'verify_code=' . $order['verify_code'];
+                /** @var SystemAttachmentServices $systemAttachmentService */
+                $systemAttachmentService = app()->make(SystemAttachmentServices::class);
+                $imageInfo = $systemAttachmentService->getOne(['name' => $verifyName]);
+                $siteUrl = sys_config('site_url');
+                if (!$imageInfo) {
+                    $res = MiniProgramService::appCodeUnlimitService($data, 'pages/admin/order_cancellation/index', 280);
+                    if (!$res) throw new ApiException('小程序核销码生成失败');
+                    $uploadType = (int)sys_config('upload_type', 1);
+                    $upload = UploadService::init();
+                    $res = (string)EntityBody::factory($res);
+                    $res = $upload->to('routine/product')->validate()->setAuthThumb(false)->stream($res, $verifyName);
+                    if ($res === false) throw new ApiException('小程序核销码生成失败');
+                    $imageInfo = $upload->getUploadInfo();
+                    $imageInfo['image_type'] = $uploadType;
+                    if ($imageInfo['image_type'] == 1) $remoteImage = PosterServices::remoteImage($siteUrl . $imageInfo['dir']);
+                    else $remoteImage = PosterServices::remoteImage($imageInfo['dir']);
+                    if (!$remoteImage['status']) throw new ApiException('小程序核销码生成失败');
+                    $systemAttachmentService->save([
+                        'name' => $imageInfo['name'],
+                        'att_dir' => $imageInfo['dir'],
+                        'satt_dir' => $imageInfo['thumb_path'],
+                        'att_size' => $imageInfo['size'],
+                        'att_type' => $imageInfo['type'],
+                        'image_type' => $imageInfo['image_type'],
+                        'module_type' => 2,
+                        'time' => time(),
+                        'pid' => 1,
+                        'type' => 2
+                    ]);
                     $url = $imageInfo['dir'];
-                } else
-                    $url = '';
-            } else $url = $imageInfo['att_dir'];
-            if (isset($imageInfo['image_type']) && $imageInfo['image_type'] == 1) $url = $siteUrl . $url;
-            $order['code'] = $url;
+                } else $url = $imageInfo['att_dir'];
+                if ($imageInfo['image_type'] == 1) $url = $siteUrl . $url;
+                $order['code'] = $url;
+            } catch (\Exception $e) {
+            }
         }
         $order['mapKey'] = sys_config('tengxun_map_key');
         $order['yue_pay_status'] = (int)sys_config('balance_func_status') && (int)sys_config('yue_pay_status') == 1 ? (int)1 : (int)2;//余额支付 1 开启 2 关闭
@@ -2523,9 +2564,31 @@ HTML;
             }
 
         }
+        $orderData['is_refund_available'] = $this->isRefundAvailable((int)$order['id']);
         return $orderData;
     }
 
+    /**
+     * 检测订单是否能退款
+     * @param $oid
+     * @return bool
+     * @author: 吴汐
+     * @email: 442384644@qq.com
+     * @date: 2023/10/11
+     */
+    public function isRefundAvailable($oid)
+    {
+        $refundTimeAvailable = (int)sys_config('refund_time_available');
+        if ($refundTimeAvailable == 0) return true;
+        $statusInfo = app()->make(StoreOrderStatusServices::class)->get(['oid' => $oid, 'change_type' => 'take_delivery']);
+        if (!$statusInfo) return true;
+        $changeTime = preg_match('/^\d+$/', $statusInfo['change_time']) ? intval($statusInfo['change_time']) : strtotime($statusInfo['change_time']);
+        if (($changeTime + ($refundTimeAvailable * 86400)) < time()) {
+            return false;
+        }
+        return true;
+    }
+
     /**
      * 获取确认订单页面是否展示快递配送和到店自提
      * @param $uid
@@ -2690,13 +2753,13 @@ HTML;
     {
         $orderInfo = $this->dao->get($id);
         if (!$orderInfo) {
-            throw new ValidateException('取消的订单不存在');
+            throw new AdminException('取消的订单不存在');
         }
         if (!$orderInfo->kuaidi_task_id || !$orderInfo->kuaidi_order_id) {
-            throw new ValidateException('商家寄件订单信息不存在,无法取消');
+            throw new AdminException('商家寄件订单信息不存在,无法取消');
         }
         if ($orderInfo->is_stock_up != 1) {
-            throw new ValidateException('订单状态不正确,无法取消寄件');
+            throw new AdminException('订单状态不正确,无法取消寄件');
         }
 
         //发起取消商家寄件
@@ -2768,4 +2831,48 @@ HTML;
             return true;
         }
     }
+
+    /**
+     * 配货单数据
+     * @param $oid
+     * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @author: 吴汐
+     * @email: 442384644@qq.com
+     * @date: 2023/10/11
+     */
+    public function printShippingData($order_id)
+    {
+        $orderInfo = $this->dao->get(['order_id' => $order_id]);
+        if (!$orderInfo) {
+            throw new AdminException('订单不存在');
+        }
+        $orderInfo = $this->tidyOrder($orderInfo->toArray(), true);
+        $data['user_name'] = $orderInfo['real_name'];
+        $data['user_phone'] = $orderInfo['user_phone'];
+        $data['user_address'] = $orderInfo['user_address'];
+        $data['order_id'] = $orderInfo['order_id'];
+        $data['pay_time'] = $orderInfo['_pay_time'];
+        $data['pay_type'] = $orderInfo['_status']['_payType'];
+        $data['pay_price'] = $orderInfo['pay_price'];
+        $data['pay_postage'] = $orderInfo['pay_postage'];
+        $data['deduction_price'] = $orderInfo['deduction_price'];
+        $data['coupon_price'] = $orderInfo['coupon_price'];
+        $data['mark'] = $orderInfo['mark'];
+        $data['product_info'] = [];
+        $data['vip_price'] = 0;
+        foreach ($orderInfo['cartInfo'] as $item) {
+            $data['product_info'][] = [
+                'name' => $item['productInfo']['store_name'],
+                'sku' => $item['attrInfo']['suk'],
+                'price' => $item['sum_price'],
+                'num' => $item['cart_num'],
+                'sum_price' => bcmul((string)$item['sum_price'], (string)$item['cart_num'], 2)
+            ];
+            $data['vip_price'] = bcadd((string)$data['vip_price'], $item['vip_sum_truePrice'], 2);
+        }
+        return $data;
+    }
 }

+ 6 - 2
crmeb/app/services/order/StoreOrderTakeServices.php

@@ -13,8 +13,10 @@ namespace app\services\order;
 
 
 use app\dao\order\StoreOrderDao;
+use app\services\activity\bargain\StoreBargainServices;
 use app\services\activity\combination\StoreCombinationServices;
 use app\services\activity\combination\StorePinkServices;
+use app\services\activity\seckill\StoreSeckillServices;
 use app\services\BaseServices;
 use app\services\user\member\MemberCardServices;
 use app\services\user\UserBillServices;
@@ -351,10 +353,12 @@ class StoreOrderTakeServices extends BaseServices
             }
         }
         if (isset($orderInfo['seckill_id']) && $orderInfo['seckill_id']) {
-            return true;
+            $seckill_commission = app()->make(StoreSeckillServices::class)->value(['id' => $orderInfo['seckill_id']], 'is_commission');
+            if (!$seckill_commission) return true;
         }
         if (isset($orderInfo['bargain_id']) && $orderInfo['bargain_id']) {
-            return true;
+            $bargain_commission = app()->make(StoreBargainServices::class)->value(['id' => $orderInfo['bargain_id']], 'is_commission');
+            if (!$bargain_commission) return true;
         }
         //绑定失效
         if (isset($orderInfo['spread_uid']) && $orderInfo['spread_uid'] == -1) {

+ 58 - 33
crmeb/app/services/other/export/ExportServices.php

@@ -74,7 +74,7 @@ class ExportServices extends BaseServices
      */
     public function exportOrderList($where)
     {
-        $header = ['订单号', '收货人姓名', '收货人电话', '收货地址', '商品信息', '总价格', '实际支付', '支付状态', '支付时间', '订单状态', '下单时间', '用户备注', '商家备注', '表单信息'];
+        $header = ['订单号', '收货人姓名', '收货人电话', '收货地址', '商品名称', '规格', '数量', '价格', '总价格', '实际支付', '支付状态', '支付时间', '订单状态', '下单时间', '用户备注', '商家备注', '表单信息'];
         $filename = '订单列表_' . date('YmdHis', time());
         $export = $fileKey = [];
         /** @var StoreOrderServices $orderServices */
@@ -136,38 +136,63 @@ class ExportServices extends BaseServices
                     }
                 }
 
-                $goodsName = [];
+//                $goodsName = [];
+//                foreach ($item['_info'] as $value) {
+//                    $_info = $value['cart_info'];
+//                    $sku = '';
+//                    if (isset($_info['productInfo']['attrInfo'])) {
+//                        if (isset($_info['productInfo']['attrInfo']['suk'])) {
+//                            $sku = '(' . $_info['productInfo']['attrInfo']['suk'] . ')';
+//                        }
+//                    }
+//                    if (isset($_info['productInfo']['store_name'])) {
+//                        $goodsName[] = implode(' ',
+//                            [$_info['productInfo']['store_name'],
+//                                $sku,
+//                                "[{$_info['cart_num']} * {$_info['truePrice']}]"
+//                            ]);
+//                    }
+//                }
+//                $one_data = [
+//                    'order_id' => $item['order_id'],
+//                    'real_name' => $item['real_name'],
+//                    'user_phone' => $item['user_phone'],
+//                    'user_address' => $item['user_address'],
+//                    'goods_name' => $goodsName ? implode("\n", $goodsName) : '',
+//                    'total_price' => $item['total_price'],
+//                    'pay_price' => $item['pay_price'],
+//                    'pay_type_name' => $item['pay_type_name'],
+//                    'pay_time' => $item['pay_time'] > 0 ? date('Y-m-d H:i', (int)$item['pay_time']) : '暂无',
+//                    'status_name' => $item['status_name'] ?? '未知状态',
+//                    'add_time' => $item['add_time'],
+//                    'mark' => $item['mark'],
+//                    'remark' => $item['remark'],
+//                    'custom_form' => $custom_form,
+//                ];
+                $goodsInfo = [];
                 foreach ($item['_info'] as $value) {
-                    $_info = $value['cart_info'];
-                    $sku = '';
-                    if (isset($_info['productInfo']['attrInfo'])) {
-                        if (isset($_info['productInfo']['attrInfo']['suk'])) {
-                            $sku = '(' . $_info['productInfo']['attrInfo']['suk'] . ')';
-                        }
-                    }
-                    if (isset($_info['productInfo']['store_name'])) {
-                        $goodsName[] = implode(' ',
-                            [$_info['productInfo']['store_name'],
-                                $sku,
-                                "[{$_info['cart_num']} * {$_info['truePrice']}]"
-                            ]);
-                    }
+                    $goodsInfo[] = [
+                        $value['cart_info']['productInfo']['store_name'],
+                        $value['cart_info']['productInfo']['attrInfo']['suk'],
+                        $value['cart_info']['cart_num'],
+                        $value['cart_info']['truePrice'],
+                    ];
                 }
                 $one_data = [
-                    'order_id' => $item['order_id'],
-                    'real_name' => $item['real_name'],
-                    'user_phone' => $item['user_phone'],
-                    'user_address' => $item['user_address'],
-                    'goods_name' => $goodsName ? implode("\n", $goodsName) : '',
-                    'total_price' => $item['total_price'],
-                    'pay_price' => $item['pay_price'],
-                    'pay_type_name' => $item['pay_type_name'],
-                    'pay_time' => $item['pay_time'] > 0 ? date('Y-m-d H:i', (int)$item['pay_time']) : '暂无',
-                    'status_name' => $item['status_name'] ?? '未知状态',
-                    'add_time' => $item['add_time'],
-                    'mark' => $item['mark'],
-                    'remark' => $item['remark'],
-                    'custom_form' => $custom_form,
+                    $item['order_id'],
+                    $item['real_name'],
+                    $item['user_phone'],
+                    $item['user_address'],
+                    $goodsInfo,
+                    $item['total_price'],
+                    $item['pay_price'],
+                    $item['pay_type_name'],
+                    $item['pay_time'] > 0 ? date('Y-m-d H:i', (int)$item['pay_time']) : '暂无',
+                    $item['status_name'] ?? '未知状态',
+                    $item['add_time'],
+                    $item['mark'],
+                    $item['remark'],
+                    $custom_form,
                 ];
                 $export[] = $one_data;
                 if ($i == 0) {
@@ -594,8 +619,8 @@ class ExportServices extends BaseServices
                     $item['nickname'],
                     $item['phone'],
                     $item['spread_count'],
-                    $item['order_count'],
-                    $item['order_price'],
+                    $item['spread_order']['order_count'],
+                    $item['spread_order']['order_price'],
                     $item['brokerage_money'],
                     $item['extract_count_price'],
                     $item['extract_count_num'],
@@ -604,7 +629,7 @@ class ExportServices extends BaseServices
                 ];
             }
         }
-        $header = ['用户编号', '昵称', '电话号码', '推广用户数量', '订单数量', '推广订单金额', '佣金金额', '已提现金额', '提现次数', '未提现金额', '上级推广人'];
+        $header = ['用户编号', '昵称', '电话号码', '推广用户数量', '推广订单数量', '推广订单金额', '佣金金额', '已提现金额', '提现次数', '未提现金额', '上级推广人'];
         $title = ['推广用户', '推广用户导出' . time(), ' 生成时间:' . date('Y-m-d H:i:s', time())];
         $filename = '推广用户_' . date('YmdHis', time());
         $suffix = 'xlsx';

+ 1 - 1
crmeb/app/services/pc/OrderServices.php

@@ -47,7 +47,7 @@ class OrderServices extends BaseServices
         /** @var StoreOrderServices $order */
         $order = app()->make(StoreOrderServices::class);
         $data['list'] = $order->getOrderApiList($where, $field, $with);
-        $data['count'] = $order->count($where);
+        $data['count'] = $order->dao->count($where, false);
         return $data;
     }
 }

+ 1 - 0
crmeb/app/services/product/product/CopyTaobaoServices.php

@@ -132,6 +132,7 @@ class CopyTaobaoServices extends BaseServices
             $productInfo['temp_id'] = 1;
             $productInfo['freight'] = 3;
             $productInfo['recommend'] = [];
+            $productInfo['logistics'] = ['1', '2'];
             $data['productInfo'] = $productInfo;
             return $data;
         } else {

+ 1 - 1
crmeb/app/services/product/product/StoreProductServices.php

@@ -1104,7 +1104,7 @@ class StoreProductServices extends BaseServices
             unset($where['productId']);
         }
         $where['vip_user'] = $uid ? app()->make(UserServices::class)->value(['uid' => $uid], 'is_money_level') : 0;
-        $list = $this->dao->getSearchList($where, $page, $limit, ['id,store_name,cate_id,image,IFNULL(sales, 0) + IFNULL(ficti, 0) as sales,price,stock,activity,ot_price,spec_type,recommend_image,unit_name,is_vip,vip_price,is_virtual,presale,custom_form,virtual_type']);
+        $list = $this->dao->getSearchList($where, $page, $limit, ['id,store_name,cate_id,image,IFNULL(sales, 0) + IFNULL(ficti, 0) as sales,price,stock,activity,ot_price,spec_type,recommend_image,unit_name,is_vip,vip_price,is_virtual,presale,custom_form,virtual_type,min_qty']);
         /** @var MemberCardServices $memberCardService */
         $memberCardService = app()->make(MemberCardServices::class);
         $vipStatus = $memberCardService->isOpenMemberCard('vip_price');

+ 3 - 0
crmeb/app/services/product/sku/StoreProductAttrServices.php

@@ -75,6 +75,7 @@ class StoreProductAttrServices extends BaseServices
         } else {
             /** @var StoreProductVirtualServices $productVirtual */
             $productVirtual = app()->make(StoreProductVirtualServices::class);
+            $cardStock = 0;
             foreach ($data['valueGroup'] as &$item) {
                 $res = $storeProductAttrValueServices->save($item);
                 if ($item['is_virtual'] && count($item['virtual_list']) && !$item['coupon_id'] && $item['disk_info'] == '') {
@@ -94,8 +95,10 @@ class StoreProductAttrServices extends BaseServices
                     }
                     $allStock = $productVirtual->count(['product_id' => $id, 'attr_unique' => $item['unique']]);
                     $storeProductAttrValueServices->update(['id' => $res['id']], ['stock' => $allStock - $sales, 'sales' => $sales]);
+                    $cardStock = $cardStock + ($allStock - $sales);
                 }
             }
+            if ($cardStock > 0) $storeProductService->update($id, ['stock' => $cardStock]);
             return true;
         }
     }

+ 4 - 1
crmeb/app/services/system/SystemMenusServices.php

@@ -243,7 +243,7 @@ class SystemMenusServices extends BaseServices
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    public function getMenus($roles): array
+    public function getMenus($roles, $check = []): array
     {
         $field = ['menu_name', 'pid', 'id'];
         $where = ['is_del' => 0, 'is_show_path' => 1];
@@ -256,6 +256,9 @@ class SystemMenusServices extends BaseServices
             $ids = $service->getRoleIds($roles);
             $menus = $this->dao->getMenusRoule(['rule' => $ids] + $where, $field);
         }
+        foreach ($menus as &$item) {
+            $item['checked'] = in_array($item['id'], $check);
+        }
         return $this->tidyMenuTier(false, $menus);
     }
 

+ 22 - 22
crmeb/app/services/system/UpgradeServices.php

@@ -54,28 +54,28 @@ class UpgradeServices extends BaseServices
      */
     public function __construct(UpgradeLogDao $dao)
     {
-        $versionData = $this->getVersion();
-        if ($versionData['version_code'] < 450) return true;
-        if (empty($versionData)) {
-            throw new AdminException('授权信息丢失');
-        }
-
-        $this->timeStamp = time();
-        $recVersion = $this->recombinationVersion($versionData['version'] ?? '');
-        $this->dao = $dao;
-
-        $this->requestData = [
-            'nonce' => mt_rand(111, 999),
-            'host' => app()->request->host(),
-            'timestamp' => $this->timeStamp,
-            'app_id' => trim($versionData['app_id'] ?? ''),
-            'app_key' => trim($versionData['app_key'] ?? ''),
-            'version' => implode('.', $recVersion)
-        ];
-
-        if (!CacheService::get('upgrade_auth_token')) {
-            $this->getAuth();
-        }
+//        $versionData = $this->getVersion();
+//        if ($versionData['version_code'] < 450) return true;
+//        if (empty($versionData)) {
+//            throw new AdminException('授权信息丢失');
+//        }
+//
+//        $this->timeStamp = time();
+//        $recVersion = $this->recombinationVersion($versionData['version'] ?? '');
+//        $this->dao = $dao;
+//
+//        $this->requestData = [
+//            'nonce' => mt_rand(111, 999),
+//            'host' => app()->request->host(),
+//            'timestamp' => $this->timeStamp,
+//            'app_id' => trim($versionData['app_id'] ?? ''),
+//            'app_key' => trim($versionData['app_key'] ?? ''),
+//            'version' => implode('.', $recVersion)
+//        ];
+//
+//        if (!CacheService::get('upgrade_auth_token')) {
+//            $this->getAuth();
+//        }
     }
 
     /**

+ 3 - 0
crmeb/app/services/system/attachment/SystemAttachmentServices.php

@@ -124,6 +124,9 @@ class SystemAttachmentServices extends BaseServices
         }
         try {
             $path = make_path('attach', 2, true);
+            if ($path === '') {
+                throw new AdminException(400555);
+            }
             $upload = UploadService::init($upload_type);
             $res = $upload->to($path)->validate()->move($file, $realName);
             if ($res === false) {

+ 1 - 1
crmeb/app/services/system/config/SystemConfigServices.php

@@ -405,7 +405,7 @@ class SystemConfigServices extends BaseServices
                 break;
             default:
                 $data['value'] = isset($data['value']) ? json_decode($data['value'], true) : '';
-                if ($data['menu_name'] == 'api') {
+                if ($data['menu_name'] == 'api' || $data['menu_name'] == 'routine_api') {
                     $formbuider[] = $this->builder->input($data['menu_name'], $data['info'], strpos($data['value'], 'http') === false ? sys_config('site_url') . $data['value'] : $data['value'])->appendRule('suffix', [
                         'type' => 'div',
                         'class' => 'tips-info',

+ 2 - 2
crmeb/app/services/system/lang/LangCodeServices.php

@@ -35,8 +35,8 @@ class LangCodeServices extends BaseServices
         $typeList = $langTypeServices->getColumn([['status', '=', 1], ['is_del', '=', 0]], 'language_name,file_name,id', 'id');
         $langType = [
             'isAdmin' => [
-                ['title' => '用户端页面', 'value' => 0],
-                ['title' => '后端接口', 'value' => 1]
+                ['title' => '页面语言', 'value' => 0],
+                ['title' => '接口语言', 'value' => 1]
             ]
         ];
         foreach ($typeList as $value) {

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

@@ -773,7 +773,7 @@ class UserBillServices extends BaseServices
         }
         /** @var UserUserBrokerageServices $userUserBrokerage */
         $userUserBrokerage = app()->make(UserUserBrokerageServices::class);
-        [$count, $list] = $userUserBrokerage->getBrokerageList($where_data, 'b.type,b.pm,sum(IF(b.pm = 1, b.number, 0)) as income,sum(IF(b.pm = 0, b.number, 0)) as pay,u.nickname,u.phone,u.uid,u.now_money,u.brokerage_price,b.add_time as time', $order_string, $limit);
+        [$count, $list] = $userUserBrokerage->getBrokerageList($where_data, 'b.type,b.pm,sum(IF(b.pm = 1 AND b.type <> \'extract_fail\', b.number, 0)) as income,sum(IF(b.pm = 0, b.number, 0)) as pay,u.nickname,u.phone,u.uid,u.now_money,u.brokerage_price,b.add_time as time', $order_string, $limit);
         $uids = array_unique(array_column($list, 'uid'));
         /** @var UserExtractServices $userExtract */
         $userExtract = app()->make(UserExtractServices::class);

+ 13 - 12
crmeb/app/services/user/UserRechargeServices.php

@@ -233,19 +233,8 @@ class UserRechargeServices extends BaseServices
 
         try {
             $recharge_type = $UserRecharge['recharge_type'];
-
-            if (sys_config('pay_wechat_type')) {
-                $drivers = 'v3_wechat_pay';
-                $trade_no = $UserRecharge['trade_no'];
-            } else {
-                $drivers = 'wechat_pay';
-                $trade_no = $UserRecharge['order_id'];
-            }
-            /** @var Pay $pay */
-            $pay = app()->make(Pay::class, [$drivers]);
             if ($recharge_type == 'weixin') {
                 $refund_data['wechat'] = true;
-                $pay->refund($trade_no, $refund_data);
             } else {
                 $refund_data['trade_no'] = $UserRecharge['trade_no'];
                 $refund_data['order_id'] = $UserRecharge['order_id'];
@@ -256,8 +245,20 @@ class UserRechargeServices extends BaseServices
                 /** @var StoreOrderCreateServices $storeOrderCreateServices */
                 $storeOrderCreateServices = app()->make(StoreOrderCreateServices::class);
                 $refund_data['refund_no'] = $storeOrderCreateServices->getNewOrderId('tk');
-                $pay->refund($UserRecharge['order_id'], $refund_data);
             }
+            if ($recharge_type == 'allinpay') {
+                $drivers = 'allin_pay';
+                $trade_no = $UserRecharge['trade_no'];
+            } elseif (sys_config('pay_wechat_type')) {
+                $drivers = 'v3_wechat_pay';
+                $trade_no = $UserRecharge['trade_no'];
+            } else {
+                $drivers = 'wechat_pay';
+                $trade_no = $UserRecharge['order_id'];
+            }
+            /** @var Pay $pay */
+            $pay = app()->make(Pay::class, [$drivers]);
+            $pay->refund($trade_no, $refund_data);
         } catch (\Exception $e) {
             throw new AdminException($e->getMessage());
         }

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

@@ -1995,7 +1995,7 @@ class UserServices extends BaseServices
             $this->dao->update(['uid' => $uid], ['is_money_level' => 0/*, 'overdue_time' => 0*/]);
             return false;
         }
-        return true;
+        return $userInfo;
     }
 
     /**

+ 5 - 3
crmeb/app/services/user/UserSignServices.php

@@ -158,6 +158,8 @@ class UserSignServices extends BaseServices
             throw new ApiException(410032);
         }
 
+        $userServices->offMemberLevel($uid);
+
         //检测今天是否已经签到
         if ($this->getIsSign($uid, 'today')) {
             throw new ApiException(410293);
@@ -257,7 +259,7 @@ class UserSignServices extends BaseServices
             /** @var UserBillServices $userBill */
             $userBill = app()->make(UserBillServices::class);
             $user['sum_integral'] = intval($userBill->getRecordCount($user['uid'], 'integral', 'sign,system_add,gain,lottery_add,product_gain,pay_product_integral_back'));
-            $user['deduction_integral'] = intval($userBill->getRecordCount($user['uid'], 'integral', 'deduction,lottery_use,order_deduction', '', true) ?? 0);
+            $user['deduction_integral'] = intval($userBill->getRecordCount($user['uid'], 'integral', 'deduction,lottery_use,order_deduction,storeIntegral_use', '', true) ?? 0);
             $user['today_integral'] = intval($userBill->getRecordCount($user['uid'], 'integral', 'sign,system_add,gain,product_gain,lottery_add,pay_product_integral_back', 'today'));
             /** @var UserBillServices $userBillServices */
             $userBillServices = app()->make(UserBillServices::class);
@@ -338,14 +340,14 @@ class UserSignServices extends BaseServices
         $nextContinuousDays = 0;
         foreach ($nextContinuousSignRewardList as $continuousNext) {
             if ($continuousSignDays < $continuousNext['days']) {
-                $nextContinuousDays = $continuousNext['days'] - $continuousSignDays > 0 ?: 1;
+                $nextContinuousDays = $continuousNext['days'] - $continuousSignDays > 0 ? $continuousNext['days'] - $continuousSignDays : 1;
                 break;
             }
         }
         $nextCumulativeDays = 0;
         foreach ($nextCumulativeSignRewardList as $cumulativeNext) {
             if ($cumulativeSignDays < $cumulativeNext['days']) {
-                $nextCumulativeDays = $cumulativeNext['days'] - $cumulativeSignDays > 0 ?: 1;
+                $nextCumulativeDays = $cumulativeNext['days'] - $cumulativeSignDays > 0 ? $cumulativeNext['days'] - $cumulativeSignDays : 1;
                 break;
             }
         }

+ 3 - 2
crmeb/app/services/wechat/WechatUserServices.php

@@ -264,7 +264,7 @@ class WechatUserServices extends BaseServices
 
     /**
      * 微信授权成功后
-     * @param array $data
+     * @param $data
      * @return array|mixed|\think\Model|null
      * @throws \think\db\exception\DataNotFoundException
      * @throws \think\db\exception\DbException
@@ -273,8 +273,9 @@ class WechatUserServices extends BaseServices
      * @email 442384644@qq.com
      * @date 2023/02/24
      */
-    public function wechatOauthAfter(array $data)
+    public function wechatOauthAfter($data)
     {
+        if (!$data) throw new ApiException('用户信息获取失败,请刷新页面重试');
         [$openid, $wechatInfo, $spreadId, $login_type, $userType] = $data;
         /** @var UserServices $userServices */
         $userServices = app()->make(UserServices::class);

+ 1 - 1
crmeb/crmeb/services/FileService.php

@@ -989,7 +989,7 @@ class FileService
                     $t3 = $this->objToStr($sheet->getCellByColumnAndRow(3, $i)->getValue());
                     $t4 = $this->objToStr($sheet->getCellByColumnAndRow(4, $i)->getValue());
                     $t5 = $this->objToStr($sheet->getCellByColumnAndRow(5, $i)->getValue());
-                    if ($t3 && $t4 && $t5) {
+                    if ($t3 && $t5) {
                         $data[] = [
                             'id' => $t1,
                             'delivery_name' => $t3,

+ 1 - 8
crmeb/crmeb/services/SystemConfigService.php

@@ -40,10 +40,6 @@ class SystemConfigService
 
         try {
             return $callable();
-//            if ($isCaChe) {
-//                return $callable();
-//            }
-//            return CacheService::remember($key, $callable);
         } catch (\Throwable $e) {
             return $default;
         }
@@ -64,10 +60,7 @@ class SystemConfigService
             return Arr::getDefaultValue($keys, $service->getConfigAll($keys));
         };
         try {
-            if ($isCaChe)
-                return $callable();
-
-            return CacheService::remember(md5(implode(',', $keys)), $callable);
+            return $callable();
         } catch (\Throwable $e) {
             return Arr::getDefaultValue($keys);
         }

+ 5 - 5
crmeb/crmeb/services/app/MiniProgramService.php

@@ -95,7 +95,7 @@ class MiniProgramService
      */
     public static function options()
     {
-        $wechat = SystemConfigService::more(['wechat_app_appsecret', 'wechat_app_appid', 'site_url', 'routine_appId', 'routine_appsecret', 'wechat_token', 'wechat_encodingaeskey']);
+        $wechat = SystemConfigService::more(['wechat_app_appsecret', 'wechat_app_appid', 'site_url', 'routine_appId', 'routine_appsecret', 'routine_token', 'routine_encodingaeskey']);
         $payment = SystemConfigService::more(['pay_weixin_mchid', 'pay_weixin_key', 'pay_weixin_client_cert', 'pay_weixin_client_key', 'pay_weixin_open', 'pay_new_weixin_open', 'pay_new_weixin_mchid']);
         $config = [];
         if (request()->isApp()) {
@@ -106,14 +106,14 @@ class MiniProgramService
             $appsecret = isset($wechat['routine_appsecret']) ? trim($wechat['routine_appsecret']) : '';
         }
         $config = [
-            'token' => isset($wechat['wechat_token']) ? trim($wechat['wechat_token']) : '',
-            'aes_key' => isset($wechat['wechat_encodingaeskey']) ? trim($wechat['wechat_encodingaeskey']) : '',
+            'token' => isset($wechat['routine_token']) ? trim($wechat['routine_token']) : '',
+            'aes_key' => isset($wechat['routine_encodingaeskey']) ? trim($wechat['routine_encodingaeskey']) : '',
         ];
         $config['mini_program'] = [
             'app_id' => $appId,
             'secret' => $appsecret,
-            'token' => isset($wechat['wechat_token']) ? trim($wechat['wechat_token']) : '',
-            'aes_key' => isset($wechat['wechat_encodingaeskey']) ? trim($wechat['wechat_encodingaeskey']) : ''
+            'token' => isset($wechat['routine_token']) ? trim($wechat['routine_token']) : '',
+            'aes_key' => isset($wechat['routine_encodingaeskey']) ? trim($wechat['routine_encodingaeskey']) : ''
         ];
         $config['payment'] = [
             'app_id' => $appId,

+ 4 - 1
crmeb/crmeb/utils/Canvas.php

@@ -261,7 +261,10 @@ class Canvas
             if ($strlen !== false) {
                 $path = substr($this->path, 8);
             }
-            make_path($path, 4, true);
+
+            if (make_path($path, 4, true) === '') {
+                throw new \RuntimeException(400555);
+            }
 
             $save_file = $this->path . $this->fileName . '.' . $this->imageType;
             switch ($this->imageType) {

+ 1 - 1
crmeb/crmeb/utils/DownloadImage.php

@@ -14,8 +14,8 @@ namespace crmeb\utils;
 
 use app\services\other\UploadService;
 use crmeb\exceptions\AdminException;
-use think\Image;
 use think\facade\Config;
+use think\Image;
 
 /**
  * 下载图片到本地

+ 6 - 1
crmeb/crmeb/utils/Translate.php

@@ -75,6 +75,11 @@ class Translate extends V4Curl
         if ($resp->getStatusCode() != 200) {
             throw new ApiException("failed to translate: status_code=%d, resp=%s", $resp->getStatusCode(), $resp->getBody());
         }
-        return json_decode($resp->getBody()->getContents(), true)["TranslationList"];
+        $result = json_decode($resp->getBody()->getContents(), true);
+        if (isset($result["TranslationList"])) {
+            return $result["TranslationList"];
+        } else {
+            throw new ApiException("failed to translate: " . $result["ResponseMetadata"]['Error']['Message']);
+        }
     }
 }

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
crmeb/public/admin/css.worker.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
crmeb/public/admin/editor.worker.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
crmeb/public/admin/html.worker.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
crmeb/public/admin/index.html


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
crmeb/public/admin/json.worker.js


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 1
crmeb/public/admin/system_static/css/app.176ec911.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/css/app.232e71fd.css


crmeb/public/admin/system_static/css/chunk-24dfe0e6.6ed9fb31.css → crmeb/public/admin/system_static/css/chunk-00655988.6ed9fb31.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 1
crmeb/public/admin/system_static/css/chunk-01461622.1098cd10.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
crmeb/public/admin/system_static/css/chunk-2a1551d0.6442138e.css


crmeb/public/admin/system_static/css/chunk-4b6139a2.5a5b6f08.css → crmeb/public/admin/system_static/css/chunk-02077a46.5a5b6f08.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/css/chunk-024eff44.ff0a8596.css


+ 1 - 0
crmeb/public/admin/system_static/css/chunk-0322990a.0e99d3e7.css

@@ -0,0 +1 @@
+.radio[data-v-224af4d2]{margin-bottom:14px}.radio[data-v-224af4d2] .name{width:125px;text-align:right;padding-right:12px}

+ 0 - 1
crmeb/public/admin/system_static/css/chunk-033cc77a.eeab2c78.css

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

crmeb/public/admin/system_static/css/chunk-4589426d.015ae8dc.css → crmeb/public/admin/system_static/css/chunk-03eeaf0a.015ae8dc.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 1
crmeb/public/admin/system_static/css/chunk-046498a8.98bd250f.css


+ 1 - 0
crmeb/public/admin/system_static/css/chunk-054ceee2.42b60f9c.css

@@ -0,0 +1 @@
+.box[data-v-25599488]{width:100%;height:100%;background:#fff}[data-v-25599488] .el-card__body{min-height:700px;padding:16px 16px 16px 0}[data-v-25599488] .conter .pictrueList{max-width:100%}

+ 0 - 1
crmeb/public/admin/system_static/css/chunk-05c82e7c.0f4894db.css

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

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/css/chunk-061b084e.cd13fc3d.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/css/chunk-0643a4f2.e5125496.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
crmeb/public/admin/system_static/css/chunk-7a4913de.c6be2663.css


+ 1 - 0
crmeb/public/admin/system_static/css/chunk-064d51c3.4e1572a5.css

@@ -0,0 +1 @@
+.picBox[data-v-494d3bec]{display:inline-block;cursor:pointer}.picBox .upLoad[data-v-494d3bec]{width:58px;height:58px;line-height:58px;border:1px dotted rgba(0,0,0,.1);border-radius:4px;background:rgba(0,0,0,.02)}.picBox .pictrue[data-v-494d3bec]{width:60px;height:60px;border:1px dotted rgba(0,0,0,.1);margin-right:10px}.picBox .pictrue img[data-v-494d3bec]{width:100%;height:100%}.picBox .iconfont[data-v-494d3bec]{color:#898989}.mapBox[data-v-494d3bec] .ivu-modal-body{height:640px!important}

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/css/chunk-0688ae90.5b71a1cf.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/css/chunk-071887cb.68de37ff.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 1
crmeb/public/admin/system_static/css/chunk-075215e2.3d9f8610.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/css/chunk-081c9142.78c3202d.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
crmeb/public/admin/system_static/css/chunk-88073580.50ba8057.css


+ 0 - 1
crmeb/public/admin/system_static/css/chunk-0a2fde4e.548e94e4.css

@@ -1 +0,0 @@
-.radio[data-v-58fdaf03]{margin-bottom:14px}.radio[data-v-58fdaf03] .name{width:125px;text-align:right;padding-right:12px}

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 1
crmeb/public/admin/system_static/css/chunk-0a5259ae.b8a8a02d.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 1
crmeb/public/admin/system_static/css/chunk-0b026fe8.53eb8477.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 1
crmeb/public/admin/system_static/css/chunk-0bd0e879.c849c1ba.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
crmeb/public/admin/system_static/css/chunk-9f697dde.b7d88feb.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/css/chunk-0dfd6ce5.654d0859.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/css/chunk-0e9fe7d9.8d0bf5f4.css


crmeb/public/admin/system_static/css/chunk-cb3f65c2.2a5ea5e7.css → crmeb/public/admin/system_static/css/chunk-0f1100c7.2a5ea5e7.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/css/chunk-0f31d873.267957b0.css


+ 1 - 0
crmeb/public/admin/system_static/css/chunk-0fe5659e.9af0ccac.css

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

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 1
crmeb/public/admin/system_static/css/chunk-102ae29a.1888ad6b.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 0 - 1
crmeb/public/admin/system_static/css/chunk-12af24b5.92287fd9.css


+ 1 - 1
crmeb/public/admin/system_static/css/chunk-147099df.79ccad36.css

@@ -1 +1 @@
-.radio[data-v-58fdaf03]{margin-bottom:14px}.radio[data-v-58fdaf03] .name{width:125px;text-align:right;padding-right:12px}.ivu-col:first-of-type .ivu-form-item .ivu-form-item-label[data-v-0fe772d0]{width:80px!important}.ivu-col:first-of-type .ivu-form-item .ivu-form-item-content[data-v-0fe772d0]{margin-left:80px!important}
+.radio[data-v-224af4d2]{margin-bottom:14px}.radio[data-v-224af4d2] .name{width:125px;text-align:right;padding-right:12px}.ivu-col:first-of-type .ivu-form-item .ivu-form-item-label[data-v-0fe772d0]{width:80px!important}.ivu-col:first-of-type .ivu-form-item .ivu-form-item-content[data-v-0fe772d0]{margin-left:80px!important}

crmeb/public/admin/system_static/css/chunk-ddff33a6.9ec65ea6.css → crmeb/public/admin/system_static/css/chunk-12faac12.9ec65ea6.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/css/chunk-1334fe21.4d8bf09c.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/css/chunk-1378e6e4.306eb365.css


Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 1
crmeb/public/admin/system_static/css/chunk-22b4cd9b.d3f412cb.css


crmeb/public/admin/system_static/css/chunk-764f7116.af3b01f2.css → crmeb/public/admin/system_static/css/chunk-14a3aaa0.af3b01f2.css


+ 0 - 1
crmeb/public/admin/system_static/css/chunk-151dd58b.9e8f70ba.css

@@ -1 +0,0 @@
-.cur[data-v-60ae7a89]{cursor:pointer}.goupBox[data-v-60ae7a89] .ivu-form-item-content{margin-left:43px!important}

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1 - 0
crmeb/public/admin/system_static/css/chunk-15477b66.deefe305.css


+ 0 - 0
crmeb/public/admin/system_static/css/chunk-15f7d94c.77da8061.css


Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů