WIN-2308041133\Administrator před 2 měsíci
rodič
revize
a1dab1f910

+ 1 - 0
app/adminapi/controller/v1/product/StoreProduct.php

@@ -270,6 +270,7 @@ class StoreProduct extends AuthController
             ['is_lb', 0],//是否礼品
             ['is_lb', 0],//是否礼品
             ['gift_price', 0],//礼品附加费
             ['gift_price', 0],//礼品附加费
         ]);
         ]);
+        @file_put_contents('quanju.txt', $data['is_lb'] . "-商品礼包\r\n", 8);
         $this->service->save((int)$id, $data);
         $this->service->save((int)$id, $data);
         return app('json')->success(100000);
         return app('json')->success(100000);
     }
     }

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

@@ -173,7 +173,7 @@ class StoreOrderController
         $userInfo = $request->user()->toArray();
         $userInfo = $request->user()->toArray();
         if ($checkOrder = $this->services->getOne(['order_id|unique' => $key, 'uid' => $userInfo['uid'], 'is_del' => 0]))
         if ($checkOrder = $this->services->getOne(['order_id|unique' => $key, 'uid' => $userInfo['uid'], 'is_del' => 0]))
             return app('json')->status('extend_order', 410209, ['orderId' => $checkOrder['order_id'], 'key' => $key]);
             return app('json')->status('extend_order', 410209, ['orderId' => $checkOrder['order_id'], 'key' => $key]);
-        [$addressId, $couponId, $payType, $useIntegral, $mark, $combinationId, $pinkId, $seckillId, $bargainId, $shipping_type, $real_name, $phone, $storeId, $news, $invoice_id, $advanceId, $customForm, $is_gift, $gift_mark] = $request->postMore([
+        [$addressId, $couponId, $payType, $useIntegral, $mark, $combinationId, $pinkId, $seckillId, $bargainId, $shipping_type, $real_name, $phone, $storeId, $news, $invoice_id, $advanceId, $customForm, $is_gift, $gift_mark, $lb_pid] = $request->postMore([
             [['addressId', 'd'], 0],
             [['addressId', 'd'], 0],
             [['couponId', 'd'], 0],
             [['couponId', 'd'], 0],
             ['payType', ''],
             ['payType', ''],
@@ -193,10 +193,11 @@ class StoreOrderController
             ['custom_form', []],
             ['custom_form', []],
             ['is_gift', 0],
             ['is_gift', 0],
             ['gift_mark', ''],
             ['gift_mark', ''],
+            ['lb_pid',0]
         ], true);
         ], true);
         $payType = strtolower($payType);
         $payType = strtolower($payType);
         $order = CacheService::lock('orderCreate' . $key, function () use ($createServices, $userInfo, $key, $addressId, $payType, $useIntegral, $couponId, $mark, $combinationId, $pinkId, $seckillId, $bargainId, $shipping_type, $real_name, $phone, $storeId, $news, $advanceId, $customForm, $invoice_id, $is_gift, $gift_mark) {
         $order = CacheService::lock('orderCreate' . $key, function () use ($createServices, $userInfo, $key, $addressId, $payType, $useIntegral, $couponId, $mark, $combinationId, $pinkId, $seckillId, $bargainId, $shipping_type, $real_name, $phone, $storeId, $news, $advanceId, $customForm, $invoice_id, $is_gift, $gift_mark) {
-            return $createServices->createOrder($userInfo['uid'], $key, $userInfo, $addressId, $payType, !!$useIntegral, $couponId, $mark, $combinationId, $pinkId, $seckillId, $bargainId, $shipping_type, $real_name, $phone, $storeId, !!$news, $advanceId, $customForm, $invoice_id, $is_gift, $gift_mark);
+            return $createServices->createOrder($userInfo['uid'], $key, $userInfo, $addressId, $payType, !!$useIntegral, $couponId, $mark, $combinationId, $pinkId, $seckillId, $bargainId, $shipping_type, $real_name, $phone, $storeId, !!$news, $advanceId, $customForm, $invoice_id, $is_gift, $gift_mark,$lb_pid);
         });
         });
         $orderId = $order['order_id'];
         $orderId = $order['order_id'];
         return app('json')->status('success', 410203, compact('orderId', 'key'));
         return app('json')->status('success', 410203, compact('orderId', 'key'));

+ 6 - 6
app/api/controller/v1/store/StoreCartController.php

@@ -89,12 +89,12 @@ class StoreCartController
             $type = 6;
             $type = 6;
         }
         }
         if ($type == 0) $cartService->checkVipGoodsBuy($request->user(), $where['productId']);
         if ($type == 0) $cartService->checkVipGoodsBuy($request->user(), $where['productId']);
-        //        检测是否是礼包商品
-        $storeServices = app()->make(StoreProductServices::class);
-        $is_lb = $storeServices->value(['id'=>$where['productId']],'is_lb');
-        if ($is_lb == 1){
-            return app('json')->fail('礼包商品不支持加入购物车');
-        }
+//        //        检测是否是礼包商品
+//        $storeServices = app()->make(StoreProductServices::class);
+//        $is_lb = $storeServices->value(['id'=>$where['productId']],'is_lb');
+//        if ($is_lb == 1){
+//            return app('json')->fail('礼包商品不支持加入购物车');
+//        }
         $res = $cartService->setCart($request->uid(), $where['productId'], $where['cartNum'], $where['uniqueId'], $type, $new, $where['combinationId'], $where['secKillId'], $where['bargainId'], $where['advanceId']);
         $res = $cartService->setCart($request->uid(), $where['productId'], $where['cartNum'], $where['uniqueId'], $type, $new, $where['combinationId'], $where['secKillId'], $where['bargainId'], $where['advanceId']);
         if (!$res) return app('json')->fail(100022);
         if (!$res) return app('json')->fail(100022);
         else  return app('json')->success(['cartId' => $res]);
         else  return app('json')->success(['cartId' => $res]);

+ 7 - 1
app/services/order/StoreOrderCreateServices.php

@@ -143,7 +143,7 @@ class StoreOrderCreateServices extends BaseServices
      * @email 442384644@qq.com
      * @email 442384644@qq.com
      * @date 2023/03/01
      * @date 2023/03/01
      */
      */
-    public function createOrder($uid, $key, $userInfo, $addressId, $payType, $useIntegral = false, $couponId = 0, $mark = '', $combinationId = 0, $pinkId = 0, $seckillId = 0, $bargainId = 0, $shippingType = 1, $real_name = '', $phone = '', $storeId = 0, $news = false, $advanceId = 0, $customForm = [], $invoice_id = 0, $is_gift = 0, $gift_mark = '')
+    public function createOrder($uid, $key, $userInfo, $addressId, $payType, $useIntegral = false, $couponId = 0, $mark = '', $combinationId = 0, $pinkId = 0, $seckillId = 0, $bargainId = 0, $shippingType = 1, $real_name = '', $phone = '', $storeId = 0, $news = false, $advanceId = 0, $customForm = [], $invoice_id = 0, $is_gift = 0, $gift_mark = '',$lb_pid=0)
     {
     {
         /** @var StoreOrderServices $orderService */
         /** @var StoreOrderServices $orderService */
         $storeOrderServices = app()->make(StoreOrderServices::class);
         $storeOrderServices = app()->make(StoreOrderServices::class);
@@ -213,6 +213,7 @@ class StoreOrderCreateServices extends BaseServices
         $cartIds = [];
         $cartIds = [];
         $totalNum = 0;
         $totalNum = 0;
         $gainIntegral = 0;
         $gainIntegral = 0;
+        $is_lb = 0;
         foreach ($cartInfo as $cart) {
         foreach ($cartInfo as $cart) {
             $cartIds[] = $cart['id'];
             $cartIds[] = $cart['id'];
             $totalNum += $cart['cart_num'];
             $totalNum += $cart['cart_num'];
@@ -222,6 +223,9 @@ class StoreOrderCreateServices extends BaseServices
             if (!$advanceId) $advanceId = $cart['advance_id'];
             if (!$advanceId) $advanceId = $cart['advance_id'];
             $cartInfoGainIntegral = isset($cart['productInfo']['give_integral']) ? bcmul((string)$cart['cart_num'], (string)$cart['productInfo']['give_integral'], 0) : 0;
             $cartInfoGainIntegral = isset($cart['productInfo']['give_integral']) ? bcmul((string)$cart['cart_num'], (string)$cart['productInfo']['give_integral'], 0) : 0;
             $gainIntegral = bcadd((string)$gainIntegral, (string)$cartInfoGainIntegral, 0);
             $gainIntegral = bcadd((string)$gainIntegral, (string)$cartInfoGainIntegral, 0);
+            if ($cart['productAttr']['product']['is_lb']==1){
+                $is_lb = 1;
+            }
         }
         }
         if (count($cartInfo) == 1 && isset($cartInfo[0]['productInfo']['presale']) && $cartInfo[0]['productInfo']['presale'] == 1) {
         if (count($cartInfo) == 1 && isset($cartInfo[0]['productInfo']['presale']) && $cartInfo[0]['productInfo']['presale'] == 1) {
             $advance_id = $cartInfo[0]['product_id'];
             $advance_id = $cartInfo[0]['product_id'];
@@ -281,6 +285,8 @@ class StoreOrderCreateServices extends BaseServices
             'division_id' => $userInfo['division_id'],
             'division_id' => $userInfo['division_id'],
             'agent_id' => $userInfo['agent_id'],
             'agent_id' => $userInfo['agent_id'],
             'staff_id' => $userInfo['staff_id'],
             'staff_id' => $userInfo['staff_id'],
+            'li_spread_uid' =>$lb_pid,
+            'is_lb' => $is_lb
         ];
         ];
 
 
         if ($shippingType == 2) {
         if ($shippingType == 2) {

+ 10 - 0
app/services/order/StoreOrderServices.php

@@ -23,6 +23,7 @@ use app\services\other\UploadService;
 use app\services\pay\OrderPayServices;
 use app\services\pay\OrderPayServices;
 use app\services\pay\PayServices;
 use app\services\pay\PayServices;
 use app\services\product\product\StoreProductLogServices;
 use app\services\product\product\StoreProductLogServices;
+use app\services\product\product\StoreProductServices;
 use app\services\serve\ServeServices;
 use app\services\serve\ServeServices;
 use app\services\system\attachment\SystemAttachmentServices;
 use app\services\system\attachment\SystemAttachmentServices;
 use app\services\system\store\SystemStoreServices;
 use app\services\system\store\SystemStoreServices;
@@ -1722,6 +1723,15 @@ HTML;
             'integralRatio' => sys_config('integral_ratio')
             'integralRatio' => sys_config('integral_ratio')
         ];
         ];
         $cartIdA = explode(',', $cartId);
         $cartIdA = explode(',', $cartId);
+        foreach ($cartIdA as $cartIdItem){
+        $product_id = $cartGroup['cartInfo'][$cartIdItem]['product_id'] ?? 0;
+                    //        检测是否是礼包商品
+        $storeServices = app()->make(StoreProductServices::class);
+        $is_lb = $storeServices->value(['id'=>$product_id],'is_lb');
+        if ($is_lb == 1){
+            return app('json')->fail('礼包商品不支持加入购物车');
+        }
+        }
         $seckill_id = 0;
         $seckill_id = 0;
         $combination_id = 0;
         $combination_id = 0;
         $bargain_id = 0;
         $bargain_id = 0;

+ 19 - 1
app/services/order/StoreOrderSuccessServices.php

@@ -17,7 +17,9 @@ use app\services\activity\lottery\LuckLotteryServices;
 use app\services\activity\combination\StorePinkServices;
 use app\services\activity\combination\StorePinkServices;
 use app\services\BaseServices;
 use app\services\BaseServices;
 use app\services\pay\PayServices;
 use app\services\pay\PayServices;
+use app\services\pc\UserServices;
 use app\services\product\product\StoreProductGiftGroupService;
 use app\services\product\product\StoreProductGiftGroupService;
+use app\services\user\UserBrokerageServices;
 use crmeb\exceptions\ApiException;
 use crmeb\exceptions\ApiException;
 
 
 /**
 /**
@@ -123,7 +125,12 @@ class StoreOrderSuccessServices extends BaseServices
             'store_name' => $orderInfo['storeName'],
             'store_name' => $orderInfo['storeName'],
             'add_time' => date('Y-m-d H:i:s', $orderInfo['add_time']),
             'add_time' => date('Y-m-d H:i:s', $orderInfo['add_time']),
         ]]);
         ]]);
-
+        if ($orderInfo['lb_spread_uid']>0){  //建立礼包推荐关系
+            self::createGiftRecommendationRelationship($orderInfo);
+        }
+        if ($orderInfo['is_lb']==1){  //赠送礼包推荐奖金
+            self::giftRecommendationBonus($orderInfo);
+        }
         $res = $res1 && $resPink;
         $res = $res1 && $resPink;
         return false !== $res;
         return false !== $res;
     }
     }
@@ -249,6 +256,17 @@ class StoreOrderSuccessServices extends BaseServices
         if ($userRelation['pid'] == $userRelation['fake_pid']) {
         if ($userRelation['pid'] == $userRelation['fake_pid']) {
             // 真直推上级和假直推上级相同,全部给直推上级
             // 真直推上级和假直推上级相同,全部给直推上级
             $userServices->addBrokerage($userRelation['pid'], $directBrokerage, '礼包直推奖');
             $userServices->addBrokerage($userRelation['pid'], $directBrokerage, '礼包直推奖');
+            // 添加佣金记录
+            /** @var UserBrokerageServices $userBrokerageServices */
+            $userBrokerageServices = app()->make(UserBrokerageServices::class);
+            //冻结时间
+            $frozenTime = time() + intval(sys_config('extract_time')) * 86400;
+            $res1 = $userBrokerageServices->income('get_two_brokerage', $spread_two_uid, [
+                'nickname' => $userInfo['nickname'],
+                'pay_price' => floatval($orderInfo['pay_price']),
+                'number' => floatval($brokeragePrice),
+                'frozen_time' => $frozenTime
+            ], $balance, $orderInfo['id']);
         } else {
         } else {
             // 真直推上级和假直推上级不同,各分50%
             // 真直推上级和假直推上级不同,各分50%
             $halfBrokerage = $directBrokerage * 0.5;
             $halfBrokerage = $directBrokerage * 0.5;

+ 4 - 0
app/services/product/product/StoreProductServices.php

@@ -711,6 +711,8 @@ class StoreProductServices extends BaseServices
                     throw new AdminException(400573);
                     throw new AdminException(400573);
                 }
                 }
                 unset($data['sales']);
                 unset($data['sales']);
+                @file_put_contents('quanju.txt', $data['is_lb'] . "-修改商品礼包\r\n", 8);
+
                 $this->dao->update($id, $data);
                 $this->dao->update($id, $data);
                 $storeDescriptionServices->saveDescription($id, $description);
                 $storeDescriptionServices->saveDescription($id, $description);
                 $cateData = [];
                 $cateData = [];
@@ -734,6 +736,8 @@ class StoreProductServices extends BaseServices
                 $data['add_time'] = time();
                 $data['add_time'] = time();
                 $data['code_path'] = '';
                 $data['code_path'] = '';
                 $data['spu'] = $this->createSpu();
                 $data['spu'] = $this->createSpu();
+                @file_put_contents('quanju.txt', $data['is_lb'] . "-创建商品礼包\r\n", 8);
+
                 $res = $this->dao->save($data);
                 $res = $this->dao->save($data);
                 $storeDescriptionServices->saveDescription($res->id, $description);
                 $storeDescriptionServices->saveDescription($res->id, $description);
                 $cateData = [];
                 $cateData = [];

+ 14 - 0
app/services/user/UserBrokerageServices.php

@@ -133,6 +133,20 @@ class UserBrokerageServices extends BaseServices
             'status' => 1,
             'status' => 1,
             'pm' => 1
             'pm' => 1
         ],
         ],
+        'get_direct_referral_brokerage' => [
+            'title' => '获得礼包直推奖',
+            'type' => 'gift_recommend_brokerage',
+            'mark' => '{%nickname%}成功消费礼包商品{%pay_price%}元,奖励直推奖{%number%}',
+            'status' => 1,
+            'pm' => 1
+        ],
+        'get_direct_referral_brokerage' => [
+            'title' => '获得礼包直推奖',
+            'type' => 'gift_recommend_brokerage',
+            'mark' => '{%nickname%}成功消费礼包商品{%pay_price%}元,奖励直推奖{%number%}',
+            'status' => 1,
+            'pm' => 1
+        ],
     ];
     ];