Procházet zdrojové kódy

Merge branch 'v5.0.0dev' of https://gitee.com/ZhongBangKeJi/CRMEB into v5.0.0dev

From-wh před 2 roky
rodič
revize
c26015d032

+ 1 - 1
crmeb/app/adminapi/controller/v1/agent/AgentManage.php

@@ -60,7 +60,7 @@ class AgentManage extends AuthController
     public function get_badge()
     {
         $where = $this->request->getMore([
-            ['data', ''],
+            ['data', '', '', 'time'],
             ['nickname', ''],
         ]);
         return app('json')->success(['res' => $this->services->getSpreadBadge($where)]);

+ 7 - 2
crmeb/app/adminapi/controller/v1/agent/Division.php

@@ -121,19 +121,24 @@ class Division extends AuthController
      * 保存代理商
      * @param UserServices $userServices
      * @return mixed
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
     public function divisionAgentSave(UserServices $userServices)
     {
         $data = $this->request->postMore([
+            ['division_id', 0],
             ['uid', 0],
             ['division_percent', 0],
             ['division_end_time', ''],
             ['division_status', 1],
             ['edit', 0],
         ]);
-        $userInfo = $userServices->get((int)$data['uid']);
+        $userInfo = $userServices->count(['uid' => (int)$data['uid']]);
         if (!$userInfo) throw new AdminException(100100);
-        $data['division_id'] = $this->adminInfo['division_id'];
+        $divisionUserInfo = $userServices->count(['uid' => (int)$data['division_id'], 'is_division' => 1, 'division_id' => $data['division_id']]);
+        if (!$divisionUserInfo) throw new AdminException(100100);
         $this->services->divisionAgentSave($data);
         return app('json')->success(100000);
     }

+ 13 - 1
crmeb/app/adminapi/controller/v1/marketing/StoreCombination.php

@@ -182,7 +182,11 @@ class StoreCombination extends AuthController
 
     /**
      * 拼团人列表
+     * @param $id
      * @return mixed
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
     public function order_pink($id)
     {
@@ -207,12 +211,20 @@ class StoreCombination extends AuthController
      * 活动参与人
      * @param $id
      * @return mixed
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
     public function combinationStatisticsList($id)
     {
+        $where = $this->request->getMore([
+            ['real_name', '', '', 'keyword'],
+            ['status', '']
+        ]);
+        $where['cid'] = $id;
         /** @var StorePinkServices $storePinkServices */
         $storePinkServices = app()->make(StorePinkServices::class);
-        $list = $storePinkServices->systemPage(['cid' => $id]);
+        $list = $storePinkServices->systemPage($where);
         return app('json')->success($list);
     }
 

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

@@ -113,7 +113,7 @@ class StoreOrderController
     public function detail(Request $request, StoreOrderServices $services, UserServices $userServices, $orderId)
     {
         $economizeServices = app()->make(StoreOrderEconomizeServices::class);
-        $orderData = $services->getUserOrderByKey($economizeServices, $orderId, (int)$request->uid());
+        $orderData = $services->getUserOrderByKey($economizeServices, $orderId, 0);
         $orderData['nickname'] = $userServices->value(['uid' => $orderData['uid']], 'nickname');
         return app('json')->success($orderData);
     }

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

@@ -94,6 +94,10 @@ class StoreOrderController
      * @param Request $request
      * @param ShippingTemplatesServices $services
      * @return mixed
+     * @throws \Psr\SimpleCache\InvalidArgumentException
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
     public function confirm(Request $request, ShippingTemplatesServices $services)
     {
@@ -297,23 +301,6 @@ class StoreOrderController
         }
     }
 
-    /**
-     * TODO 支付宝单独支付 弃用
-     * @param OrderPayServices $payServices
-     * @param OtherOrderServices $services
-     * @param string $key
-     * @param string $quitUrl
-     * @return mixed
-     * @throws \think\db\exception\DataNotFoundException
-     * @throws \think\db\exception\DbException
-     * @throws \think\db\exception\ModelNotFoundException
-     */
-//    public function aliPay(OrderPayServices $payServices, OtherOrderServices $services, string $key, string $quitUrl)
-//    {
-//        $payInfo = $this->services->aliPayOrder($payServices, $services, $key, $quitUrl);
-//        return app('json')->success(['pay_content' => $payInfo]);
-//    }
-
     /**
      * 订单列表
      * @param Request $request
@@ -467,8 +454,14 @@ class StoreOrderController
     /**
      * 订单 查看物流
      * @param Request $request
+     * @param StoreOrderCartInfoServices $services
+     * @param ExpressServices $expressServices
      * @param $uni
+     * @param string $type
      * @return mixed
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
     public function express(Request $request, StoreOrderCartInfoServices $services, ExpressServices $expressServices, $uni, $type = '')
     {
@@ -535,6 +528,7 @@ class StoreOrderController
      * @param Request $request
      * @param StoreOrderCartInfoServices $cartInfoServices
      * @param StoreProductReplyServices $replyServices
+     * @return \think\Response|void
      * @throws \Psr\SimpleCache\InvalidArgumentException
      */
     public function comment(Request $request, StoreOrderCartInfoServices $cartInfoServices, StoreProductReplyServices $replyServices)
@@ -728,37 +722,6 @@ class StoreOrderController
             return app('json')->fail(100028);
     }
 
-    /**
-     * 订单申请退款审核
-     * @param Request $request
-     * @param StoreOrderRefundServices $services
-     */
-    public function refund_verify(Request $request, StoreOrderRefundServices $services)
-    {
-//        $data = $request->postMore([
-//            ['text', ''],
-//            ['refund_reason_wap_img', ''],
-//            ['refund_reason_wap_explain', ''],
-//            ['uni', ''],
-//            ['refund_type', 1],
-//            ['cart_id', 0],
-//            ['refund_num', 0]
-//        ]);
-//        $uni = $data['uni'];
-//        unset($data['uni']);
-//        if ($data['refund_reason_wap_img'] != '') {
-//            $data['refund_reason_wap_img'] = explode(',', $data['refund_reason_wap_img']);
-//        } else {
-//            $data['refund_reason_wap_img'] = [];
-//        }
-//        if (!$uni || $data['text'] == '' || $data['refund_num'] <= 0) return app('json')->fail('参数错误!');
-//        $res = $services->orderApplyRefund($this->services->getUserOrderDetail($uni, (int)$request->uid()), $data['text'], $data['refund_reason_wap_explain'], $data['refund_reason_wap_img'], $data['refund_type'], $data['cart_id'], $data['refund_num']);
-//        if ($res)
-//            return app('json')->success('提交申请成功');
-//        else
-//            return app('json')->fail('提交失败');
-    }
-
     /**
      * 用户退货提交快递单号
      * @param Request $request

+ 3 - 1
crmeb/app/dao/BaseDao.php

@@ -304,13 +304,14 @@ abstract class BaseDao
         $with = [];
         $otherWhere = [];
         $responses = new \ReflectionClass($this->setModel());
+
         foreach ($where as $key => $value) {
             $method = 'search' . Str::studly($key) . 'Attr';
             if ($responses->hasMethod($method)) {
                 $with[] = $key;
             } else {
                 if ($key != 'timeKey') {
-                    $otherWhere[] = $value;
+                    $otherWhere[] = is_array($value) ? $value : [$key, '=', $value];
                 }
             }
         }
@@ -320,6 +321,7 @@ abstract class BaseDao
     /**
      * 根据搜索器获取搜索内容
      * @param $where
+     * @param $search
      * @return BaseModel
      * @throws \ReflectionException
      * @author 吴汐

+ 3 - 0
crmeb/app/dao/activity/combination/StorePinkDao.php

@@ -56,6 +56,8 @@ class StorePinkDao extends BaseDao
     {
         return $this->search($where, false)->when($where['k_id'] != 0, function ($query) use ($where) {
             $query->whereOr('id', $where['k_id']);
+        })->when(isset($where['keyword']) && $where['keyword'] != '', function ($query) use ($where) {
+            $query->where('uid|nickname', 'like', '%' . $where['keyword'] . '%');
         })->with('getProduct')->when($page != 0, function ($query) use ($page, $limit) {
             $query->page($page, $limit);
         })->order('add_time desc')->select()->toArray();
@@ -138,6 +140,7 @@ class StorePinkDao extends BaseDao
     /**
      * 获取拼团完成的个数
      * @return float
+     * @throws \ReflectionException
      */
     public function getPinkOkSumTotalNum()
     {

+ 8 - 5
crmeb/app/dao/order/StoreOrderDao.php

@@ -447,8 +447,9 @@ class StoreOrderDao extends BaseDao
 
     /**
      * 获取订单详情
-     * @param $uid
-     * @param $key
+     * @param string $key
+     * @param int $uid
+     * @param array $with
      * @return array|\think\Model|null
      * @throws \think\db\exception\DataNotFoundException
      * @throws \think\db\exception\DbException
@@ -456,7 +457,9 @@ class StoreOrderDao extends BaseDao
      */
     public function getUserOrderDetail(string $key, int $uid, $with = [])
     {
-        return $this->getOne(['order_id|unique' => $key, 'uid' => $uid, 'is_del' => 0], '*', $with);
+        $where = ['order_id|unique' => $key, 'is_del' => 0];
+        if ($uid > 0) $where = $where + ['uid' => $uid];
+        return $this->getOne($where, '*', $with);
     }
 
     /**
@@ -965,9 +968,9 @@ class StoreOrderDao extends BaseDao
      */
     public function combinationStatisticsOrder($id, $where, $page = 0, $limit = 0)
     {
-        return $this->search($where)->where('combination_id', $id)
+        return $this->search($where)->where('combination_id', $id)->where('paid', 1)->whereIn('refund_type', [0, 3])->where('is_del', 0)
             ->when($page && $limit, function ($query) use ($page, $limit) {
                 $query->page($page, $limit);
-            })->field(['order_id', 'real_name', 'status', 'pay_price', 'total_num', 'add_time', 'pay_time', 'paid'])->select()->toArray();
+            })->field(['uid', 'order_id', 'real_name', 'status', 'pay_price', 'total_num', 'add_time', 'pay_time', 'paid'])->order('add_time desc')->select()->toArray();
     }
 }

+ 1 - 0
crmeb/app/dao/user/UserDao.php

@@ -176,6 +176,7 @@ class UserDao extends BaseDao
      * 获取推广员ids
      * @param array $where
      * @return array
+     * @throws \ReflectionException
      */
     public function getAgentUserIds(array $where)
     {

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

@@ -644,8 +644,8 @@ class StoreCombinationServices extends BaseServices
         $spread_count = $pinkServices->getDistinctCount([['cid', '=', $id], ['k_id', '>', 0]], 'uid', false);
         $start_count = $pinkServices->count(['cid' => $id, 'k_id' => 0]);
         $success_count = $pinkServices->count(['cid' => $id, 'k_id' => 0, 'status' => 2]);
-        $pay_price = $orderServices->sum(['combination_id' => $id, 'paid' => 1], 'pay_price', true);
-        $pay_count = $orderServices->getDistinctCount([['combination_id', '=', $id], ['paid', '=', 1]], 'uid', false);
+        $pay_price = $orderServices->sum([['combination_id', '=', $id], ['paid', '=', 1], ['refund_type', 'in', [0, 3]], ['is_del', '=', 0]], 'pay_price', false);
+        $pay_count = $orderServices->getDistinctCount([['combination_id', '=', $id], ['paid', '=', 1], ['refund_type', 'in', [0, 3]], ['is_del', '=', 0]], 'uid', false);
         return compact('people_count', 'spread_count', 'start_count', 'success_count', 'pay_price', 'pay_count');
     }
 

+ 10 - 1
crmeb/app/services/activity/combination/StorePinkServices.php

@@ -56,6 +56,9 @@ class StorePinkServices extends BaseServices
     /**
      * @param array $where
      * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
     public function systemPage(array $where)
     {
@@ -88,6 +91,9 @@ class StorePinkServices extends BaseServices
      * 参团人员
      * @param int $id
      * @return array
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
     public function getPinkMember(int $id)
     {
@@ -96,8 +102,11 @@ class StorePinkServices extends BaseServices
 
     /**
      * 拼团退款
-     * @param $id
+     * @param $order
      * @return bool
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
     public function setRefundPink($order)
     {

+ 4 - 5
crmeb/app/services/activity/integral/StoreIntegralOrderServices.php

@@ -160,8 +160,7 @@ class StoreIntegralOrderServices extends BaseServices
         if (!$addressId) {
             throw new ApiException(410045);
         }
-        if (!$addressInfo = $addressServices->getOne(['uid' => $uid, 'id' => $addressId, 'is_del' => 0]))
-        throw new ApiException(410046);
+        if (!$addressInfo = $addressServices->getOne(['uid' => $uid, 'id' => $addressId, 'is_del' => 0])) throw new ApiException(410046);
         $addressInfo = $addressInfo->toArray();
         $total_price = bcmul($productInfo['price'], $num, 2);
         /** @var UserBillServices $userBillServices */
@@ -226,7 +225,7 @@ class StoreIntegralOrderServices extends BaseServices
             $res2 = false !== $userServices->bcDec($userInfo['uid'], 'integral', $priceIntegral, 'uid');
             /** @var UserBillServices $userBillServices */
             $userBillServices = app()->make(UserBillServices::class);
-            $res3 = $userBillServices->income('storeIntegral_use_integral', $uid, $priceIntegral, $userInfo['integral'], $orderId);
+            $res3 = $userBillServices->income('storeIntegral_use_integral', $uid, $priceIntegral, $userInfo['integral'] - $priceIntegral, $orderId);
             $res2 = $res2 && false != $res3;
         }
         if (!$res2) {
@@ -334,7 +333,7 @@ class StoreIntegralOrderServices extends BaseServices
         /** @var StoreProductAttrValueServices $StoreProductAttrValueServices */
         $StoreProductAttrValueServices = app()->make(StoreProductAttrValueServices::class);
         $attrValue = $StoreProductAttrValueServices->uniqueByField($unique, 'product_id,suk,price,image,unique');
-        if(!$attrValue || !isset($attrValue['storeIntegral']) || !$attrValue['storeIntegral']){
+        if (!$attrValue || !isset($attrValue['storeIntegral']) || !$attrValue['storeIntegral']) {
             throw new ApiException(410295);
         }
         $data = [];
@@ -734,7 +733,7 @@ class StoreIntegralOrderServices extends BaseServices
         if (!$remark) throw new AdminException(400106);
         if (!$id) throw new AdminException(100100);
         if (!$order = $this->dao->get($id)) {
-           throw new AdminException(100025);
+            throw new AdminException(100025);
         }
 
         $order->remark = $remark;

+ 8 - 2
crmeb/app/services/agent/DivisionServices.php

@@ -222,9 +222,11 @@ class DivisionServices extends BaseServices
         if ($uid && !$userInfo) throw new AdminException(400214);
         $field = [];
         if ($uid) {
+            $field[] = Form::number('division_id', '事业部UID', $userInfo['division_id'] ?? '')->disabled(true)->style(['width' => '173px']);
             $field[] = Form::number('uid', '用户UID', $userInfo['uid'] ?? '')->disabled(true)->style(['width' => '173px']);
             $field[] = Form::hidden('edit', 1);
         } else {
+            $field[] = Form::number('division_id', '事业部UID')->style(['width' => '173px']);
             $field[] = Form::number('uid', '用户UID')->style(['width' => '173px']);
             $field[] = Form::hidden('edit', 0);
         }
@@ -238,20 +240,24 @@ class DivisionServices extends BaseServices
      * 保存代理商
      * @param $data
      * @return bool
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
      */
     public function divisionAgentSave($data)
     {
         /** @var UserServices $userServices */
         $userServices = app()->make(UserServices::class);
         $uid = $data['uid'];
-        $userInfo = $userServices->getUserInfo($uid, 'is_division,division_id,agent_id');
         $agentData = [
+            'division_id' => $data['division_id'],
             'division_status' => $data['division_status'],
             'division_percent' => $data['division_percent'],
             'division_change_time' => time(),
             'division_end_time' => strtotime($data['division_end_time']),
+            'division_type' => 2,
         ];
-        $division_info = $userServices->getUserInfo($userInfo['division_id'], 'division_end_time,division_percent');
+        $division_info = $userServices->getUserInfo($data['division_id'], 'division_end_time,division_percent');
         if ($division_info) {
             if ($agentData['division_percent'] > $division_info['division_percent']) throw new AdminException(400448);
             if ($agentData['division_end_time'] > $division_info['division_end_time']) throw new AdminException(400449);

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

@@ -237,6 +237,7 @@ class UserServices extends BaseServices
      * 获取分销员ids
      * @param array $where
      * @return array
+     * @throws \ReflectionException
      */
     public function getAgentUserIds(array $where)
     {

+ 5 - 5
template/admin/src/pages/division/agent/index.vue

@@ -27,6 +27,11 @@
     <Card :bordered="false" dis-hover class="ivu-mt">
       <Row class="ivu-mt box-wrapper">
         <Col :xs="24" :sm="24" ref="rightBox">
+          <Row type="flex">
+            <Col v-bind="grid">
+              <Button type="primary" @click="groupAdd('0')" class="mr20">添加代理商</Button>
+            </Col>
+          </Row>
           <Table
             :columns="columns"
             :data="userLists"
@@ -179,11 +184,6 @@ export default {
           slot: 'division_percent',
           minWidth: 100,
         },
-        {
-          title: '订单数量',
-          key: 'order_count',
-          minWidth: 100,
-        },
       ],
       columns: [
         {

+ 5 - 10
template/admin/src/pages/division/list/index.vue

@@ -179,24 +179,19 @@ export default {
           slot: 'nickname',
           minWidth: 150,
         },
-        {
-          title: '邀请码',
-          key: 'division_invite',
-          minWidth: 150,
-        },
         {
           title: '分销比例',
           slot: 'division_percent',
           minWidth: 100,
         },
         {
-          title: '用户数量',
-          key: 'user_count',
-          minWidth: 100,
+          title: '到期时间',
+          key: 'division_end_time',
+          minWidth: 150,
         },
         {
-          title: '订单数量',
-          key: 'order_count',
+          title: '员工数量',
+          key: 'agent_count',
           minWidth: 100,
         },
       ],

+ 2 - 2
template/admin/src/pages/marketing/live/creat_live.vue

@@ -117,7 +117,7 @@
               />
             </FormItem>
           </Col>
-          <Col span="24">
+          <!-- <Col span="24">
             <FormItem label="显示样式:">
               <RadioGroup v-model="formValidate.screen_type">
                 <Radio :label="item.label" v-for="(item, index) in screen_type" :key="index">
@@ -125,7 +125,7 @@
                 </Radio>
               </RadioGroup>
             </FormItem>
-          </Col>
+          </Col> -->
           <Col span="24">
             <FormItem label="直播间类型:">
               <RadioGroup v-model="formValidate.type">

+ 1 - 1
template/admin/src/pages/marketing/storeCombination/combinaList.vue

@@ -249,7 +249,7 @@ export default {
         },
         {
           title: '金额',
-          key: 'price',
+          key: 'total_price',
         },
         {
           title: '订单状态',

+ 2 - 2
template/admin/src/pages/marketing/storeCombination/statistics.vue

@@ -42,7 +42,7 @@
                 search
                 enter-button
                 v-model="pagination.real_name"
-                placeholder="请输入用户姓名|手机号|UID"
+                :placeholder="type == 1 ? '请输入用户|订单号|UID' : '请输入用户姓名|UID'"
                 @on-search="searchList"
               />
             </FormItem>
@@ -292,7 +292,7 @@ export default {
         },
         {
           title: '金额',
-          key: 'price',
+          key: 'total_price',
         },
         {
           title: '订单状态',

+ 1 - 1
template/admin/src/pages/user/list/handle/userDetails.vue

@@ -214,7 +214,7 @@ export default {
                     minWidth: 120,
                   },
                   {
-                    title: '变化积分',
+                    title: '变化积分',
                     key: 'balance',
                     minWidth: 120,
                   },

+ 1 - 1
template/uni-app/pages/activity/goods_combination_details/index.vue

@@ -258,7 +258,7 @@
 		<!-- #ifdef MP -->
 		<!-- <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize> -->
 		<!-- #endif -->
-		<product-window :attr='attribute' :limitNum='1' @myevent="onMyEvent" @ChangeAttr="ChangeAttr"
+		<product-window :attr='attribute' :limitNum='attribute.productSelect.quota' @myevent="onMyEvent" @ChangeAttr="ChangeAttr"
 			@ChangeCartNum="ChangeCartNum" @iptCartNum="iptCartNum" @attrVal="attrVal" @getImg="showImg">
 		</product-window>
 		<swiperPrevie ref="cusSwiperImg" :list="storeInfo.images"></swiperPrevie>

+ 1 - 1
template/uni-app/pages/goods/goods_return/index.vue

@@ -10,7 +10,7 @@
 					<view class='text acea-row row-between'>
 						<view class='name line2'>{{item.productInfo.store_name}}</view>
 						<view class='money'>
-							<view>{{$t(`¥`)}}{{(parseFloat(item.truePrice)+parseFloat(item.postage_price)).toFixed(2)}}
+							<view>{{$t(`¥`)}}{{(parseFloat(item.truePrice)+parseFloat(item.postage_price/item.cart_num)).toFixed(2)}}
 							</view>
 							<view class='num'>x{{item.cart_num}}</view>
 						</view>