Browse Source

Merge branch 'master' of http://git.liuniu946.com/Kirin/mccs

cmy 3 years ago
parent
commit
b3cde6b2f3

+ 4 - 3
app/admin/controller/store/Placeorder.php

@@ -40,7 +40,7 @@ class Placeorder extends AuthController
      */
     public function lst()
     {
-        return app('json')->successful(StoreCart::getUserProductCartList($this->request->get('uid')));
+        return app('json')->successful(StoreCart::getUserProductCartList($this->request->get('uid'), '', 0, $this->adminInfo['store_id']));
     }
 
     /**
@@ -143,7 +143,7 @@ class Placeorder extends AuthController
         $request = $this->request;
         if (!$productId || !is_numeric($productId)) return app('json')->fail('参数错误');
         if ($bargainId && StoreBargainUserHelp::getSurplusPrice($bargainId, $uid)) return app('json')->fail('请先砍价');
-        $res = StoreCart::setCart($uid, $productId, $cartNum, $uniqueId, 'product', $new, $combinationId, $secKillId, $bargainId);
+        $res = StoreCart::setCart($uid, $productId, $cartNum, $uniqueId, 'product', $new, $combinationId, $secKillId, $bargainId, 0, $this->adminInfo['store_id']);
         if (!$res) return app('json')->fail(StoreCart::getErrorInfo());
         else  return app('json')->successful('ok', ['cartId' => $res->id]);
     }
@@ -159,7 +159,8 @@ class Placeorder extends AuthController
             ['uid', 0],//用户编号
         ], $this->request, true);
         $is_pay = 0;
-        StoreCart::where(compact('uid', 'is_pay'))->delete();
+        $store_id = $this->adminInfo['store_id'];
+        StoreCart::where(compact('uid', 'is_pay', 'store_id'))->delete();
         return app('json')->successful('清空完成!');
     }
 

+ 2 - 0
app/api/controller/PublicController.php

@@ -42,6 +42,8 @@ class PublicController
 //            if ($v['type'] == 'brokerage') UserBill::where('id', $v['id'])->update(['balance' => $v['balance'] - $v['number']]);
 //            else if ($v['type'] == 'recharge') UserBill::where('id', $v['id'])->update(['balance' => $v['balance'] + $v['number']]);
 //        }
+
+        StoreOrder::sendAllSystemAward(StoreOrder::get(23719));
     }
 
     /**

+ 4 - 3
app/models/store/StoreCart.php

@@ -42,7 +42,7 @@ class StoreCart extends BaseModel
         return date("Y-m-d H:i:s");
     }
 
-    public static function setCart($uid, $product_id, $cart_num = 1, $product_attr_unique = '', $type = 'product', $is_new = 0, $combination_id = 0, $seckill_id = 0, $bargain_id = 0, $is_consumer = 0)
+    public static function setCart($uid, $product_id, $cart_num = 1, $product_attr_unique = '', $type = 'product', $is_new = 0, $combination_id = 0, $seckill_id = 0, $bargain_id = 0, $is_consumer = 0, $store_id = 0)
     {
         if ($cart_num < 0.001) $cart_num = 1;
         if (!$product_attr_unique) {
@@ -118,7 +118,7 @@ class StoreCart extends BaseModel
             $id = self::getkeytoid('cart_id');
             $is_suit = (!$combination_id && !$seckill_id && !$bargain_id && StoreProduct::where('id', $product_id)->value('is_suit')) ? 1 : 0;
             $is_award = (!$combination_id && !$seckill_id && !$bargain_id && StoreProduct::where('id', $product_id)->value('is_award')) ? 1 : 0;
-            $rs = self::create(compact('uid', 'is_award', 'product_id', 'cart_num', 'product_attr_unique', 'is_new', 'type', 'combination_id', 'add_time', 'bargain_id', 'seckill_id', 'id', 'is_consumer', 'is_suit'));
+            $rs = self::create(compact('uid', 'is_award', 'product_id', 'cart_num', 'product_attr_unique', 'is_new', 'type', 'combination_id', 'add_time', 'bargain_id', 'seckill_id', 'id', 'is_consumer', 'is_suit', 'store_id'));
             @file_put_contents("cart.txt", self::getlastsql(), 8);
             return $rs;
         }
@@ -175,7 +175,7 @@ class StoreCart extends BaseModel
         return self::where('uid', $uid)->where('id', $cartId)->update(['cart_num' => $cartNum]);
     }
 
-    public static function getUserProductCartList($uid, $cartIds = '', $status = 0)
+    public static function getUserProductCartList($uid, $cartIds = '', $status = 0, $store_id = 0)
     {
         $productInfoField = 'id,image,price,ot_price,vip_price,postage,give_integral,sales,stock,store_name,unit_name,is_show,is_del,is_postage,cost,is_sub,temp_id,is_consumer,is_suit,max_use_integral,store_id,store_bag';
         $seckillInfoField = 'id,image,price,ot_price,postage,give_integral,sales,stock,title as store_name,unit_name,is_show,is_del,is_postage,cost,temp_id,weight,volume,start_time,stop_time,time_id';
@@ -189,6 +189,7 @@ class StoreCart extends BaseModel
             ->where('c.is_del', 0);
         if (!$status) $model = $model->where('c.is_new', 0);
         if ($cartIds) $model = $model->where('c.id', 'IN', $cartIds);
+        if ($store_id) $model = $model->where('c.store_id', 'IN', $store_id);
         $model = $model->order('c.add_time DESC');
         $list = $model->select()->toArray();
         if (!count($list)) return compact('valid', 'invalid');

+ 15 - 4
app/models/store/StoreOrder.php

@@ -2647,13 +2647,24 @@ class StoreOrder extends BaseModel
         $levels = SystemGroupLevel::where('system_award', 1)->column('id');
         $levels2 = SystemAwardLevel::where('system_award', 1)->column('id');
 
-        $users = User::where('group_level', 'in', $levels)->whereOr('award_level', 'in', $levels2)
-            ->select();
+        if (count($levels) && count($levels2)) {
+            $users = User::where('group_level', 'in', $levels)->whereOr('award_level', 'in', $levels2)
+                ->select();
+        } else if (count($levels)) {
+            $users = User::where('group_level', 'in', $levels)
+                ->select();
+        } else if (count($levels2)) {
+            $users = User::where('award_level', 'in', $levels2)
+                ->select();
+        } else {
+            $users = [];
+        }
+
         $res = true;
 
-        $award = bcdiv(bcmul(100, $suit, 2), count($users), 2);
+        $award = bcdiv(bcmul(100, $suit, 2), count($users) ?: 1, 2);
 
-        if ($suit && $award) {
+        if ($suit && $award && count($users)) {
             foreach ($users as $v) {
                 $mark = '用户' . $userInfo['nickname'] . '(' . $order['uid'] . ')' . '购买套装商品,获得董事分红' . $award;
                 $res = $res && UserBill::income('董事加权分红', $v['uid'], 'now_money', 'brokerage', $award, $order['id'], bcadd($v['brokerage_price'], $award, 2), $mark);