shichen месяцев назад: 10
Родитель
Сommit
c356fafcb2

+ 1 - 1
app/common/dao/user/UserBillDao.php

@@ -226,7 +226,7 @@ class UserBillDao extends BaseDao
226 226
         try {
227 227
             $dataList = UserBill::getDB()
228 228
                 ->where('type_shop', '=', $typeShop)
229
-                ->whereIn('order_id', $orderIdList)
229
+                ->whereIn('link_id', $orderIdList)
230 230
                 ->where('status', '=', UserBillEnum::STATUS['PENDING']['code'])
231 231
                 ->select()
232 232
                 ->toArray();

+ 51 - 1
app/common/dao/user/UserSignFugouDao.php

@@ -3,12 +3,20 @@
3 3
 namespace app\common\dao\user;
4 4
 
5 5
 use app\common\dao\BaseDao;
6
+use app\common\enum\user\UserSignFugouEnum;
7
+use app\common\model\BaseModel;
6 8
 use app\common\model\user\UserSignFugou;
7 9
 use app\entity\CommonEntity;
8 10
 use app\entity\data\user\UserSignFugouEntity;
11
+use think\db\exception\DataNotFoundException;
12
+use think\db\exception\DbException;
13
+use think\db\exception\ModelNotFoundException;
9 14
 
10 15
 class UserSignFugouDao extends BaseDao
11 16
 {
17
+    /**
18
+     * @return BaseModel
19
+     */
12 20
     protected function getModel(): string
13 21
     {
14 22
         return UserSignFugou::class;
@@ -18,7 +26,7 @@ class UserSignFugouDao extends BaseDao
18 26
      * @param array $idList
19 27
      * @return CommonEntity[]
20 28
      */
21
-    public function getStoreSignFugouEntityListByIdList(array $idList): array
29
+    public function getUserSignFugouEntityListByIdList(array $idList): array
22 30
     {
23 31
         $entityList = [];
24 32
         try {
@@ -38,4 +46,46 @@ class UserSignFugouDao extends BaseDao
38 46
         }
39 47
         return $entityList;
40 48
     }
49
+
50
+    /**
51
+     * @param string $orderType
52
+     * @param array $orderIdList
53
+     * @return UserSignFugouEntity[]
54
+     */
55
+    public function getUserSignFugouEntityListByOrderIdListAndPending(string $orderType, array $orderIdList): array
56
+    {
57
+        $entityList = [];
58
+        try {
59
+            /** @var UserSignFugou $model */
60
+            $model = $this->getModel();
61
+            $dataList = $model::getDB()
62
+                ->where('order_type', '=', $orderType)
63
+                ->whereIn('order_id', $orderIdList)
64
+                ->where('status', '=', UserSignFugouEnum::STATUS['Pending']['code'])
65
+                ->select()
66
+                ->toArray();
67
+            if (!empty($dataList)) {
68
+                $entityList = array_map(function ($data) {
69
+                    return UserSignFugouEntity::newInstance($data);
70
+                }, $dataList);
71
+            }
72
+        } catch (DataNotFoundException|ModelNotFoundException|DbException $e) {
73
+
74
+        }
75
+        return $entityList;
76
+    }
77
+
78
+    /**
79
+     * 批量更新
80
+     * @param $dataList
81
+     * @return array
82
+     */
83
+    public function saveAll($dataList): array
84
+    {
85
+        try {
86
+            return $this->getModel()::getInstance()->allowField(array_keys(reset($dataList)))->saveAll($dataList)->toArray();
87
+        } catch (\Exception $e) {
88
+            return [];
89
+        }
90
+    }
41 91
 }

+ 5 - 5
app/common/enum/CommonEnum.php

@@ -135,11 +135,11 @@ class CommonEnum
135 135
         'MemberZone' => [
136 136
             'Fixed' => [
137 137
                 'Basic' => [ // 售价 => 基础计算价格 (历史原因:原价是1000、2000...等,后来单间成本价上调了180,所以售价调整了,考虑到涨价前后的奖励应保持一致,所以设置了基础计算值)
138
-                    1180.00 => 1000.00,
139
-                    2360.00 => 2000.00,
140
-                    9440.00 => 8000.00,
141
-                    10620.00 => 9000.00,
142
-                    11800.00 => 10000.00
138
+                    '1180.00' => 1000.00,
139
+                    '2360.00' => 2000.00,
140
+                    '9440.00' => 8000.00,
141
+                    '10620.00' => 9000.00,
142
+                    '11800.00' => 10000.00
143 143
                 ]
144 144
             ],
145 145
             'Self' => [

+ 18 - 0
app/common/model/Region.php

@@ -0,0 +1,18 @@
1
+<?php
2
+
3
+namespace app\common\model;
4
+
5
+
6
+class Region extends BaseModel
7
+{
8
+
9
+    public static function tablePk(): string
10
+    {
11
+        return 'id';
12
+    }
13
+
14
+    public static function tableName(): string
15
+    {
16
+        return 'regions';
17
+    }
18
+}

+ 3 - 1
app/common/model/store/shipping/ShippingTemplateFree.php

@@ -8,6 +8,7 @@
8 8
 namespace app\common\model\store\shipping;
9 9
 
10 10
 use app\common\model\BaseModel;
11
+use app\common\model\Region;
11 12
 
12 13
 class ShippingTemplateFree extends BaseModel
13 14
 {
@@ -41,7 +42,8 @@ class ShippingTemplateFree extends BaseModel
41 42
         $result = [];
42 43
         if(is_array($city_id)){
43 44
             foreach ($city_id as $v){
44
-                $result[] = [City::where('city_id',$v)->value('parent_id') ?? 0,intval($v) ];
45
+                // $result[] = [City::where('city_id',$v)->value('parent_id') ?? 0,intval($v) ];
46
+                $result[] = [Region::where('id',$v)->value('pid') ?? 0,intval($v) ];
45 47
             }
46 48
         }
47 49
         return $result;

+ 3 - 1
app/common/model/store/shipping/ShippingTemplateRegion.php

@@ -8,6 +8,7 @@
8 8
 namespace app\common\model\store\shipping;
9 9
 
10 10
 use app\common\model\BaseModel;
11
+use app\common\model\Region;
11 12
 
12 13
 class ShippingTemplateRegion extends BaseModel
13 14
 {
@@ -40,7 +41,8 @@ class ShippingTemplateRegion extends BaseModel
40 41
         $result = [];
41 42
         if(is_array($city_id)){
42 43
             foreach ($city_id as $v){
43
-                $result[] = [City::where('city_id',$v)->value('parent_id') ?? 0,intval($v) ];
44
+                // $result[] = [City::where('city_id',$v)->value('parent_id') ?? 0,intval($v) ];
45
+                $result[] = [Region::where('id',$v)->value('pid') ?? 0,intval($v) ];
44 46
             }
45 47
         }
46 48
         return $result;

+ 3 - 1
app/common/model/store/shipping/ShippingTemplateUndelivery.php

@@ -8,6 +8,7 @@
8 8
 namespace app\common\model\store\shipping;
9 9
 
10 10
 use app\common\model\BaseModel;
11
+use app\common\model\Region;
11 12
 
12 13
 class ShippingTemplateUndelivery extends BaseModel
13 14
 {
@@ -40,7 +41,8 @@ class ShippingTemplateUndelivery extends BaseModel
40 41
         $result = [];
41 42
         if(is_array($city_id)){
42 43
             foreach ($city_id as $v){
43
-                $result[] = [City::where('city_id',$v)->value('parent_id') ?? 0,intval($v) ];
44
+                // $result[] = [City::where('city_id',$v)->value('parent_id') ?? 0,intval($v) ];
45
+                $result[] = [Region::where('id',$v)->value('pid') ?? 0,intval($v) ];
44 46
             }
45 47
         }else{
46 48
             $result['city_id'] = [];

+ 20 - 24
app/common/repositories/finance/FinanceRepository.php

@@ -1953,7 +1953,6 @@ class FinanceRepository extends BaseRepository
1953 1953
         $query = Db::name('user_pv_log')
1954 1954
         ->alias('uss')
1955 1955
         ->leftJoin('user u', 'u.uid=uss.uid')
1956
-        ->leftJoin('store_order o', 'o.order_id=uss.order_id')
1957 1956
         ->when(isset($params['uid']) && $params['uid'] != '', function ($query) use ($params) {
1958 1957
             $query->where('uss.uid', $params['uid']);
1959 1958
         })
@@ -1976,49 +1975,46 @@ class FinanceRepository extends BaseRepository
1976 1975
 
1977 1976
         //导出数据
1978 1977
         $is_excel = request()->param('is_excel', 0);
1979
-        if($is_excel == 1){
1978
+        if ($is_excel == 1) {
1980 1979
             $date['list'] = $this->date_where($query, $where['date'], 'uss.addtime', '-', 2)
1981
-            ->field('uss.id,uss.addtime,u.nickname,u.phone,uss.pv,o.order_sn,uss.status,uss.mark,u.score')
1982
-            ->order('uss.id', 'desc')
1983
-            ->select();
1980
+                ->field('uss.id,uss.addtime,u.nickname,u.phone,uss.pv,uss.order_id,uss.status,uss.mark')
1981
+                ->order('uss.id', 'desc')
1982
+                ->select();
1984 1983
             $arr = [];
1985
-            foreach ($date['list'] as $k=>$item){
1984
+            foreach ($date['list'] as $k => $item) {
1986 1985
                 switch ($item['status']) {
1987
-                    case '1':
1988
-                        $item['status'] = '有效';
1989
-                        break;
1990
-                    case '-1':
1991
-                        $item['status'] = '待确认';
1992
-                        break;
1993
-                    case '0':
1994
-                        $item['status'] = '已失效';
1995
-                        break;
1986
+                    case '1': $statusLabel = '有效'; break;
1987
+                    case '-1': $statusLabel = '待确认'; break;
1988
+                    case '0': $statusLabel = '已失效'; break;
1989
+                    default: $statusLabel = (string)$item['status'];
1996 1990
                 }
1997
-                $arr[] = array(
1991
+                $addtimeFormatted = is_numeric($item['addtime']) ? date('Y-m-d H:i:s', $item['addtime']) : $item['addtime'];
1992
+                $arr[] = [
1998 1993
                     $item['id'],
1999
-                    date('Y-m-d H:i:s', $item['addtime']),
1994
+                    $addtimeFormatted,
2000 1995
                     $item['nickname'],
2001 1996
                     $item['phone'],
2002 1997
                     $item['pv'],
2003
-                    $item['status'],
2004
-                    $item['order_sn'],
1998
+                    $statusLabel,
1999
+                    $item['order_id'],
2005 2000
                     $item['mark']
2006
-                );
2001
+                ];
2007 2002
             }
2008 2003
             return $this->getStatisticsExcel([
2009
-                'ID','时间','用户昵称','手机号','PV数','状态','关联订单','说名',
2004
+                'ID', '时间', '用户昵称', '手机号', 'PV数', '状态', '关联订单号', '说明',
2010 2005
             ], $arr, 'PV统计');
2011 2006
         }
2012 2007
 
2013 2008
 
2009
+
2014 2010
         $date['list'] = $this->date_where($query, $where['date'], 'uss.addtime', '-', 2)
2015
-            ->field('uss.id,uss.addtime,u.nickname,u.phone,uss.pv,o.order_sn,uss.status,uss.mark,u.score')
2011
+            ->field('uss.id,uss.addtime,u.nickname,u.phone,uss.pv,uss.order_id,uss.status,uss.mark,u.score')
2016 2012
             ->page($page, $limit)
2017 2013
             ->order('uss.id', 'desc')
2018 2014
             ->select()
2019 2015
             ->each(function ($item) {
2020
-                $item['mark'] = $item['mark'];
2021
-                $item['addtime'] = date('Y-m-d H:i:s', $item['addtime']);
2016
+                $item['addtime'] = is_numeric($item['addtime']) ? date('Y-m-d H:i:s', $item['addtime']) : $item['addtime'];
2017
+                $item['order_sn'] = $item['order_id'];
2022 2018
                 return $item;
2023 2019
             });
2024 2020
         $date['count'] = $query->count();

+ 4 - 1
app/common/repositories/gzc/GzcLogRepository.php

@@ -47,6 +47,7 @@ class GzcLogRepository extends BaseRepository
47 47
      */
48 48
     public function addGzcLog(int $uid, string $userName, string $mobile, string $userCard, int $orderType, string $orderId, float $pension, int $payType = 0): GzcLogEntity
49 49
     {
50
+        $linkId = 0;
50 51
         $orderSn = '';
51 52
         $payTime = '';
52 53
         if ($orderType == CommonEnum::ORDER_TYPE['Platform']['code']) {
@@ -68,6 +69,7 @@ class GzcLogRepository extends BaseRepository
68 69
         /** @var GzcLogEntity $gzcLogEntity */
69 70
         $gzcLogEntity = GzcLogEntity::newInstance();
70 71
         $gzcLogEntity->setUid($uid)
72
+            ->setPlatformNo('IN10' . (int)(microtime(true) * 1000) . mt_rand(10000, 99999))
71 73
             ->setUserName($userName)
72 74
             ->setMobile($mobile)
73 75
             ->setUserCard($userCard)
@@ -77,7 +79,8 @@ class GzcLogRepository extends BaseRepository
77 79
             ->setOrderType($orderType)
78 80
             ->setPayTime($payTime)
79 81
             ->setCreateTime($createTime)
80
-            ->setUpdateTime($createTime);
82
+            ->setUpdateTime($createTime)
83
+            ->setLinkId($orderId);
81 84
 
82 85
         return $this->createByEntity($gzcLogEntity);
83 86
     }

+ 163 - 94
app/common/repositories/store/order/StoreOrderRepository.php

@@ -85,6 +85,7 @@ use app\entity\data\user\UserAddressEntity;
85 85
 use app\entity\data\user\UserBillEntity;
86 86
 use app\entity\data\user\UserEntity;
87 87
 use app\entity\monomer\store\FzonePayTypeEntity;
88
+use app\entity\request\api\store\order\CalculatePostageRequestEntity;
88 89
 use app\entity\request\api\store\order\StoreOrderCreateRequestEntity;
89 90
 use app\model\common\JdOrderModel;
90 91
 use app\model\common\TbOrderModel;
@@ -11289,7 +11290,7 @@ class StoreOrderRepository extends BaseRepository
11289 11290
                             /** @var UserBillRepository $userBillRepository */
11290 11291
                             $userBillRepository = app()->make(UserBillRepository::class);
11291 11292
                             $userBillRepository->addUserBill(
11292
-                                $storeOrderEntity->getUid(),
11293
+                                $userEntityBySpreadUid->getUid(),
11293 11294
                                 UserBillEnum::COMMISSION_TYPE['PENSION']['code'],
11294 11295
                                 UserBillEnum::PM['INCOME']['code'],
11295 11296
                                 $yanglaojinBySpreadUid,
@@ -11648,6 +11649,17 @@ class StoreOrderRepository extends BaseRepository
11648 11649
                 $userBillRepository->executeByIdList($billIdList);
11649 11650
             }
11650 11651
 
11652
+            /** @var UserSignFugouRepository $userSignFugouRepository */
11653
+            $userSignFugouRepository = app()->make(UserSignFugouRepository::class);
11654
+            $userSignFugouEntityList = $userSignFugouRepository->getUserSignFugouEntityListByOrderIdListAndPending(UserSignFugouEnum::ORDER_TYPE['Platform']['code'], $unsettledOrderIdList);
11655
+            if (!empty($userSignFugouEntityList)) {
11656
+                $fugouIdList = array_map(function ($userSignFugouEntity) {
11657
+                    return $userSignFugouEntity->getId();
11658
+                }, $userSignFugouEntityList);
11659
+                // 去结算 养老金 和佣金
11660
+                $userSignFugouRepository->executeByIdList($fugouIdList);
11661
+            }
11662
+
11651 11663
             /** 结算 积分 */
11652 11664
             /** @var UserSignScoreRepository $userSignScoreRepository */
11653 11665
             $userSignScoreRepository = app()->make(UserSignScoreRepository::class);
@@ -11706,6 +11718,7 @@ class StoreOrderRepository extends BaseRepository
11706 11718
         $userEntity = $verifyResult['userEntity'];
11707 11719
         /** @var CartEntity[] $cartEntityList 发起创建订单的购物车列表 */
11708 11720
         $cartEntityList = $verifyResult['cartEntityList'];
11721
+        /** @var CartEntity[] $cartEntityMap 发起创建订单的购物车映射 */
11709 11722
         $cartEntityMap = array_column($cartEntityList, null, 'cartId');
11710 11723
         $cartIdList = array_keys($cartEntityMap);
11711 11724
         /** @var UserAddressEntity $addressEntity 地址信息 */
@@ -11733,19 +11746,6 @@ class StoreOrderRepository extends BaseRepository
11733 11746
         // /** @var StoreCouponUserRepository $storeCouponUserRepository */
11734 11747
         // $storeCouponUserRepository = app()->make(StoreCouponUserRepository::class);
11735 11748
 
11736
-        // 获取 运费表数据  商品 对应的 运费模板
11737
-        /** @var ShippingTemplateRepository $shippingTemplateRepository */
11738
-        $shippingTemplateRepository = app()->make(ShippingTemplateRepository::class);
11739
-        // 获取  商品 对应的 运费模板 de 指定不配送区域表
11740
-        /** @var ShippingTemplateUndeliveRepository $shippingTemplateUndeliveRepository */
11741
-        $shippingTemplateUndeliveRepository = app()->make(ShippingTemplateUndeliveRepository::class);
11742
-        // 获取  商品 对应的 运费模板 de 指定包邮信息表
11743
-        /** @var ShippingTemplateFreeRepository $shippingTemplateFreeRepository */
11744
-        $shippingTemplateFreeRepository = app()->make(ShippingTemplateFreeRepository::class);
11745
-        // 获取  商品 对应的 运费模板 de 配送区域表
11746
-        /** @var ShippingTemplateRegionRepository $shippingTemplateRegionRepository */
11747
-        $shippingTemplateRegionRepository = app()->make(ShippingTemplateRegionRepository::class);
11748
-
11749 11749
         // 商品
11750 11750
         /** @var ProductRepository $productRepository */
11751 11751
         $productRepository = app()->make(ProductRepository::class);
@@ -11834,85 +11834,14 @@ class StoreOrderRepository extends BaseRepository
11834 11834
             $price = bcmul($cartEntity->getCartNum(), $productAttrValueEntity->getPrice(), CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
11835 11835
 
11836 11836
             // 计算运费 获取该商品的运费模板 运费表
11837
-            // TODO  注意 这个地址好像有问题,我再 客户端->收货地址管理中 (rrx_user_address)增加的廊坊市 对应的城市编号是(code_list)315 且city_id 字段的值是 2,而我再后台设置 可配送地址时 ,廊坊市对应的编码是 58247
11838 11837
             // 判断商品是否是 供应链(微唯宝)商品
11839
-            $postage = 0.00;
11840
-            if (!empty($productAttrValueEntity->getGongSkuId())) {
11841
-                $freight = GongApiRequest::freight($addressEntity->getCityId(), [['sku_id' => $productAttrValueEntity->getGongSkuId(), 'num' => $cartEntity->getCartNum()]]);
11842
-                $postage = $freight['freight'] ?? 0;
11843
-            } else {
11844
-                $shippingTemplateEntity = $shippingTemplateRepository->getShippingTemplateEntityByShippingTemplateId($productEntity->getTempId());
11845
-                if (empty($shippingTemplateEntity->getShippingTemplateId())) {
11846
-                    throw new ValidateException('未查询到商品所绑定的运费模板');
11847
-                } else {
11848
-                    // 判断是否开启 开启指定区域不配送
11849
-                    if ($shippingTemplateEntity->getUndelivery() == ShippingTemplateEnum::UNDELIVERY['Yes']['code']) {
11850
-                        // 获取运费模板的 指定不配送区域列表
11851
-                        $shippingTemplateUndeliveryEntityList = $shippingTemplateUndeliveRepository->getShippingTemplateUndeliveryEntityListByTempId($shippingTemplateEntity->getShippingTemplateId());
11852
-                        foreach ($shippingTemplateUndeliveryEntityList as $shippingTemplateUndeliveryEntity) {
11853
-                            // 验证 此次配送地址 是否在不配送区域中
11854
-                            if (in_array($addressEntity->getCityId(), $shippingTemplateUndeliveryEntity->getCityIdList())) {
11855
-                                throw new ValidateException($productEntity->getStoreName() . '此商品不支持该配送区域');
11856
-                            }
11857
-                        }
11858
-                    }
11859
-
11860
-                    $isBaoYou = false;
11861
-                    $number = 0.00;
11862
-                    // 获取 当前商品的 计费方式 (计费方式 0=数量 1=重量 2=体积)
11863
-                    if ($shippingTemplateEntity->getType() == ShippingTemplateEnum::TYPE['Quantity']['code']) {
11864
-                        $number = $cartEntity->getCartNum();
11865
-                    } else if ($shippingTemplateEntity->getType() == ShippingTemplateEnum::TYPE['Weight']['code']) {
11866
-                        $number = bcmul($cartEntity->getCartNum(), $productAttrValueEntity->getWeight(), 2);
11867
-                    } else {
11868
-                        $number = bcmul($cartEntity->getCartNum(), $productAttrValueEntity->getVolume(), 2);
11869
-                    }
11870
-
11871
-                    // 获取 指定包邮信息 包邮信息表
11872
-                    $shippingTemplateFreeEntityList = $shippingTemplateFreeRepository->getShippingTemplateFreeEntityListByTempId($shippingTemplateEntity->getShippingTemplateId());
11873
-                    foreach ($shippingTemplateFreeEntityList as $shippingTemplateFreeEntity) {
11874
-                        // 判断当前收货地址 是不是 在 指定 包邮 地点内
11875
-                        if (in_array($addressEntity->getCityId(), $shippingTemplateFreeEntity->getCityIdList())) {
11876
-                            // 判断当前 商品 是否符合 最高包邮数量上限 和 最低包邮金额
11877
-                            if ($number <= $shippingTemplateFreeEntity->getNumber() && $price >= $shippingTemplateFreeEntity->getPrice()) {
11878
-                                $isBaoYou = true;
11879
-                            }
11880
-                        }
11881
-                    }
11882
-
11883
-                    // 如果不包邮 则需要计算邮费
11884
-                    if (!$isBaoYou){
11885
-                        // 配送区域表
11886
-                        $shippingTemplateRegionEntityList = $shippingTemplateRegionRepository->getShippingTemplateRegionEntityListByTempId($shippingTemplateEntity->getShippingTemplateId());
11887
-                        if (empty($shippingTemplateRegionEntityList)) {
11888
-                            throw new ValidateException($productEntity->getStoreName() . '此商品不支持该配送区域');
11889
-                        }
11890
-                        $isPeiSong = false;
11891
-                        foreach ($shippingTemplateRegionEntityList as $shippingTemplateRegionEntity) {
11892
-                            // 判断当前收货地址 是否在可配送区域内
11893
-                            if (in_array($addressEntity->getCityId(), $shippingTemplateRegionEntity->getCityIdList())) {
11894
-                                // 比如 该商品 重量 5.03kg 首件重量 2kg 运费 2元  续件重量 3kg 续费3元
11895
-                                // 那本次 运费就是 首件运费 + ((重量 - 首件重量)/续件重量) * 续费单价
11896
-                                // 那本次 运费就是 2 + ((5.03 - 2)/3)向上取整 * 3 = 8
11897
-                                // 首件(重量or体积) 运费计算
11898
-                                if ($number > $shippingTemplateRegionEntity->getFirst()) {
11899
-                                    // 数量(重量or体积) 超出 首件部分 也就是续费部分
11900
-                                    $excess = bcsub($number, $shippingTemplateRegionEntity->getFirst(), 3);
11901
-                                    // 查看 需 续费几次 并向上取整
11902
-                                    $continueNum = ceil(bcdiv($excess, $shippingTemplateRegionEntity->getContinue(), 3));
11903
-                                    $postage = bcmul($continueNum, $shippingTemplateRegionEntity->getContinuePrice(), 2);
11904
-                                } else {
11905
-                                    $postage = $shippingTemplateRegionEntity->getFirstPrice();
11906
-                                }
11907
-                                $isPeiSong = true;
11908
-                            }
11909
-                        }
11910
-                        if (!$isPeiSong) {
11911
-                            throw new ValidateException($productEntity->getStoreName() . '此商品不支持该配送区域');
11912
-                        }
11913
-                    }
11914
-                }
11915
-            }
11838
+            // $postage = $this->calculatePostage(
11839
+            //     $productEntity,
11840
+            //     $productAttrValueEntity,
11841
+            //     $cartEntity->getCartNum(),
11842
+            //     $addressEntity->getCityId()
11843
+            // );
11844
+            $postage = 0.00; // 默认全都包邮s
11916 11845
 
11917 11846
             // 汇付手续费 (订单价格 + 邮费) * 汇付手续费比例
11918 11847
             $commissionRate = bcmul(bcadd($price, $postage, CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT), CommonEnum::HUIFU_COMMISSION_CHARGE, CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
@@ -11969,7 +11898,7 @@ class StoreOrderRepository extends BaseRepository
11969 11898
                 ->setSeckill($productSeckillEntity->getId())
11970 11899
                 ->setYouhuiPrice($youhuiPrice)
11971 11900
                 ->setDouhuomall(empty($productEntity->getSpuId())?StoreOrderEnum::DOHUOMALL['PlatformOrder']['code']:StoreOrderEnum::DOHUOMALL['SupplyChainOrder']['code'])
11972
-                ->setDouhuomallStatus(StoreOrderEnum::DOHUOMALL_STATUS['NotSubmittedToWeiweiBao']['code'])
11901
+                ->setDouhuomallStatus(empty($productEntity->getSpuId()) ? null : StoreOrderEnum::DOHUOMALL_STATUS['NotSubmittedToWeiweiBao']['code'])
11973 11902
                 ->setFzonePaytype($storeOrderCreateRequestEntity->getFzonePayType())
11974 11903
                 ->setConPri($serviceMoney);
11975 11904
             $storeOrderEntityList[] = $storeOrderEntity;
@@ -12140,7 +12069,8 @@ class StoreOrderRepository extends BaseRepository
12140 12069
         }
12141 12070
 
12142 12071
         /** 验证分享信息 分享 */
12143
-        $shareEntity = [];
12072
+        /** @var ShareEntity $shareEntity */
12073
+        $shareEntity = ShareEntity::newInstance();
12144 12074
         if (!empty($storeOrderCreateRequestEntity->getShareId())) {
12145 12075
             /** @var ShareRepository $shareRepository */
12146 12076
             $shareRepository = app()->make(ShareRepository::class);
@@ -12290,4 +12220,143 @@ class StoreOrderRepository extends BaseRepository
12290 12220
             'storeProductAttrValueEntityMap' => $storeProductAttrValueEntityMap,
12291 12221
         ];
12292 12222
     }
12223
+
12224
+    /**
12225
+     * 根据 商品属性 唯一值、城市ID、数量 计算运费
12226
+     * @param CalculatePostageRequestEntity $calculatePostageRequestEntity
12227
+     * @return float|int|mixed|string
12228
+     */
12229
+    public function getPostageByUniqueAndCityIdAndNum(CalculatePostageRequestEntity $calculatePostageRequestEntity)
12230
+    {
12231
+        // 商品属性
12232
+        /** @var ProductAttrValueRepository $storeProductAttrValueRepository */
12233
+        $storeProductAttrValueRepository = app()->make(ProductAttrValueRepository::class);
12234
+        $storeProductAttrValueEntityList = $storeProductAttrValueRepository->getStoreProductAttrValueEntityByUnique($calculatePostageRequestEntity->getUnique());
12235
+        if (empty($storeProductAttrValueEntityList->getProductId())) {
12236
+            throw new ValidateException('未查询到商品属性信息');
12237
+        }
12238
+
12239
+        // 商品
12240
+        /** @var ProductRepository $storeProductRepository */
12241
+        $storeProductRepository = app()->make(ProductRepository::class);
12242
+        $storeProductEntity = $storeProductRepository->getStoreProductEntityByProductId($storeProductAttrValueEntityList->getProductId());
12243
+        if (empty($storeProductEntity->getProductId())) {
12244
+            throw new ValidateException('未查询到商品信息');
12245
+        }
12246
+
12247
+        return $this->calculatePostage(
12248
+            $storeProductEntity,
12249
+            $storeProductAttrValueEntityList,
12250
+            $calculatePostageRequestEntity->getNum(),
12251
+            $calculatePostageRequestEntity->getCityId()
12252
+        );
12253
+    }
12254
+
12255
+    /**
12256
+     * 计算运费
12257
+     * @param StoreProductEntity $productEntity
12258
+     * @param StoreProductAttrValueEntity $productAttrValueEntity
12259
+     * @param int $num
12260
+     * @param int $cityId
12261
+     * @return float|int|mixed|string
12262
+     */
12263
+    public function calculatePostage(StoreProductEntity $productEntity, StoreProductAttrValueEntity $productAttrValueEntity, int $num, int $cityId)
12264
+    {
12265
+        // 获取 运费表数据  商品 对应的 运费模板
12266
+        /** @var ShippingTemplateRepository $shippingTemplateRepository */
12267
+        $shippingTemplateRepository = app()->make(ShippingTemplateRepository::class);
12268
+        // 获取  商品 对应的 运费模板 de 指定不配送区域表
12269
+        /** @var ShippingTemplateUndeliveRepository $shippingTemplateUndeliveRepository */
12270
+        $shippingTemplateUndeliveRepository = app()->make(ShippingTemplateUndeliveRepository::class);
12271
+        // 获取  商品 对应的 运费模板 de 指定包邮信息表
12272
+        /** @var ShippingTemplateFreeRepository $shippingTemplateFreeRepository */
12273
+        $shippingTemplateFreeRepository = app()->make(ShippingTemplateFreeRepository::class);
12274
+        // 获取  商品 对应的 运费模板 de 配送区域表
12275
+        /** @var ShippingTemplateRegionRepository $shippingTemplateRegionRepository */
12276
+        $shippingTemplateRegionRepository = app()->make(ShippingTemplateRegionRepository::class);
12277
+        // 计算 该款商品 总金额
12278
+        $price = bcmul($num, $productAttrValueEntity->getPrice(), CommonEnum::DECIMAL_PLACES_OF_THE_AMOUNT);
12279
+        $postage = 0.00;
12280
+
12281
+        if (!empty($productAttrValueEntity->getGongSkuId())) {
12282
+            $freight = GongApiRequest::freight($cityId, [['sku_id' => $productAttrValueEntity->getGongSkuId(), 'num' => $num]]);
12283
+            $postage = $freight['freight'] ?? 0;
12284
+        } else {
12285
+            $shippingTemplateEntity = $shippingTemplateRepository->getShippingTemplateEntityByShippingTemplateId($productEntity->getTempId());
12286
+            if (empty($shippingTemplateEntity->getShippingTemplateId())) {
12287
+                throw new ValidateException('未查询到商品所绑定的运费模板');
12288
+            } else {
12289
+                // 判断是否开启 开启指定区域不配送
12290
+                if ($shippingTemplateEntity->getUndelivery() == ShippingTemplateEnum::UNDELIVERY['Yes']['code']) {
12291
+                    // 获取运费模板的 指定不配送区域列表
12292
+                    $shippingTemplateUndeliveryEntityList = $shippingTemplateUndeliveRepository->getShippingTemplateUndeliveryEntityListByTempId($shippingTemplateEntity->getShippingTemplateId());
12293
+                    foreach ($shippingTemplateUndeliveryEntityList as $shippingTemplateUndeliveryEntity) {
12294
+                        // 验证 此次配送地址 是否在不配送区域中
12295
+                        if (in_array($cityId, $shippingTemplateUndeliveryEntity->getCityIdList())) {
12296
+                            throw new ValidateException($productEntity->getStoreName() . '此商品不支持该配送区域');
12297
+                        }
12298
+                    }
12299
+                }
12300
+
12301
+                $isBaoYou = false;
12302
+                $number = 0.00;
12303
+                // 获取 当前商品的 计费方式 (计费方式 0=数量 1=重量 2=体积)
12304
+                if ($shippingTemplateEntity->getType() == ShippingTemplateEnum::TYPE['Quantity']['code']) {
12305
+                    $number = $num;
12306
+                } else if ($shippingTemplateEntity->getType() == ShippingTemplateEnum::TYPE['Weight']['code']) {
12307
+                    $number = bcmul($num, $productAttrValueEntity->getWeight(), 2);
12308
+                } else {
12309
+                    $number = bcmul($num, $productAttrValueEntity->getVolume(), 2);
12310
+                }
12311
+
12312
+                // 获取 指定包邮信息 包邮信息表
12313
+                $shippingTemplateFreeEntityList = $shippingTemplateFreeRepository->getShippingTemplateFreeEntityListByTempId($shippingTemplateEntity->getShippingTemplateId());
12314
+                foreach ($shippingTemplateFreeEntityList as $shippingTemplateFreeEntity) {
12315
+                    // 判断当前收货地址 是不是 在 指定 包邮 地点内
12316
+                    if (in_array($cityId, $shippingTemplateFreeEntity->getCityIdList())) {
12317
+                        // 判断当前 商品 是否符合 最高包邮数量上限 和 最低包邮金额
12318
+                        if ($number <= $shippingTemplateFreeEntity->getNumber() && $price >= $shippingTemplateFreeEntity->getPrice()) {
12319
+                            $isBaoYou = true;
12320
+                            break;
12321
+                        }
12322
+                    }
12323
+                }
12324
+
12325
+                // 如果不包邮 则需要计算邮费
12326
+                if (!$isBaoYou) {
12327
+                    // 配送区域表
12328
+                    $shippingTemplateRegionEntityList = $shippingTemplateRegionRepository->getShippingTemplateRegionEntityListByTempId($shippingTemplateEntity->getShippingTemplateId());
12329
+                    if (empty($shippingTemplateRegionEntityList)) {
12330
+                        throw new ValidateException($productEntity->getStoreName() . '此商品不支持该配送区域');
12331
+                    }
12332
+                    $isPeiSong = false;
12333
+                    foreach ($shippingTemplateRegionEntityList as $shippingTemplateRegionEntity) {
12334
+                        // 判断当前收货地址 是否在可配送区域内
12335
+                        if (in_array($cityId, $shippingTemplateRegionEntity->getCityIdList()) || $shippingTemplateRegionEntity->getCityId() == 0) {
12336
+                            // 比如 该商品 重量 5.03kg 首件重量 2kg 运费 2元  续件重量 3kg 续费3元
12337
+                            // 那本次 运费就是 首件运费 + ((重量 - 首件重量)/续件重量) * 续费单价
12338
+                            // 那本次 运费就是 2 + ((5.03 - 2)/3)向上取整 * 3 = 8
12339
+                            // 首件(重量or体积) 运费计算
12340
+                            if ($number > $shippingTemplateRegionEntity->getFirst()) {
12341
+                                // 数量(重量or体积) 超出 首件部分 也就是续费部分
12342
+                                $excess = bcsub($number, $shippingTemplateRegionEntity->getFirst(), 3);
12343
+                                // 查看 需 续费几次 并向上取整
12344
+                                $continueNum = ceil(bcdiv($excess, $shippingTemplateRegionEntity->getContinue(), 3));
12345
+                                $postage = bcmul($continueNum, $shippingTemplateRegionEntity->getContinuePrice(), 2);
12346
+                            } else {
12347
+                                $postage = $shippingTemplateRegionEntity->getFirstPrice();
12348
+                            }
12349
+                            $isPeiSong = true;
12350
+                            break;
12351
+                        }
12352
+                    }
12353
+                    if (!$isPeiSong) {
12354
+                        throw new ValidateException($productEntity->getStoreName() . '此商品不支持该配送区域');
12355
+                    }
12356
+                }
12357
+            }
12358
+        }
12359
+
12360
+        return $postage;
12361
+    }
12293 12362
 }

+ 2 - 2
app/common/repositories/user/UserBillRepository.php

@@ -590,7 +590,7 @@ class UserBillRepository extends BaseRepository
590 590
 
591 591
                 } else if ($userBillEntity->getCommissionType() == UserBillEnum::COMMISSION_TYPE['PENSION']['code']) {
592 592
 
593
-                    if ($userBillEntity->getGzc() == UserBillEnum::GZC_STATUS['NOT_ENTERED']) {
593
+                    if ($userBillEntity->getGzc() == UserBillEnum::GZC_STATUS['NOT_ENTERED']['code']) {
594 594
                         if (!empty($userCertificationEntityMapByUid[$userBillEntity->getUid()])) {
595 595
                             $userCertificationEntity = $userCertificationEntityMapByUid[$userBillEntity->getUid()];
596 596
                             // 创建公证处记录
@@ -600,7 +600,7 @@ class UserBillRepository extends BaseRepository
600 600
                                 $userCertificationEntity->getMobile(),
601 601
                                 $userCertificationEntity->getUserCard(),
602 602
                                 $userBillEntity->getTypeShop(),
603
-                                $userBillEntity->getOrderSn(),
603
+                                $userBillEntity->getLinkId(),
604 604
                                 $userBillEntity->getNumber()
605 605
                             );
606 606
 

+ 3 - 7
app/common/repositories/user/UserRepository.php

@@ -3126,9 +3126,7 @@ class UserRepository extends BaseRepository
3126 3126
    *@author cabbage
3127 3127
    *@date 2020-10-31
3128 3128
    * */
3129
-    public function update_spread($uid,$spread_account,$mark,$olld_id,$adminId){
3130
-        //推荐人信息
3131
-        $spread = Db::name("user")->where('account',$spread_account)->field("uid")->find();
3129
+    public function update_spread($uid,$spread_account,$mark,$olld_id,$adminId,$spread){
3132 3130
         //被推荐人信息
3133 3131
         $identity=Db::name("user")->where('uid',$uid)->field("identity,spread_uid")->find();
3134 3132
 //        $user_identity_log=Db::name("user_identity_log")->where(["link_id"=>$uid])->find();
@@ -3162,15 +3160,13 @@ class UserRepository extends BaseRepository
3162 3160
 
3163 3161
     }
3164 3162
 
3165
-    public function update_level_uid($uid, $account, $level_account, $mark,$adminId){
3166
-        $level = Db::name("user")->where('account',$level_account)->field("uid,account")->find();
3167
-        $levelId = Db::name("user")->where('account',$account)->value("uid");
3163
+    public function update_level_uid($uid, $olld_id, $level_account, $mark,$adminId,$level){
3168 3164
         if($level){
3169 3165
             try{
3170 3166
                 Db::name("user_level_change_records")->insert([
3171 3167
                     'operation_id' => $adminId,
3172 3168
                     'uid' => $uid,
3173
-                    'old_level_id' => $levelId,
3169
+                    'old_level_id' => $olld_id,
3174 3170
                     'new_level_id' => $level['uid'],
3175 3171
                     'mark' => $mark ]);
3176 3172
                 return Db::name("user")->where(["uid"=>$uid])->update(['level_id'=>$level['uid']]);

+ 126 - 42
app/common/repositories/user/UserSignFugouRepository.php

@@ -6,6 +6,7 @@ use app\common\dao\user\UserSignFugouDao;
6 6
 use app\common\enum\user\UserSignFugouEnum;
7 7
 use app\common\repositories\BaseRepository;
8 8
 use app\common\repositories\store\order\StoreOrderRepository;
9
+use app\entity\data\user\UserEntity;
9 10
 use app\entity\data\user\UserSignFugouEntity;
10 11
 use think\db\exception\DbException;
11 12
 use think\exception\ValidateException;
@@ -21,9 +22,9 @@ class UserSignFugouRepository extends BaseRepository
21 22
      * @param int $id
22 23
      * @return UserSignFugouEntity
23 24
      */
24
-    public function getStoreSignFugouEntityById(int $id): UserSignFugouEntity
25
+    public function getUserSignFugouEntityById(int $id): UserSignFugouEntity
25 26
     {
26
-        $entityList = $this->getStoreSignFugouEntityListByIdList([$id]);
27
+        $entityList = $this->getUserSignFugouEntityListByIdList([$id]);
27 28
         $entity = array_shift($entityList);
28 29
         if ($entity instanceof UserSignFugouEntity) {
29 30
             return $entity;
@@ -37,9 +38,19 @@ class UserSignFugouRepository extends BaseRepository
37 38
      * @param array $idList
38 39
      * @return UserSignFugouEntity[]
39 40
      */
40
-    public function getStoreSignFugouEntityListByIdList(array $idList): array
41
+    public function getUserSignFugouEntityListByIdList(array $idList): array
41 42
     {
42
-        return $this->dao->getStoreSignFugouEntityListByIdList($idList);
43
+        return $this->dao->getUserSignFugouEntityListByIdList($idList);
44
+    }
45
+
46
+    /**
47
+     * @param string $orderType
48
+     * @param array $orderIdList
49
+     * @return UserSignFugouEntity[]
50
+     */
51
+    public function getUserSignFugouEntityListByOrderIdListAndPending(string $orderType, array $orderIdList): array
52
+    {
53
+        return $this->dao->getUserSignFugouEntityListByOrderIdListAndPending($orderType, $orderIdList);
43 54
     }
44 55
 
45 56
     public function create($data)
@@ -104,49 +115,122 @@ class UserSignFugouRepository extends BaseRepository
104 115
     /**
105 116
      * 将 复购 记录设置为生效状态 并对用户的 复购 字段进行增减
106 117
      * @param int $id
107
-     * @return UserSignFugouEntity
118
+     * @return int
108 119
      */
109
-    public function execute(int $id): UserSignFugouEntity
120
+    public function execute(int $id): int
110 121
     {
111
-        $UserSignFugouEntity = $this->getStoreSignFugouEntityById($id);
112
-        if (empty($UserSignFugouEntity->getId()) || empty($UserSignFugouEntity->getUid())) {
113
-            throw new ValidateException('无效的复购记录');
114
-        }
115
-        if ($UserSignFugouEntity->getStatus() == UserSignFugouEnum::STATUS['Invalid']['code']) {
116
-            throw new ValidateException('该复购记录已失效');
117
-        }
118
-        if (!empty($UserSignFugouEntity->getSettlementTime()) || $UserSignFugouEntity->getStatus() == UserSignFugouEnum::STATUS['Valid']['code']) {
119
-            throw new ValidateException('该复购记录已更新,请勿重复操作');
120
-        }
122
+        $result = $this->executeByIdList([$id]);
123
+        return array_shift($result);
124
+    }
121 125
 
122
-        /** @var UserRepository $userRepository */
123
-        $userRepository = app()->make(UserRepository::class);
124
-        $userEntity = $userRepository->getUserEntityByUid($UserSignFugouEntity->getUid());
125
-        if (empty($userEntity->getUid())) {
126
-            throw new ValidateException('未查询到用户信息');
127
-        }
128
-        if ($UserSignFugouEntity->getType() == UserSignFugouEnum::TYPE['Consume']['code']) {
129
-            $surplus = bcsub($userEntity->getFugou(), $UserSignFugouEntity->getNumber(), 2);
130
-            if ($surplus < 0.00) {
131
-                throw new ValidateException('用户复购不足');
126
+    /**
127
+     * 将 复购 记录设置为生效状态 并对用户的 复购 字段进行增减
128
+     * @param array $idList
129
+     * @return array
130
+     */
131
+    public function executeByIdList(array $idList): array
132
+    {
133
+        $userSignFugouEntityList = $this->getUserSignFugouEntityListByIdList($idList);
134
+        $userIdList = [];
135
+
136
+        // 忽略 已经生效的 记录
137
+        $userSignFugouEntityList = array_filter($userSignFugouEntityList, function ($entity) use (&$userIdList) {
138
+            // 积分数据不为空 用户不为空 状态属于待结算 并且结算字段为空
139
+            if ((!empty($entity->getId()) && !empty($entity->getUid()) && ($entity->getStatus() == UserSignFugouEnum::STATUS['Pending']['code']) && empty($entity->getSettlementTime()))) {
140
+                $userIdList[] = $entity->getUid();
141
+                return true;
132 142
             }
133
-        } else {
134
-            $surplus = bcadd($userEntity->getFugou(), $UserSignFugouEntity->getNumber(), 2);
135
-        }
136
-        try {
137
-            $UserSignFugouEntity
138
-                ->setSurplus($surplus)
139
-                ->setSettlementTime(date('Y-m-d H:i:s'))
140
-                ->setStatus(UserSignFugouEnum::STATUS['Valid']['code']);
141
-            $userRepository->update($userEntity->getUid(), ['Fugou' => $surplus]);
142
-            $this->dao->update($UserSignFugouEntity->getId(), [
143
-                'surplus' => $UserSignFugouEntity->getSurplus(),
144
-                'settlement_time' => $UserSignFugouEntity->getSettlementTime(),
145
-                'status' => $UserSignFugouEntity->getStatus()
146
-            ]);
147
-        } catch (DbException $e) {
143
+            return false;
144
+        });
148 145
 
146
+        if (!empty($userSignFugouEntityList)) {
147
+            // 获取用户 映射信息
148
+            /** @var UserRepository $userRepository */
149
+            $userRepository = app()->make(UserRepository::class);
150
+            /** @var UserEntity[] $userEntityMapByUid */
151
+            $userEntityMapByUid = [];
152
+            if (!empty($userIdList)) {
153
+                $userEntityMapByUid = $userRepository->getUserEntityMapByUidList($userIdList);
154
+            }
155
+
156
+            /** @var UserEntity[] $updateUserEntityList */
157
+            $updateUserEntityList = [];
158
+            /** @var UserSignFugouEntity[] $updateUserFugouEntityList */
159
+            $updateUserFugouEntityList = [];
160
+            foreach ($userSignFugouEntityList as $userSignFugouEntity) {
161
+
162
+                $userEntity = $userEntityMapByUid[$userSignFugouEntity->getUid()];
163
+                if (empty($userEntity) || empty($userEntity->getUid())) {
164
+                    throw new ValidateException("未查询到用户信息(FugouId:{$userSignFugouEntity->getId()})");
165
+                }
166
+
167
+                // 组建 更新 用户信息
168
+                if (isset($updateUserEntityList[$userEntity->getUid()])) {
169
+                    $updateUserEntity = $updateUserEntityList[$userEntity->getUid()];
170
+                } else {
171
+                    /** @var UserEntity $updateUserEntity */
172
+                    $updateUserEntity = UserEntity::newInstance();
173
+                    $updateUserEntity
174
+                        ->setUid($userEntity->getUid())
175
+                        ->setFugou($userEntity->getFugou());
176
+
177
+                }
178
+                // 组建 账单 记录
179
+                if (isset($updateUserFugouEntityList[$userSignFugouEntity->getId()])) {
180
+                    $updateUserSignFugouEntity = $updateUserFugouEntityList[$userSignFugouEntity->getId()];
181
+                } else {
182
+                    /** @var UserSignFugouEntity $updateUserSignFugouEntity */
183
+                    $updateUserSignFugouEntity = UserSignFugouEntity::newInstance();
184
+                    // 更新 账单记录 状态
185
+                    $updateUserSignFugouEntity
186
+                        ->setId($userSignFugouEntity->getId())
187
+                        ->setStatus(UserSignFugouEnum::STATUS['Valid']['code'])
188
+                        ->setSettlementTime(date('Y-m-d H:i:s'));
189
+                }
190
+
191
+                if ($userSignFugouEntity->getType() == UserSignFugouEnum::TYPE['Consume']['code']) {
192
+                    // 支出
193
+                    $updateUserEntity->setFugou(bcsub($updateUserEntity->getFugou(), $userSignFugouEntity->getNumber(), 2));
194
+                    if ($updateUserEntity->getFugou() < 0.00) {
195
+                        throw new ValidateException('用户复购金不足');
196
+                    }
197
+                } else {
198
+                    $updateUserEntity->setFugou(bcadd($updateUserEntity->getFugou(), $userSignFugouEntity->getNumber(), 2));
199
+                }
200
+                $updateUserSignFugouEntity->setSurplus($updateUserEntity->getFugou());
201
+
202
+                $updateUserEntityList[$userSignFugouEntity->getUid()] = $updateUserEntity;
203
+                $updateUserFugouEntityList[$userSignFugouEntity->getId()] = $updateUserSignFugouEntity;
204
+            }
205
+            try {
206
+                if (!empty($updateUserEntityList)) {
207
+                    $userRepository->batchUpdateUserDataByDataList(
208
+                        array_map(function (UserEntity $updateUserEntity) {
209
+                            return $updateUserEntity->toUnderlineArray();
210
+                        }, $updateUserEntityList)
211
+                    );
212
+                }
213
+
214
+                if (!empty($updateUserFugouEntityList)) {
215
+                    $this->batchUpdateUserSignFugouDataByDataList(
216
+                        array_map(function (UserSignFugouEntity $updateUserSignFugouEntity) {
217
+                            return $updateUserSignFugouEntity->toUnderlineArray();
218
+                        }, $updateUserFugouEntityList)
219
+                    );
220
+                }
221
+            } catch (\Exception $e) {
222
+                throw new ValidateException('用户复购金结算失败');
223
+            }
149 224
         }
150
-        return $UserSignFugouEntity;
225
+        return $idList;
226
+    }
227
+
228
+    /**
229
+     * @param $dataList
230
+     * @return array
231
+     */
232
+    public function batchUpdateUserSignFugouDataByDataList($dataList): array
233
+    {
234
+        return $this->dao->saveAll($dataList);
151 235
     }
152 236
 }

+ 1 - 1
app/common/repositories/user/UserSignGongxianRepository.php

@@ -214,7 +214,7 @@ class UserSignGongxianRepository extends BaseRepository
214 214
                 );
215 215
             }
216 216
 
217
-            if (!empty($updateUserBillEntityList)) {
217
+            if (!empty($updateUserScoreEntityList)) {
218 218
                 $this->batchUpdateUserSignGongxianDataByDataList(
219 219
                     array_map(function (UserSignGongxianEntity $updateUserSignGongxianEntity) {
220 220
                         return $updateUserSignGongxianEntity->toUnderlineArray();

+ 2 - 2
app/common/repositories/user/UserSignScoreRepository.php

@@ -228,8 +228,8 @@ class UserSignScoreRepository extends BaseRepository
228 228
                         }, $updateUserScoreEntityList)
229 229
                     );
230 230
                 }
231
-            } catch (DbException $e) {
232
-
231
+            } catch (\Exception $e) {
232
+                throw new ValidateException('用户积分结算失败');
233 233
             }
234 234
         }
235 235
         return $idList;

+ 99 - 0
app/controller/admin/order/Order.php

@@ -331,4 +331,103 @@ class Order extends BaseController
331 331
         }
332 332
         return app('json')->fail('操作失败');
333 333
     }
334
+
335
+    /**
336
+     * 撤回订单,并撤回订单奖励
337
+     */
338
+    public function killOrderRewards(){
339
+        $group_order_id = request()->param('group_order_id');
340
+        $order_id = request()->param('order_id');
341
+        $uid = request()->param('uid');
342
+        if (empty($order_id) || empty($group_order_id) || empty($uid)) {
343
+            return app('json')->fail('参数缺失');
344
+        }
345
+        try {
346
+            Db::startTrans();
347
+            //查找是否有推荐人
348
+            $spreadUid = Db::name('user')->where('uid', $uid)->value('spread_uid');
349
+            //取出并删除 pv
350
+            $pv = $this->getValue('user_pv_log', [['order_id', '=', $order_id], ['status', '=', 1],], 'pv');
351
+            //取出 vr 消耗
352
+            $payVr = $this->getValue('user_sign_vr', [['order_id', '=', $order_id], ['type', '=', 2],], 'number');
353
+            //取出购买赠送积分 / 支出积分
354
+            $score = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['status', '=', 1], ['source_type', '=', 3], ['uid', '=', $uid], ['pm', '=', 1],], 'reward_socre');
355
+            $payScore = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['status', '=', 1], ['pm', '=', 2], ['uid', '=', $uid],], 'reward_socre');
356
+            // 贡献值
357
+            $gongXian = $this->getValue('user_sign_gongxian', [['order_id', '=', $order_id], ['status', '=', 1], ['type', '=', 1], ['uid', '=', $uid],], 'number');
358
+            // 养老金 / 推广养老金 / 推广佣金
359
+            $yangLaoJin = $this->getValue('user_bill', [['link_id', '=', $order_id], ['status', '=', 1], ['pm', '=', 1], ['uid', '=', $uid],], 'number');
360
+            if($spreadUid){
361
+                $spreadScore = 0;
362
+                $spreadGongXian = 0;
363
+                $spreadYlj = 0;
364
+                $spreadYongJin = 0;
365
+                $spreadScore = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['uid', '=', $spreadUid], ['status', '=', 1],], 'reward_socre');
366
+                $spreadGongXian = $this->getValue('user_sign_gongxian', [['order_id', '=', $order_id], ['status', '=', 1], ['type', '=', 1], ['uid', '=', $spreadUid],], 'number');
367
+                $spreadYlj = $this->getValue('user_bill', [['link_id', '=', $order_id], ['commission_type', '=', 5], ['uid', '=', $spreadUid],], 'number'); //推荐获得养老金
368
+                $spreadYongJin = $this->getValue('user_bill', [['link_id', '=', $order_id], ['commission_type', '=', 3], ['uid', '=', $spreadUid],], 'number');  //推荐获得佣金
369
+                $spreadUser = Db::name('user')->where('uid', $spreadUid)->find();
370
+                Db::name('backup_user')->insert($spreadUser);
371
+                Db::name('user')->where('uid', $spreadUid)->dec('score', $spreadScore)->update();
372
+                Db::name('user')->where('uid', $spreadUid)->dec('per_contribute', $spreadGongXian)->update();
373
+                Db::name('user')->where('uid', $spreadUid)->dec('annuity', $spreadYlj)->update();
374
+                Db::name('user')->where('uid', $spreadUid)->dec('brokerage_price', $spreadYongJin)->update();
375
+            }
376
+            //扫吗消费
377
+            $smSpreadUid = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['mark','like','%扫码%'], ['status', '=', 1],], 'uid');
378
+            $smSpreadScore = $this->getValue('user_sign_score', [['order_id', '=', $order_id], ['uid','=',$smSpreadUid], ['status', '=', 1],], 'reward_socre');
379
+            //第二推荐
380
+            $spreadYongJinTwo = $this->getValue('user_bill', [['link_id', '=', $order_id], ['commission_type', '=', 3], ['uid', '<>', $spreadUid],], 'number');
381
+            $spreadYongJinTwoUid = $this->getValue('user_bill', [['link_id', '=', $order_id], ['commission_type', '=', 3], ['uid', '<>', $spreadUid],], 'uid');
382
+            //更新对应的user表
383
+            $user = Db::name('user')->where('uid', $uid)->find();
384
+            Db::name('backup_user')->insert($user);
385
+            Db::name('user')->where('uid', $uid)->dec('pv', $pv)->update();
386
+            Db::name('user')->where('uid', $uid)->inc('vr', $payVr)->update();
387
+            Db::name('user')->where('uid', $uid)->inc('score', $payScore)->update();
388
+            Db::name('user')->where('uid', $uid)->dec('score', $score)->update();
389
+            Db::name('user')->where('uid', $uid)->dec('contribute', $gongXian)->update();
390
+            Db::name('user')->where('uid', $uid)->dec('annuity', $yangLaoJin)->update();
391
+            //第二推荐
392
+            if($spreadYongJinTwoUid) {
393
+                $spreadUserTwo = Db::name('user')->where('uid', $spreadYongJinTwoUid)->find();
394
+                Db::name('backup_user')->insert($spreadUserTwo);
395
+                Db::name('user')->where('uid', $spreadYongJinTwoUid)->dec('brokerage_price', $spreadYongJinTwo)->update();
396
+            }
397
+            if($smSpreadUid){
398
+                $smUserTwo = Db::name('user')->where('uid', $smSpreadUid)->find();
399
+                Db::name('backup_user')->insert($smUserTwo);
400
+                Db::name('user')->where('uid', $smSpreadUid)->dec('score', $smSpreadScore)->update();
401
+            }
402
+            // 删除订单相关表
403
+            $this->backupAndDelete('store_order', ['group_order_id' => $group_order_id]);
404
+            $this->backupAndDelete('store_group_order', ['group_order_id' => $group_order_id]);
405
+            $this->backupAndDelete('user_pv_log', ['order_id' => $order_id]);
406
+            $this->backupAndDelete('user_sign_vr', ['order_id' => $order_id]);
407
+            $this->backupAndDelete('user_sign_score', ['order_id' => $order_id]);
408
+            $this->backupAndDelete('user_sign_gongxian', ['order_id' => $order_id]);
409
+            $this->backupAndDelete('user_bill', ['link_id' => $order_id]);
410
+            $this->backupAndDelete('gzc_logs', ['link_id' => $order_id]);
411
+            Db::commit();
412
+        } catch (\Exception $e) {
413
+            Db::rollback();
414
+            return app('json')->fail('操作失败'. $e->getMessage());
415
+        }
416
+        return app('json')->success('操作成功');
417
+    }
418
+
419
+    private function backupAndDelete($table, array $where)
420
+    {
421
+        $backupTable = 'backup_' . $table;
422
+        $rows = Db::name($table)->where($where)->select()->toArray();
423
+        if ($rows) {
424
+            Db::name($backupTable)->insertAll($rows);
425
+            Db::name($table)->where($where)->delete();
426
+        }
427
+    }
428
+    private function getValue($table, array $where, string $field, $default = 0)
429
+    {
430
+        $value = Db::name($table)->where($where)->value($field);
431
+        return $value ?? $default;
432
+    }
334 433
 }

+ 35 - 54
app/controller/admin/user/User.php

@@ -815,9 +815,19 @@ class User extends BaseController
815 815
     {
816 816
         $spread_account = $this->request->param('spread_account');
817 817
         $adminId = $this->request->adminId();
818
-        $mark = $this->getMark($adminId,'spread');
818
+        $adminInfo = $this->request->adminInfo();
819
+        $operation = $adminInfo['account'].'修改用户推荐人';
820
+        $mark = $this->request->param('mark');
821
+        if (!empty($mark)) {
822
+            $mark = "($mark)";
823
+        }
824
+        $mark = $operation.$mark;
819 825
         $olld_id = Db::name('user')->where('uid', $id)->value('spread_uid')??0;
820
-        if($repository->update_spread($id,$spread_account,$mark,$olld_id,$adminId)){
826
+        $spread = Db::name("user")->where('account',$spread_account)->field("uid")->find();
827
+        if(!$spread){
828
+            return app('json')->fail("推荐人信息不存在");
829
+        }
830
+        if($repository->update_spread($id,$spread_account,$mark,$olld_id,$adminId,$spread)){
821 831
             return app('json')->success("修改成功");
822 832
         }else{
823 833
             return app('json')->fail("失败");
@@ -849,14 +859,23 @@ class User extends BaseController
849 859
      * */
850 860
     public function changeProLevel($id,UserRepository $repository) {
851 861
         $level_account = $this->request->param('level_account');
852
-        $level_account_old = $this->request->param('level_account_old');
853
-        $account = explode('(', $level_account_old)[0];
862
+        $olld_id = Db::name('user')->where('uid', $id)->value('level_id')??0;
854 863
         $adminId = $this->request->adminId();
855
-        $mark = $this->getMark($adminId,'level');
864
+        $adminInfo = $this->request->adminInfo();
865
+        $operation = $adminInfo['account'].'修改用户节点人';
866
+        $mark = $this->request->param('mark');
867
+        if (!empty($mark)) {
868
+            $mark = "($mark)";
869
+        }
870
+        $mark = $operation.$mark;
871
+        $level = Db::name("user")->where('account',$level_account)->field("uid,account")->find();
872
+        if(!$level){
873
+            return app('json')->fail("节点人信息不存在");
874
+        }
856 875
         if (!$id) {
857 876
             return app('json')->fail("参数丢失");
858 877
         }
859
-        if($repository->update_level_uid($id,$account,$level_account,$mark,$adminId)){
878
+        if($repository->update_level_uid($id,$olld_id,$level_account,$mark,$adminId,$level)){
860 879
             return app('json')->success("修改成功");
861 880
         }else{
862 881
             return app('json')->fail("失败"); }
@@ -874,11 +893,16 @@ class User extends BaseController
874 893
     }
875 894
     public function changeProGroup($id,UserRepository $repository)
876 895
     {
877
-        $adminId = $this->request->adminId();
878 896
         $old_identity_id = $this->request->param('old_identity_id');
879 897
         $new_identity_id = $this->request->param('new_identity_id');
880 898
         $adminId = $this->request->adminId();
881
-        $mark = $this->getMark($adminId,'identity');
899
+        $adminInfo = $this->request->adminInfo();
900
+        $operation = $adminInfo['account'].'修改用户身份';
901
+        $mark = $this->request->param('mark');
902
+        if (!empty($mark)) {
903
+            $mark = "($mark)";
904
+        }
905
+        $mark = $operation.$mark;
882 906
         if (empty($id) || empty($old_identity_id) || empty($new_identity_id)) {
883 907
             return app('json')->fail("参数丢失");
884 908
         }
@@ -2038,9 +2062,9 @@ class User extends BaseController
2038 2062
         $records = Db::name('user_identity_change_records')
2039 2063
             ->alias('r')
2040 2064
             ->join('user u', 'r.uid = u.uid', 'LEFT')
2041
-            ->field('r.operation_id,r.old_identity_id,r.new_identity_id,r.mark,r.create_time,u.nickname,u.account');
2065
+            ->field('r.operation_id,r.old_identity_id,r.uid,r.new_identity_id,r.mark,r.create_time,u.nickname,u.account');
2042 2066
             if($uid){
2043
-                $records->where('uid', $uid);
2067
+                $records->where('r.uid', $uid);
2044 2068
             }
2045 2069
             $query=$records
2046 2070
             ->order('create_time DESC')
@@ -2055,7 +2079,7 @@ class User extends BaseController
2055 2079
             ->alias('r')
2056 2080
             ->join('user u', 'u.uid = r.old_spread_id', 'LEFT')
2057 2081
             ->join('user ua', 'ua.uid = r.new_spread_id', 'LEFT')
2058
-            ->field('r.operation_id,r.uid,u,account as old_account,ua.account as new_account,r.mark, r.create_time');
2082
+            ->field('r.operation_id,r.uid,u.account as old_account,ua.account as new_account,r.mark, r.create_time');
2059 2083
 
2060 2084
         if ($uid) {
2061 2085
             $records->where('r.uid', $uid);
@@ -2100,47 +2124,4 @@ class User extends BaseController
2100 2124
             ->toArray();
2101 2125
         return app('json')->success($query, '获取成功');
2102 2126
     }
2103
-    /**
2104
-     * 通过后台管理员id和修改信息来区别默认备注
2105
-     */
2106
-    protected function getMark($adminId, string $type)
2107
-    {
2108
-        $mark = $this->request->param('mark');
2109
-        if ($mark) {
2110
-            return $mark;
2111
-        }
2112
-        $defaultMap = [
2113
-            'spread'   => '后台管理员修改用户推荐人',
2114
-            'level'     => '后台管理员修改用户节点人',
2115
-            'identity' => '后台管理员修改用户身份',
2116
-        ];
2117
-        $markMap = [
2118
-            'spread' => [
2119
-                1 => 'admin修改用户推荐人',
2120
-                10 => '商户+文章管理员修改用户推荐人',
2121
-                25 => '运营管理员修改用户推荐人',
2122
-                27 => '订单发货管理员修改用户推荐人',
2123
-                28 => '财务管理员修改用户推荐人',
2124
-                29 => '超级管理员修改用户推荐人',
2125
-            ],
2126
-            'node' => [
2127
-                1 => 'admin修改用户节点人',
2128
-                10 => '商户+文章管理员修改用户节点人',
2129
-                25 => '运营管理员修改用户节点人',
2130
-                27 => '订单发货管理员修改用户节点人',
2131
-                28 => '财务管理员修改用户节点人',
2132
-                29 => '超级管理员修改用户节点人',
2133
-            ],
2134
-            'identity' => [
2135
-                1 => 'admin修改用户身份',
2136
-                10 => '商户+文章管理员修改用户身份',
2137
-                25 => '运营管理员修改用户身份',
2138
-                27 => '订单发货管理员修改用户身份',
2139
-                28 => '财务管理员修改用户身份',
2140
-                29 => '超级管理员修改用户身份',
2141
-            ]
2142
-        ];
2143
-        return $markMap[$type][$adminId] ?? ($defaultMap[$type] ?? '哈基米修改用户信息');
2144
-    }
2145
-
2146 2127
 }

+ 28 - 0
app/controller/api/store/order/StoreOrder.php

@@ -20,8 +20,10 @@ use app\common\repositories\store\product\ProductAttrValueRepository;
20 20
 use app\common\repositories\user\UserAddressRepository;
21 21
 use app\common\repositories\user\UserRepository;
22 22
 use app\entity\data\user\UserEntity;
23
+use app\entity\request\api\store\order\CalculatePostageRequestEntity;
23 24
 use app\entity\request\api\store\order\StoreOrderCreateRequestEntity;
24 25
 use app\traits\ShouxinyiApiRequest;
26
+use app\validate\api\store\order\CalculatePostageValidate;
25 27
 use app\validate\api\store\order\StoreOrderCreateValidate;
26 28
 use crmeb\basic\BaseController;
27 29
 use app\common\repositories\store\order\StoreCartRepository;
@@ -1999,4 +2001,30 @@ class StoreOrder extends BaseController
1999 2001
     }
2000 2002
 
2001 2003
 
2004
+    /**
2005
+     * 计算运费
2006
+     *
2007
+     * @param CalculatePostageValidate $calculatePostageValidate
2008
+     * @return mixed
2009
+     */
2010
+    public function calculatePostage(CalculatePostageValidate $calculatePostageValidate)
2011
+    {
2012
+        // 1、接收参数
2013
+        $calculatePostageValidateResult = $calculatePostageValidate->validateRequest();
2014
+        // 如果验证失败,返回错误
2015
+        if ($calculatePostageValidateResult['status'] == 'error') {
2016
+            return app('json')->fail($calculatePostageValidateResult['message']);
2017
+        }
2018
+
2019
+        // 验证通过,继续处理数据
2020
+        /** @var CalculatePostageRequestEntity $calculatePostageRequestEntity */
2021
+        $calculatePostageRequestEntity = $calculatePostageValidateResult['data'];
2022
+
2023
+        // 2. 获取运费
2024
+        $postage = $this->repository->getPostageByUniqueAndCityIdAndNum($calculatePostageRequestEntity);
2025
+
2026
+        return app('json')->success([
2027
+            'postage' => $postage
2028
+        ]);
2029
+    }
2002 2030
 }

+ 79 - 79
app/entity/data/user/UserBillEntity.php

@@ -6,49 +6,49 @@ use app\entity\data\DataEntity;
6 6
 
7 7
 class UserBillEntity extends DataEntity
8 8
 {
9
-    public $bill_id = null;           // 用户账单id
10
-    public $uid = null;               // 用户uid
11
-    public $link_id = null;           // 关联订单id
12
-    public $pm = null;                // 0 = 支出 1 = 获得
13
-    public $title = null;             // 账单标题
14
-    public $category = null;          // 明细种类
15
-    public $type = null;              // 明细类型 commission佣金
16
-    public $number = null;            // 明细数字
17
-    public $balance = null;           // 剩余
18
-    public $mark = null;              // 备注
19
-    public $create_time = null;       // 添加时间
20
-    public $status = null;            // 0 = 待确定 1 = 有效 -1 = 无效
21
-    public $commission_type = null;   // 佣金类型
22
-    public $order_sn = null;          // 订单号
23
-    public $tripartite = null;        // 三方支付类型
24
-    public $type_shop = null;         // 平台或店铺类型
25
-    public $mer_id = null;            // 商户id
26
-    public $source = null;            // 1 线下 0线上
27
-    public $order_type = null;        // 订单类型 1自营 2 第三方
28
-    public $is_red_brokerage = null;  // 红积分对冲佣金 0正常佣金
29
-    public $gzc = null;               // 养老金是否已进入公证处log表
30
-    public $is_gzc = null;            // 养老金是否发起过
31
-    public $take_time = null;         // 结算时间
32
-    public $district_id = null;       // 区域ID
33
-    public $street_id = null;         // 街道ID
34
-    public $month = null;             // 月份
35
-    public $num = null;               // 份数
9
+    public $billId = null;  // 用户账单id
10
+    public $uid = null;  // 用户uid
11
+    public $linkId = null;  // 关联订单id
12
+    public $pm = null;  // 0 = 支出 1 = 获得
13
+    public $title = null;  // 账单标题
14
+    public $category = null;  // 明细种类
15
+    public $type = null;  // 明细类型
16
+    public $number = null;  // 明细数字
17
+    public $balance = null;  // 剩余
18
+    public $mark = null;  // 备注
19
+    public $createTime = null;  // 添加时间
20
+    public $status = null;  // 0 = 待确定 1 = 有效 -1 = 无效
21
+    public $commissionType = null;  // 佣金类型
22
+    public $orderSn = null;  // 订单号
23
+    public $tripartite = null;
24
+    public $typeShop = null;  // 0平台1多多进宝2唯品会3苏宁易购4网易考拉5淘宝客6京东联盟7饿了么8线上 9话费
25
+    public $merId = null;  // 商户id
26
+    public $source = null;  // 1 线下 0线上
27
+    public $orderType = null;  // 1自营 2 第三方 订单类型
28
+    public $isRedBrokerage = null;  // 1红积分对冲佣金 0正常佣金
29
+    public $gzc = null;  // 养老金是否已进入公证处log表0:未进入。1:已进入
30
+    public $isGzc = null;  // 0:未发起 1:已发起 2:已成功
31
+    public $takeTime = null;  // 结算时间
32
+    public $districtId = null;
33
+    public $streetId = null;
34
+    public $month = null;  // 月份
35
+    public $num = null;  // 份数
36 36
 
37 37
     /**
38 38
      * @return mixed
39 39
      */
40 40
     public function getBillId()
41 41
     {
42
-        return $this->bill_id;
42
+        return $this->billId;
43 43
     }
44 44
 
45 45
     /**
46
-     * @param mixed $bill_id
46
+     * @param mixed $billId
47 47
      * @return UserBillEntity
48 48
      */
49
-    public function setBillId($bill_id): UserBillEntity
49
+    public function setBillId($billId): UserBillEntity
50 50
     {
51
-        $this->bill_id = $bill_id;
51
+        $this->billId = $billId;
52 52
         return $this;
53 53
     }
54 54
 
@@ -75,16 +75,16 @@ class UserBillEntity extends DataEntity
75 75
      */
76 76
     public function getLinkId()
77 77
     {
78
-        return $this->link_id;
78
+        return $this->linkId;
79 79
     }
80 80
 
81 81
     /**
82
-     * @param mixed $link_id
82
+     * @param mixed $linkId
83 83
      * @return UserBillEntity
84 84
      */
85
-    public function setLinkId($link_id): UserBillEntity
85
+    public function setLinkId($linkId): UserBillEntity
86 86
     {
87
-        $this->link_id = $link_id;
87
+        $this->linkId = $linkId;
88 88
         return $this;
89 89
     }
90 90
 
@@ -219,16 +219,16 @@ class UserBillEntity extends DataEntity
219 219
      */
220 220
     public function getCreateTime()
221 221
     {
222
-        return $this->create_time;
222
+        return $this->createTime;
223 223
     }
224 224
 
225 225
     /**
226
-     * @param mixed $create_time
226
+     * @param mixed $createTime
227 227
      * @return UserBillEntity
228 228
      */
229
-    public function setCreateTime($create_time): UserBillEntity
229
+    public function setCreateTime($createTime): UserBillEntity
230 230
     {
231
-        $this->create_time = $create_time;
231
+        $this->createTime = $createTime;
232 232
         return $this;
233 233
     }
234 234
 
@@ -255,16 +255,16 @@ class UserBillEntity extends DataEntity
255 255
      */
256 256
     public function getCommissionType()
257 257
     {
258
-        return $this->commission_type;
258
+        return $this->commissionType;
259 259
     }
260 260
 
261 261
     /**
262
-     * @param mixed $commission_type
262
+     * @param mixed $commissionType
263 263
      * @return UserBillEntity
264 264
      */
265
-    public function setCommissionType($commission_type): UserBillEntity
265
+    public function setCommissionType($commissionType): UserBillEntity
266 266
     {
267
-        $this->commission_type = $commission_type;
267
+        $this->commissionType = $commissionType;
268 268
         return $this;
269 269
     }
270 270
 
@@ -273,16 +273,16 @@ class UserBillEntity extends DataEntity
273 273
      */
274 274
     public function getOrderSn()
275 275
     {
276
-        return $this->order_sn;
276
+        return $this->orderSn;
277 277
     }
278 278
 
279 279
     /**
280
-     * @param mixed $order_sn
280
+     * @param mixed $orderSn
281 281
      * @return UserBillEntity
282 282
      */
283
-    public function setOrderSn($order_sn): UserBillEntity
283
+    public function setOrderSn($orderSn): UserBillEntity
284 284
     {
285
-        $this->order_sn = $order_sn;
285
+        $this->orderSn = $orderSn;
286 286
         return $this;
287 287
     }
288 288
 
@@ -309,16 +309,16 @@ class UserBillEntity extends DataEntity
309 309
      */
310 310
     public function getTypeShop()
311 311
     {
312
-        return $this->type_shop;
312
+        return $this->typeShop;
313 313
     }
314 314
 
315 315
     /**
316
-     * @param mixed $type_shop
316
+     * @param mixed $typeShop
317 317
      * @return UserBillEntity
318 318
      */
319
-    public function setTypeShop($type_shop): UserBillEntity
319
+    public function setTypeShop($typeShop): UserBillEntity
320 320
     {
321
-        $this->type_shop = $type_shop;
321
+        $this->typeShop = $typeShop;
322 322
         return $this;
323 323
     }
324 324
 
@@ -327,16 +327,16 @@ class UserBillEntity extends DataEntity
327 327
      */
328 328
     public function getMerId()
329 329
     {
330
-        return $this->mer_id;
330
+        return $this->merId;
331 331
     }
332 332
 
333 333
     /**
334
-     * @param mixed $mer_id
334
+     * @param mixed $merId
335 335
      * @return UserBillEntity
336 336
      */
337
-    public function setMerId($mer_id): UserBillEntity
337
+    public function setMerId($merId): UserBillEntity
338 338
     {
339
-        $this->mer_id = $mer_id;
339
+        $this->merId = $merId;
340 340
         return $this;
341 341
     }
342 342
 
@@ -363,16 +363,16 @@ class UserBillEntity extends DataEntity
363 363
      */
364 364
     public function getOrderType()
365 365
     {
366
-        return $this->order_type;
366
+        return $this->orderType;
367 367
     }
368 368
 
369 369
     /**
370
-     * @param mixed $order_type
370
+     * @param mixed $orderType
371 371
      * @return UserBillEntity
372 372
      */
373
-    public function setOrderType($order_type): UserBillEntity
373
+    public function setOrderType($orderType): UserBillEntity
374 374
     {
375
-        $this->order_type = $order_type;
375
+        $this->orderType = $orderType;
376 376
         return $this;
377 377
     }
378 378
 
@@ -381,16 +381,16 @@ class UserBillEntity extends DataEntity
381 381
      */
382 382
     public function getIsRedBrokerage()
383 383
     {
384
-        return $this->is_red_brokerage;
384
+        return $this->isRedBrokerage;
385 385
     }
386 386
 
387 387
     /**
388
-     * @param mixed $is_red_brokerage
388
+     * @param mixed $isRedBrokerage
389 389
      * @return UserBillEntity
390 390
      */
391
-    public function setIsRedBrokerage($is_red_brokerage): UserBillEntity
391
+    public function setIsRedBrokerage($isRedBrokerage): UserBillEntity
392 392
     {
393
-        $this->is_red_brokerage = $is_red_brokerage;
393
+        $this->isRedBrokerage = $isRedBrokerage;
394 394
         return $this;
395 395
     }
396 396
 
@@ -417,16 +417,16 @@ class UserBillEntity extends DataEntity
417 417
      */
418 418
     public function getIsGzc()
419 419
     {
420
-        return $this->is_gzc;
420
+        return $this->isGzc;
421 421
     }
422 422
 
423 423
     /**
424
-     * @param mixed $is_gzc
424
+     * @param mixed $isGzc
425 425
      * @return UserBillEntity
426 426
      */
427
-    public function setIsGzc($is_gzc): UserBillEntity
427
+    public function setIsGzc($isGzc): UserBillEntity
428 428
     {
429
-        $this->is_gzc = $is_gzc;
429
+        $this->isGzc = $isGzc;
430 430
         return $this;
431 431
     }
432 432
 
@@ -435,16 +435,16 @@ class UserBillEntity extends DataEntity
435 435
      */
436 436
     public function getTakeTime()
437 437
     {
438
-        return $this->take_time;
438
+        return $this->takeTime;
439 439
     }
440 440
 
441 441
     /**
442
-     * @param mixed $take_time
442
+     * @param mixed $takeTime
443 443
      * @return UserBillEntity
444 444
      */
445
-    public function setTakeTime($take_time): UserBillEntity
445
+    public function setTakeTime($takeTime): UserBillEntity
446 446
     {
447
-        $this->take_time = $take_time;
447
+        $this->takeTime = $takeTime;
448 448
         return $this;
449 449
     }
450 450
 
@@ -453,16 +453,16 @@ class UserBillEntity extends DataEntity
453 453
      */
454 454
     public function getDistrictId()
455 455
     {
456
-        return $this->district_id;
456
+        return $this->districtId;
457 457
     }
458 458
 
459 459
     /**
460
-     * @param mixed $district_id
460
+     * @param mixed $districtId
461 461
      * @return UserBillEntity
462 462
      */
463
-    public function setDistrictId($district_id): UserBillEntity
463
+    public function setDistrictId($districtId): UserBillEntity
464 464
     {
465
-        $this->district_id = $district_id;
465
+        $this->districtId = $districtId;
466 466
         return $this;
467 467
     }
468 468
 
@@ -471,16 +471,16 @@ class UserBillEntity extends DataEntity
471 471
      */
472 472
     public function getStreetId()
473 473
     {
474
-        return $this->street_id;
474
+        return $this->streetId;
475 475
     }
476 476
 
477 477
     /**
478
-     * @param mixed $street_id
478
+     * @param mixed $streetId
479 479
      * @return UserBillEntity
480 480
      */
481
-    public function setStreetId($street_id): UserBillEntity
481
+    public function setStreetId($streetId): UserBillEntity
482 482
     {
483
-        $this->street_id = $street_id;
483
+        $this->streetId = $streetId;
484 484
         return $this;
485 485
     }
486 486
 

+ 69 - 0
app/entity/request/api/store/order/CalculatePostageRequestEntity.php

@@ -0,0 +1,69 @@
1
+<?php
2
+
3
+namespace app\entity\request\api\store\order;
4
+
5
+use app\entity\request\RequestCommonEntity;
6
+
7
+class CalculatePostageRequestEntity extends RequestCommonEntity
8
+{
9
+    // 收货地址 城市ID
10
+    public $cityId = 0;
11
+    // 商品ID
12
+    public $unique = '';
13
+    // 购买数量
14
+    public $num = 0;
15
+
16
+    /**
17
+     * @return int
18
+     */
19
+    public function getCityId(): int
20
+    {
21
+        return $this->cityId;
22
+    }
23
+
24
+    /**
25
+     * @param int $cityId
26
+     * @return CalculatePostageRequestEntity
27
+     */
28
+    public function setCityId(int $cityId): CalculatePostageRequestEntity
29
+    {
30
+        $this->cityId = $cityId;
31
+        return $this;
32
+    }
33
+
34
+    /**
35
+     * @return string
36
+     */
37
+    public function getUnique(): string
38
+    {
39
+        return $this->unique;
40
+    }
41
+
42
+    /**
43
+     * @param string $unique
44
+     * @return CalculatePostageRequestEntity
45
+     */
46
+    public function setUnique(string $unique): CalculatePostageRequestEntity
47
+    {
48
+        $this->unique = $unique;
49
+        return $this;
50
+    }
51
+
52
+    /**
53
+     * @return int
54
+     */
55
+    public function getNum(): int
56
+    {
57
+        return $this->num;
58
+    }
59
+
60
+    /**
61
+     * @param int $num
62
+     * @return CalculatePostageRequestEntity
63
+     */
64
+    public function setNum(int $num): CalculatePostageRequestEntity
65
+    {
66
+        $this->num = $num;
67
+        return $this;
68
+    }
69
+}

+ 42 - 0
app/validate/api/store/order/CalculatePostageValidate.php

@@ -0,0 +1,42 @@
1
+<?php
2
+
3
+namespace app\validate\api\store\order;
4
+
5
+use app\entity\request\api\store\order\CalculatePostageRequestEntity;
6
+use app\validate\CommonValidate;
7
+use think\facade\Log;
8
+
9
+class CalculatePostageValidate extends CommonValidate
10
+{
11
+
12
+    protected $rule = [
13
+        'cityId' => 'require|integer|egt:0',
14
+        'unique' => 'require',
15
+        'num' => 'require|integer|gt:0'
16
+    ];
17
+
18
+    protected $message = [
19
+        'cityId.require' => '城市ID不能为空!',
20
+        'cityId.integer' => '城市ID必须是整数!',
21
+        'cityId.egt' => '城市ID必须大于等于0!',
22
+        'unique.require' => '唯一标识不能为空!',
23
+        'num.require' => '购买数量不能为空!',
24
+        'num.integer' => '购买数量必须是整数!',
25
+        'num.gt' => '购买数量必须大于0!'
26
+    ];
27
+
28
+    /**
29
+     * 将Request参数获取与验证封装到验证类中
30
+     *
31
+     * @return array
32
+     */
33
+    public function validateRequest(): array
34
+    {
35
+        $data = $this->request->param();
36
+        Log::info('request-api-store-order-CalculatePostage-params:' . json_encode($data));
37
+        if (!$this->check($data)) {
38
+            return ['status' => 'error', 'message' => $this->getError()];
39
+        }
40
+        return ['status' => 'success', 'data' => CalculatePostageRequestEntity::newInstance($data)];
41
+    }
42
+}

+ 1 - 0
route/admin.php

@@ -980,6 +980,7 @@ Route::group(config('admin.api_admin_prefix') . '/', function () {
980 980
             Route::get('dhm_list/lst', 'RefundOrder/dhm_list')->name('systemRefundOrderDhmLst');
981 981
             Route::get('dhm_status', 'RefundOrder/dhm_status')->name('systemRefundOrderDhmStatus');
982 982
             Route::get('excel', 'Order/Excel')->name('systemOrderExcel');
983
+            Route::post('killOrderRewards', 'Order/killOrderRewards');
983 984
         })->prefix('admin.order.');
984 985
 
985 986
         //第三方订单

+ 7 - 0
route/api.php

@@ -85,6 +85,8 @@ Route::group('api/', function () {
85 85
             Route::post('tests/:order_sn', '/tests');
86 86
             Route::post('create', '/createOrder');//创建订单
87 87
             Route::post('createNew', '/createOrderNew');//创建订单
88
+            // 通过 商品ID 商品数量 ,使用商品选用的运费模板 计算邮费
89
+            Route::get('calculatePostage', '/calculatePostage');
88 90
             Route::post('delete', '/delete');//删除订单
89 91
             Route::post('create_annual_cost', '/create_annual_costorder');
90 92
             Route::post('create_activation_code_order', '/create_activation_code_order');
@@ -1328,6 +1330,11 @@ Route::get('test_external', 'api.store.merchant.Taskorderlianc/getUserPoints');
1328 1330
 Route::any('/share', function () {
1329 1331
     return view(app()->getRootPath() . 'public/share/register.html');
1330 1332
 });
1333
+
1334
+Route::any('/scrn', function () {
1335
+    return view(app()->getRootPath() . 'public/scrn/index.html');
1336
+});
1337
+
1331 1338
 Route::any('/', function () {
1332 1339
     $DB = DIRECTORY_SEPARATOR;
1333 1340