evoxwht 3 rokov pred
rodič
commit
eee85c7fa5

+ 3 - 3
crmeb/app/adminapi/controller/v1/order/RefundOrder.php

@@ -36,7 +36,7 @@ class RefundOrder extends AuthController
     {
         $where = $this->request->getMore([
             ['order_id', ''],
-            ['time', '', '', 'add_time'],
+            ['time', ''],
             ['refund_type', 0]
         ]);
         $where['is_cancel'] = 0;
@@ -174,8 +174,8 @@ class RefundOrder extends AuthController
             }
             //修改订单退款状态
             unset($data['refund_price']);
-            if ($this->services->update($id, $data)) {
-                $this->services->agreeRefund($id, $refund_data);
+            if ($this->services->agreeRefund($id, $refund_data)) {
+                $this->services->update($id, $data);
                 return app('json')->success('退款成功');
             } else {
                 $this->services->storeProductOrderRefundYFasle((int)$id, $refund_price);

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

@@ -481,6 +481,7 @@ class StoreOrder extends AuthController
             $orderInfo['_store_name'] = $storeServices->value(['id' => $orderInfo['store_id']], 'name');
         } else
             $orderInfo['_store_name'] = '';
+        $orderInfo['spread_name'] = $services->value(['uid'=>$orderInfo['spread_uid']],'nickname') ?? '无';
         $userInfo = $userInfo->toArray();
         return app('json')->success(compact('orderInfo', 'userInfo'));
     }

+ 3 - 2
crmeb/app/api/controller/pc/HomeController.php

@@ -11,6 +11,7 @@
 namespace app\api\controller\pc;
 
 
+use app\Request;
 use app\services\pc\HomeServices;
 use app\services\other\QrcodeServices;
 
@@ -49,9 +50,9 @@ class HomeController
      * 首页分类尚品
      * @return mixed
      */
-    public function getCategoryProduct()
+    public function getCategoryProduct(Request $request)
     {
-        $data = $this->services->getCategoryProduct();
+        $data = $this->services->getCategoryProduct((int)$request->uid());
         return app('json')->successful($data);
     }
 

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

@@ -443,6 +443,7 @@ class LoginController
                 return app('json')->fail('验证码错误');
             }
         }
+        if ($email == '') $email = substr(md5($openId), 0, 12);
         $userInfo = [
             'openId' => $openId,
             'unionid' => '',

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

@@ -479,6 +479,7 @@ class PublicController
         $data['customer_type'] = sys_config('customer_type', 0);
         $data['customer_phone'] = sys_config('customer_phone', 0);
         $data['customer_url'] = sys_config('customer_url', 0);
+        $data['customer_corpId'] = sys_config('customer_corpId', 0);
         return app('json')->success($data);
     }
 

+ 4 - 5
crmeb/app/api/controller/v1/admin/StoreOrderController.php

@@ -373,9 +373,8 @@ class StoreOrderController
 
 
                 //修改订单退款状态
-                if ($services->update((int)$orderRefund['id'], $data)) {
-                    $services->agreeRefund((int)$orderRefund['id'], $refundData);
-
+                if ($services->agreeRefund((int)$orderRefund['id'], $refundData)) {
+                    $services->update((int)$orderRefund['id'], $data);
                     return app('json')->success('退款成功');
                 } else {
                     $services->storeProductOrderRefundYFasle((int)$orderInfo['id'], $price);
@@ -444,8 +443,8 @@ class StoreOrderController
 
 
                 //修改订单退款状态
-                if ($this->service->update($id, $data)) {
-                    $services->agreeRefund((int)$res->id, $refund_data);
+                if ($services->agreeRefund((int)$res->id, $refund_data)) {
+                    $this->service->update($id, $data);
                     return app('json')->success('退款成功');
                 } else {
                     $services->storeProductOrderRefundYFasle((int)$id, $refund_price);

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

@@ -660,7 +660,7 @@ class StoreOrderController
         $orderData = $this->services->tidyOrder($order, true, true);
         $splitNum = $storeOrderCartInfoServices->getSplitCartNum($order['cart_id']);
         foreach ($orderData['cartInfo'] ?? [] as $key => $cart) {
-            $orderData['cartInfo'][$key]['one_postage_price'] = bcdiv($cart['postage_price'], $cart['cart_num'], 2);
+            $orderData['cartInfo'][$key]['one_postage_price'] = isset($cart['postage_price']) ? bcdiv($cart['postage_price'], $cart['cart_num'], 2) : 0;
             if ($cartId != '') {
                 if ($cart['id'] != $cartId) {
                     unset($orderData['cartInfo'][$key]);

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

@@ -219,7 +219,7 @@ class StoreOrderDao extends BaseDao
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    public function getOrderList(array $where, array $field, int $page = 0, int $limit = 0, array $with = [], $order = 'pay_time DESC,id DESC')
+    public function getOrderList(array $where, array $field, int $page = 0, int $limit = 0, array $with = [], $order = 'add_time DESC,id DESC')
     {
         return $this->search($where)->field($field)->with(array_merge(['user', 'spread', 'refund'], $with))->when($page && $limit, function ($query) use ($page, $limit) {
             $query->page($page, $limit);

+ 4 - 2
crmeb/app/dao/product/sku/StoreProductRuleDao.php

@@ -39,9 +39,11 @@ class StoreProductRuleDao extends BaseDao
      * @throws \think\db\exception\DbException
      * @throws \think\db\exception\ModelNotFoundException
      */
-    public function getList(array $where = [], int $page, int $limit)
+    public function getList(array $where = [], int $page = 0, int $limit = 0)
     {
-        return $this->search($where)->page($page, $limit)->order('id desc')->select()->toArray();
+        return $this->search($where)->when($page && $limit, function ($query) use ($page, $limit) {
+            $query->page($page, $limit);
+        })->order('id desc')->select()->toArray();
     }
 
     /**

+ 4 - 1
crmeb/app/services/agent/DivisionServices.php

@@ -140,7 +140,7 @@ class DivisionServices extends BaseServices
             'pwd' => $data['pwd'],
             'conf_pwd' => $data['conf_pwd'],
             'real_name' => $data['real_name'],
-            'roles' => implode(',', $data['roles']),
+            'roles' => $data['roles'],
             'status' => 1,
             'level' => 1,
             'division_id' => $uid
@@ -281,7 +281,10 @@ class DivisionServices extends BaseServices
     {
         /** @var UserServices $userServices */
         $userServices = app()->make(UserServices::class);
+        /** @var SystemAdminServices $adminServices */
+        $adminServices = app()->make(SystemAdminServices::class);
         $res = $userServices->update($uid, ['division_status' => $status]);
+        $res = $res && $adminServices->update(['division_id' => $uid], ['status' => $status]);
         if ($res) {
             return true;
         } else {

+ 2 - 2
crmeb/app/services/message/notice/WechatTemplateListService.php

@@ -125,8 +125,8 @@ class WechatTemplateListService extends NoticeService
             'keyword1' => $goodsName,
             'keyword2' => $order['pay_type'] == 'offline' ? '线下支付' : date('Y/m/d H:i', $order['pay_time']),
             'keyword3' => $order['user_address'],
-            'keyword4' => $data['delivery_name'],
-            'keyword5' => $data['delivery_id'],
+            'keyword4' => $order['delivery_name'],
+            'keyword5' => $order['delivery_id'],
             'remark' => '点击查看订单详情'
         ], '/pages/users/order_details/index?order_id=' . $order['order_id']);
     }

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

@@ -34,6 +34,7 @@ use crmeb\services\MiniProgramService;
 use crmeb\services\WechatService;
 use crmeb\services\workerman\ChannelService;
 use think\exception\ValidateException;
+use think\facade\Log;
 
 
 /**
@@ -231,10 +232,22 @@ class StoreOrderRefundServices extends BaseServices
                 'refund_price' => $orderRefundInfo['refund_price'],
             ], 'id');
             $this->dao->update($id, ['store_order_id' => $splitOrderInfo['id']]);
-            if ($orderInfo['id'] != $otherOrder['id']) {//拆分生成新订单了
+            if ($otherOrder['id'] != 0 && $orderInfo['id'] != $otherOrder['id']) {//拆分生成新订单了
                 //修改原订单还在申请的退款单
                 $this->dao->update(['store_order_id' => $orderInfo['id']], ['store_order_id' => $otherOrder['id']]);
             }
+
+            /** @var CapitalFlowServices $capitalFlowServices */
+            $capitalFlowServices = app()->make(CapitalFlowServices::class);
+            /** @var UserServices $userServices */
+            $userServices = app()->make(UserServices::class);
+            $userInfo = $userServices->get($splitOrderInfo['uid']);
+            $splitOrderInfo['nickname'] = $userInfo['nickname'];
+            $splitOrderInfo['phone'] = $userInfo['phone'];
+            if ($splitOrderInfo['pay_type'] == 'alipay' || $splitOrderInfo['pay_type'] == 'weixin' || $splitOrderInfo['pay_type'] == 'offline') {
+                $capitalFlowServices->setFlow($splitOrderInfo, 'refund');
+            }
+
             return $splitOrderInfo;
         });
 

+ 10 - 7
crmeb/app/services/pc/HomeServices.php

@@ -15,24 +15,27 @@ namespace app\services\pc;
 use app\services\BaseServices;
 use app\services\product\product\StoreCategoryServices;
 use app\services\product\product\StoreProductServices;
+use app\services\user\UserServices;
 
 class HomeServices extends BaseServices
 {
     /**
-     * 首页分类尚品
-     * @return mixed
+     * 首页分类商品
+     * @param int $uid
+     * @return array
      */
-    public function getCategoryProduct()
+    public function getCategoryProduct(int $uid = 0)
     {
         /** @var StoreCategoryServices $category */
         $category = app()->make(StoreCategoryServices::class);
         /** @var StoreProductServices $product */
         $product = app()->make(StoreProductServices::class);
-
+        $vip_user = $uid ? app()->make(UserServices::class)->value(['uid' => $uid], 'is_money_level') : 0;
         [$page, $limit] = $this->getPageValue();
         $list = $category->getCid($page, $limit);
-        foreach ($list as &$info) {
-            $productList = $product->getSearchList(['cid' => $info['id'], 'star' => 1, 'is_show' => 1, 'is_del' => 0], 1, 8, ['id,store_name,image,IFNULL(sales, 0) + IFNULL(ficti, 0) as sales,price,ot_price,presale']);
+        foreach ($list as $key => &$info) {
+            $productList = $product->getSearchList(['cid' => $info['id'], 'star' => 1, 'is_show' => 1, 'is_del' => 0, 'vip_user' => $vip_user], 1, 8, ['id,store_name,image,IFNULL(sales, 0) + IFNULL(ficti, 0) as sales,price,ot_price,presale']);
+            if (!count($productList)) unset($list[$key]);
             foreach ($productList as &$item) {
                 if (count($item['star'])) {
                     $item['star'] = bcdiv((string)array_sum(array_column($item['star'], 'product_score')), (string)count($item['star']), 1);
@@ -42,7 +45,7 @@ class HomeServices extends BaseServices
             }
             $info['productList'] = get_thumb_water($productList, 'mid');
         }
-        $data['list'] = $list;
+        $data['list'] = array_merge($list);
         $data['count'] = $category->getCidCount();
         return $data;
     }

+ 2 - 0
crmeb/app/services/pc/ProductServices.php

@@ -15,6 +15,7 @@ namespace app\services\pc;
 use app\services\BaseServices;
 use app\services\product\product\StoreProductServices;
 use app\services\system\attachment\SystemAttachmentServices;
+use app\services\user\UserServices;
 use crmeb\services\MiniProgramService;
 use crmeb\services\UploadService;
 use crmeb\services\UtilService;
@@ -36,6 +37,7 @@ class ProductServices extends BaseServices
 
         $where['is_show'] = 1;
         $where['is_del'] = 0;
+        $where['vip_user'] = $uid ? app()->make(UserServices::class)->value(['uid' => $uid], 'is_money_level') : 0;
         $data['count'] = $product->getCount($where);
         [$page, $limit] = $this->getPageValue();
         $list = $product->getSearchList($where + ['star' => 1], $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,presale']);

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

@@ -14,6 +14,7 @@ namespace app\services\product\product;
 
 use app\services\BaseServices;
 use app\services\product\sku\StoreProductAttrServices;
+use app\services\product\sku\StoreProductAttrValueServices;
 use app\services\serve\ServeServices;
 use app\services\system\attachment\SystemAttachmentCategoryServices;
 use app\services\system\attachment\SystemAttachmentServices;
@@ -244,6 +245,8 @@ class CopyTaobaoServices extends BaseServices
         $systemAttachmentCategoryService = app()->make(SystemAttachmentCategoryServices::class);
         /** @var StoreProductServices $StoreProductServices */
         $StoreProductServices = app()->make(StoreProductServices::class);
+        /** @var StoreProductAttrValueServices $StoreProductAttrValueServices */
+        $StoreProductAttrValueServices = app()->make(StoreProductAttrValueServices::class);
         $AttachmentCategory = $systemAttachmentCategoryService->getOne(['name' => $this->AttachmentCategoryName]);
         //不存在则创建
         if (!$AttachmentCategory) $AttachmentCategory = $systemAttachmentCategoryService->save(['pid' => '0', 'name' => $this->AttachmentCategoryName, 'enname' => '']);
@@ -274,6 +277,7 @@ class CopyTaobaoServices extends BaseServices
         $image = $slider_images[0];
         $slider_images = $slider_images ? json_encode($slider_images) : '';
         $StoreProductServices->update($id, ['slider_image' => $slider_images, 'image' => $image]);
+        $StoreProductAttrValueServices->update(['product_id' => $id], ['image' => $image]);
     }
 
 //    /**

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

@@ -205,7 +205,7 @@ class StoreCategoryServices extends BaseServices
     {
         $cate = $this->dao->getOne(['cate_name' => $data['cate_name']]);
         if ($cate && $cate['id'] != $id) {
-            throw new AdminException('该分类存在');
+            throw new AdminException('该分类存在');
         }
         $this->transaction(function () use ($id, $data) {
             $res = $this->dao->update($id, $data);

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

@@ -100,15 +100,6 @@ class SystemConfigServices extends BaseServices
             ],
             'show_value' => 1
         ],
-        'pay_success_printing_switch' => [
-            'son_type' => [
-                'develop_id' => '',
-                'printing_api_key' => '',
-                'printing_client_id' => '',
-                'terminal_number' => '',
-            ],
-            'show_value' => 1
-        ],
         'wss_open' => [
             'son_type' => [
                 'wss_local_cert' => '',
@@ -138,18 +129,6 @@ class SystemConfigServices extends BaseServices
             ],
             'show_value' => 1
         ],
-        'system_product_copy_type' => [
-            'son_type' => [
-                'copy_product_apikey' => '',
-            ],
-            'show_value' => 2
-        ],
-        'logistics_type' => [
-            'son_type' => [
-                'system_express_app_code' => '',
-            ],
-            'show_value' => 2
-        ],
         'ali_pay_status' => [
             'son_type' => [
                 'ali_pay_appid' => '',
@@ -168,15 +147,6 @@ class SystemConfigServices extends BaseServices
             ],
             'show_value' => 1
         ],
-        'config_export_open' => [
-            'son_type' => [
-                'config_export_to_name' => '',
-                'config_export_to_tel' => '',
-                'config_export_to_address' => '',
-                'config_export_siid' => '',
-            ],
-            'show_value' => 1
-        ],
         'image_watermark_status' => [
             'son_type' => [
                 'watermark_type' => [
@@ -211,6 +181,7 @@ class SystemConfigServices extends BaseServices
         'customer_type@' => [
             'son_type' => [
                 'customer_url' => '',
+                'customer_corpId' => '',
             ],
             'show_value' => 2
         ],

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

@@ -410,7 +410,7 @@ class UserExtractServices extends BaseServices
             $mark = '使用微信提现' . $insertData['extract_price'] . '元';
             /** @var WechatUserServices $wechatServices */
             $wechatServices = app()->make(WechatUserServices::class);
-            $openid = $wechatServices->getWechatOpenid($uid, request()->isRoutine() ? 'routine' : 'wechat');
+            $openid = $wechatServices->getWechatOpenid($uid, 'wechat');
             if (sys_config('brokerage_type', 0) && $openid) {
                 $insertData['status'] = 1;
                 /** @var StoreOrderCreateServices $services */

+ 1 - 1
crmeb/app/services/wechat/WechatQrcodeServices.php

@@ -221,7 +221,7 @@ class WechatQrcodeServices extends BaseServices
             foreach ($qrcodeInfo['label_id'] as $item) {
                 $labelArr[] = [
                     'uid' => $userInfo['uid'],
-                    'label_id' => $item
+                    'label_id' => $item['id'] ?? $item
                 ];
             }
             $labelServices->saveAll($labelArr);

+ 2 - 1
crmeb/public/install/crmeb.sql

@@ -7630,7 +7630,8 @@ INSERT INTO `eb_system_config` (`id`, `menu_name`, `type`, `input_type`, `config
 (384, 'extract_type', 'checkbox', 'input', 74, '0=>银行卡\n1=>微信\n2=>支付宝', 1, '', 0, 0, '[\"0\",\"1\",\"2\"]', '提现方式', '提现方式', 0, 1),
 (385, 'integral_frozen', 'text', 'input', 11, '', 1, '', 100, 0, '\"0\"', '积分冻结(天)', '积分冻结(天)', 0, 1),
 (386, 'print_type', 'radio', 'input', 86, '1=>易联云', 1, '', 0, 0, '\"1\"', '平台选择', '平台选择', 0, 1),
-(387, 'config_export_type', 'radio', 'input', 93, '1=>一号通', 1, '', 0, 0, '\"1\"', '电子面单类型', '电子面单类型', 0, 1);
+(387, 'config_export_type', 'radio', 'input', 93, '1=>一号通', 1, '', 0, 0, '\"1\"', '电子面单类型', '电子面单类型', 0, 1),
+(388, 'customer_corpId', 'text', 'input', 69, '', 1, '', 100, 0, '\"\"', '企业ID', '小程序需要跳转企业微信客服的话需要配置此项', 0, 1);
 
 -- --------------------------------------------------------