Kirin 3 anni fa
parent
commit
ca601136d3
1 ha cambiato i file con 141 aggiunte e 141 eliminazioni
  1. 141 141
      app/models/store/StoreOrder.php

+ 141 - 141
app/models/store/StoreOrder.php

@@ -838,7 +838,7 @@ class StoreOrder extends BaseModel
                 && self::addAwardLake(sys_config('gift_order_award_lake', 30, true), $order['id'], 'gift');
         }
         $res = $res_Gift && $res1 && $resPink && User::backOrderBrokerage($order)
-//            && self::areaAward($order)
+            && self::areaAward($order)
             && self::gainUserIntegral($order);
         if ($order['is_gift']) {
             $res = $res && User::sendBackOrderIntegral($order);
@@ -958,146 +958,146 @@ class StoreOrder extends BaseModel
         return $res;
     }
 
-//    public static function areaAward($order)
-//    {
-//        if (isset($order['combination_id']) && $order['combination_id']) return true;
-//        if (isset($order['seckill_id']) && $order['seckill_id']) return true;
-//        if (isset($order['bargain_id']) && $order['bargain_id']) return true;
-//        $userInfo = User::getUserInfo($order['uid']);
-//        $cartId = is_string($order['cart_id']) ? json_decode($order['cart_id'], true) : $order['cart_id'];
-//        list($realPrice, $virtualPrice) = StoreProduct::getProductPrice($cartId);
-//        if ($realPrice <= 0 && $virtualPrice <= 0) return true;
-//
-//        $province_admin_ratio = sys_config('province_admin_ratio', 0);
-//        $city_admin_ratio = sys_config('city_admin_ratio', 0);
-//        $district_admin_ratio = sys_config('district_admin_ratio', 0);
-//        $area_recommend_ratio = sys_config('area_recommend_ratio', 0);
-//        $res = true;
-//        $district = User::where('area_admin', 1)->where('area_province', $order['province'])->where('area_city', $order['city'])->where('area_district', $order['district'])->select();
-//        if (count($district) > 0) {
-//            $money_real = bcmul(bcdiv($district_admin_ratio, 100, 4), $realPrice, 2);
-//            $money_virtual = bcmul(bcdiv($district_admin_ratio, 100, 4), $virtualPrice, 2);
-//            $every_money_real = bcdiv($money_real, count($district), 2);
-//            $every_money_virtual = bcdiv($money_virtual, count($district), 2);
-//            if ($every_money_real <= 0 && $every_money_virtual <= 0) return true;
-//            $res = true;
-//            foreach ($district as $v) {
-//                if ($every_money_real > 0) {
-//                    $balance = bcadd($v['brokerage_price'], $every_money_real, 2);
-//                    $mark = $userInfo['nickname'] . '成功消费[实物产品]' . floatval($order['pay_price']) . '元,区代理分红' . floatval($every_money_real);
-//                    $res1 = UserBill::income('区代理分红', $v['uid'], 'now_money', 'brokerage', $every_money_real, $order['id'], $balance, $mark, 0);
-//                    $res = $res && $res1;
-//                    $sp_money = bcmul($every_money_real, bcdiv($area_recommend_ratio, 100, 4), 2);
-//                    if ($v['spread_uid'] && $sp_money > 0) {
-//                        $sp = User::where('uid', $v['spread_uid'])->find();
-//                        $balance = bcadd($sp['brokerage_price'], $sp_money, 2);
-//                        $mark = $userInfo['nickname'] . '成功消费[实物产品]' . floatval($order['pay_price']) . '元,推荐代理分红' . floatval($sp_money);
-//                        $res1 = UserBill::income('推荐代理分红', $sp['uid'], 'now_money', 'brokerage', $sp_money, $order['id'], $balance, $mark, 0);
-//                        $res = $res && $res1;
-//                    }
-//                }
-//                if ($every_money_virtual > 0) {
-//                    $balance = bcadd($v['brokerage_price'], $every_money_virtual, 2);
-//                    $mark = $userInfo['nickname'] . '成功消费[虚拟产品]' . floatval($order['pay_price']) . '元,区代理分红' . floatval($every_money_virtual);
-//                    $res1 = UserBill::income('区代理分红', $v['uid'], 'now_money', 'brokerage', $every_money_virtual, $order['id'], $balance, $mark);
-//                    $res2 = self::bcInc($v['uid'], 'brokerage_price', $every_money_virtual, 'uid');
-//                    $res = $res && $res1 && $res2;
-//                    $sp_money = bcmul($every_money_virtual, bcdiv($area_recommend_ratio, 100, 4), 2);
-//                    if ($v['spread_uid'] && $sp_money > 0) {
-//                        $sp = User::where('uid', $v['spread_uid'])->find();
-//                        $balance = bcadd($sp['brokerage_price'], $sp_money, 2);
-//                        $mark = $userInfo['nickname'] . '成功消费[虚拟产品]' . floatval($order['pay_price']) . '元,推荐代理分红' . floatval($sp_money);
-//                        $res1 = UserBill::income('推荐代理分红', $sp['uid'], 'now_money', 'brokerage', $sp_money, $order['id'], $balance, $mark, 0);
-//                        $res2 = self::bcInc($sp['uid'], 'brokerage_price', $sp_money, 'uid');
-//                        $res = $res && $res1 && $res2;
-//                    }
-//                }
-//            }
-//        }
-//        $city = User::where('area_admin', 2)->where('area_province', $order['province'])->where('area_city', $order['city'])->select();
-//        if (count($city) > 0) {
-//            $money_real = bcmul(bcdiv($city_admin_ratio, 100, 4), $realPrice, 2);
-//            $money_virtual = bcmul(bcdiv($city_admin_ratio, 100, 4), $virtualPrice, 2);
-//            $every_money_real = bcdiv($money_real, count($city), 2);
-//            $every_money_virtual = bcdiv($money_virtual, count($city), 2);
-//            if ($every_money_real <= 0 && $every_money_virtual <= 0) return true;
-//            $res = true;
-//            foreach ($city as $v) {
-//                if ($every_money_real > 0) {
-//                    $balance = bcadd($v['brokerage_price'], $every_money_real, 2);
-//                    $mark = $userInfo['nickname'] . '成功消费[实物产品]' . floatval($order['pay_price']) . '元,市代理分红' . floatval($every_money_real);
-//                    $res1 = UserBill::income('市代理分红', $v['uid'], 'now_money', 'brokerage', $every_money_real, $order['id'], $balance, $mark, 0);
-//                    $res = $res && $res1;
-//                    $sp_money = bcmul($every_money_real, bcdiv($area_recommend_ratio, 100, 4), 2);
-//                    if ($v['spread_uid'] && $sp_money > 0) {
-//                        $sp = User::where('uid', $v['spread_uid'])->find();
-//                        $balance = bcadd($sp['brokerage_price'], $sp_money, 2);
-//                        $mark = $userInfo['nickname'] . '成功消费[实物产品]' . floatval($order['pay_price']) . '元,推荐代理分红' . floatval($sp_money);
-//                        $res1 = UserBill::income('推荐代理分红', $sp['uid'], 'now_money', 'brokerage', $sp_money, $order['id'], $balance, $mark, 0);
-//                        $res = $res && $res1;
-//                    }
-//                }
-//                if ($every_money_virtual > 0) {
-//                    $balance = bcadd($v['brokerage_price'], $every_money_virtual, 2);
-//                    $mark = $userInfo['nickname'] . '成功消费[虚拟产品]' . floatval($order['pay_price']) . '元,市代理分红' . floatval($every_money_virtual);
-//                    $res1 = UserBill::income('市代理分红', $v['uid'], 'now_money', 'brokerage', $every_money_virtual, $order['id'], $balance, $mark);
-//                    $res2 = self::bcInc($v['uid'], 'brokerage_price', $every_money_virtual, 'uid');
-//                    $res = $res && $res1 && $res2;
-//                    $sp_money = bcmul($every_money_virtual, bcdiv($area_recommend_ratio, 100, 4), 2);
-//                    if ($v['spread_uid'] && $sp_money > 0) {
-//                        $sp = User::where('uid', $v['spread_uid'])->find();
-//                        $balance = bcadd($sp['brokerage_price'], $sp_money, 2);
-//                        $mark = $userInfo['nickname'] . '成功消费[虚拟产品]' . floatval($order['pay_price']) . '元,推荐代理分红' . floatval($sp_money);
-//                        $res1 = UserBill::income('推荐代理分红', $sp['uid'], 'now_money', 'brokerage', $sp_money, $order['id'], $balance, $mark, 0);
-//                        $res2 = self::bcInc($sp['uid'], 'brokerage_price', $sp_money, 'uid');
-//                        $res = $res && $res1 && $res2;
-//                    }
-//                }
-//            }
-//        }
-//        $province = User::where('area_admin', 3)->where('area_province', $order['province'])->select();
-//        if (count($province) > 0) {
-//            $money_real = bcmul(bcdiv($province_admin_ratio, 100, 4), $realPrice, 2);
-//            $money_virtual = bcmul(bcdiv($province_admin_ratio, 100, 4), $virtualPrice, 2);
-//            $every_money_real = bcdiv($money_real, count($province), 2);
-//            $every_money_virtual = bcdiv($money_virtual, count($province), 2);
-//            if ($every_money_real <= 0 && $every_money_virtual <= 0) return true;
-//            $res = true;
-//            foreach ($province as $v) {
-//                if ($every_money_real > 0) {
-//                    $balance = bcadd($v['brokerage_price'], $every_money_real, 2);
-//                    $mark = $userInfo['nickname'] . '成功消费[实物产品]' . floatval($order['pay_price']) . '元,省代理分红' . floatval($every_money_real);
-//                    $res1 = UserBill::income('省代理分红', $v['uid'], 'now_money', 'brokerage', $every_money_real, $order['id'], $balance, $mark, 0);
-//                    $res = $res && $res1;
-//                    $sp_money = bcmul($every_money_real, bcdiv($area_recommend_ratio, 100, 4), 2);
-//                    if ($v['spread_uid'] && $sp_money > 0) {
-//                        $sp = User::where('uid', $v['spread_uid'])->find();
-//                        $balance = bcadd($sp['brokerage_price'], $sp_money, 2);
-//                        $mark = $userInfo['nickname'] . '成功消费[实物产品]' . floatval($order['pay_price']) . '元,推荐代理分红' . floatval($sp_money);
-//                        $res1 = UserBill::income('推荐代理分红', $sp['uid'], 'now_money', 'brokerage', $sp_money, $order['id'], $balance, $mark, 0);
-//                        $res = $res && $res1;
-//                    }
-//                }
-//                if ($every_money_virtual > 0) {
-//                    $balance = bcadd($v['brokerage_price'], $every_money_virtual, 2);
-//                    $mark = $userInfo['nickname'] . '成功消费[虚拟产品]' . floatval($order['pay_price']) . '元,省代理分红' . floatval($every_money_virtual);
-//                    $res1 = UserBill::income('省代理分红', $v['uid'], 'now_money', 'brokerage', $every_money_virtual, $order['id'], $balance, $mark);
-//                    $res2 = self::bcInc($v['uid'], 'brokerage_price', $every_money_virtual, 'uid');
-//                    $res = $res && $res1 && $res2;
-//                    $sp_money = bcmul($every_money_virtual, bcdiv($area_recommend_ratio, 100, 4), 2);
-//                    if ($v['spread_uid'] && $sp_money > 0) {
-//                        $sp = User::where('uid', $v['spread_uid'])->find();
-//                        $balance = bcadd($sp['brokerage_price'], $sp_money, 2);
-//                        $mark = $userInfo['nickname'] . '成功消费[虚拟产品]' . floatval($order['pay_price']) . '元,推荐代理分红' . floatval($sp_money);
-//                        $res1 = UserBill::income('推荐代理分红', $sp['uid'], 'now_money', 'brokerage', $sp_money, $order['id'], $balance, $mark, 0);
-//                        $res2 = self::bcInc($sp['uid'], 'brokerage_price', $sp_money, 'uid');
-//                        $res = $res && $res1 && $res2;
-//                    }
-//                }
-//            }
-//        }
-//        return $res;
-//    }
+    public static function areaAward($order)
+    {
+        if (isset($order['combination_id']) && $order['combination_id']) return true;
+        if (isset($order['seckill_id']) && $order['seckill_id']) return true;
+        if (isset($order['bargain_id']) && $order['bargain_id']) return true;
+        $userInfo = User::getUserInfo($order['uid']);
+        $cartId = is_string($order['cart_id']) ? json_decode($order['cart_id'], true) : $order['cart_id'];
+        list($realPrice, $virtualPrice) = StoreProduct::getProductPrice($cartId);
+        if ($realPrice <= 0 && $virtualPrice <= 0) return true;
+
+        $province_admin_ratio = sys_config('province_admin_ratio', 0);
+        $city_admin_ratio = sys_config('city_admin_ratio', 0);
+        $district_admin_ratio = sys_config('district_admin_ratio', 0);
+        $area_recommend_ratio = sys_config('area_recommend_ratio', 0);
+        $res = true;
+        $district = User::where('area_admin', 1)->where('area_province', $order['province'])->where('area_city', $order['city'])->where('area_district', $order['district'])->select();
+        if (count($district) > 0) {
+            $money_real = bcmul(bcdiv($district_admin_ratio, 100, 4), $realPrice, 2);
+            $money_virtual = bcmul(bcdiv($district_admin_ratio, 100, 4), $virtualPrice, 2);
+            $every_money_real = bcdiv($money_real, count($district), 2);
+            $every_money_virtual = bcdiv($money_virtual, count($district), 2);
+            if ($every_money_real <= 0 && $every_money_virtual <= 0) return true;
+            $res = true;
+            foreach ($district as $v) {
+                if ($every_money_real > 0) {
+                    $balance = bcadd($v['brokerage_price'], $every_money_real, 2);
+                    $mark = $userInfo['nickname'] . '成功消费[实物产品]' . floatval($order['pay_price']) . '元,区代理分红' . floatval($every_money_real);
+                    $res1 = UserBill::income('区代理分红', $v['uid'], 'now_money', 'brokerage', $every_money_real, $order['id'], $balance, $mark, 0);
+                    $res = $res && $res1;
+                    $sp_money = bcmul($every_money_real, bcdiv($area_recommend_ratio, 100, 4), 2);
+                    if ($v['spread_uid'] && $sp_money > 0) {
+                        $sp = User::where('uid', $v['spread_uid'])->find();
+                        $balance = bcadd($sp['brokerage_price'], $sp_money, 2);
+                        $mark = $userInfo['nickname'] . '成功消费[实物产品]' . floatval($order['pay_price']) . '元,推荐代理分红' . floatval($sp_money);
+                        $res1 = UserBill::income('推荐代理分红', $sp['uid'], 'now_money', 'brokerage', $sp_money, $order['id'], $balance, $mark, 0);
+                        $res = $res && $res1;
+                    }
+                }
+                if ($every_money_virtual > 0) {
+                    $balance = bcadd($v['brokerage_price'], $every_money_virtual, 2);
+                    $mark = $userInfo['nickname'] . '成功消费[虚拟产品]' . floatval($order['pay_price']) . '元,区代理分红' . floatval($every_money_virtual);
+                    $res1 = UserBill::income('区代理分红', $v['uid'], 'now_money', 'brokerage', $every_money_virtual, $order['id'], $balance, $mark);
+                    $res2 = self::bcInc($v['uid'], 'brokerage_price', $every_money_virtual, 'uid');
+                    $res = $res && $res1 && $res2;
+                    $sp_money = bcmul($every_money_virtual, bcdiv($area_recommend_ratio, 100, 4), 2);
+                    if ($v['spread_uid'] && $sp_money > 0) {
+                        $sp = User::where('uid', $v['spread_uid'])->find();
+                        $balance = bcadd($sp['brokerage_price'], $sp_money, 2);
+                        $mark = $userInfo['nickname'] . '成功消费[虚拟产品]' . floatval($order['pay_price']) . '元,推荐代理分红' . floatval($sp_money);
+                        $res1 = UserBill::income('推荐代理分红', $sp['uid'], 'now_money', 'brokerage', $sp_money, $order['id'], $balance, $mark, 0);
+                        $res2 = self::bcInc($sp['uid'], 'brokerage_price', $sp_money, 'uid');
+                        $res = $res && $res1 && $res2;
+                    }
+                }
+            }
+        }
+        $city = User::where('area_admin', 2)->where('area_province', $order['province'])->where('area_city', $order['city'])->select();
+        if (count($city) > 0) {
+            $money_real = bcmul(bcdiv($city_admin_ratio, 100, 4), $realPrice, 2);
+            $money_virtual = bcmul(bcdiv($city_admin_ratio, 100, 4), $virtualPrice, 2);
+            $every_money_real = bcdiv($money_real, count($city), 2);
+            $every_money_virtual = bcdiv($money_virtual, count($city), 2);
+            if ($every_money_real <= 0 && $every_money_virtual <= 0) return true;
+            $res = true;
+            foreach ($city as $v) {
+                if ($every_money_real > 0) {
+                    $balance = bcadd($v['brokerage_price'], $every_money_real, 2);
+                    $mark = $userInfo['nickname'] . '成功消费[实物产品]' . floatval($order['pay_price']) . '元,市代理分红' . floatval($every_money_real);
+                    $res1 = UserBill::income('市代理分红', $v['uid'], 'now_money', 'brokerage', $every_money_real, $order['id'], $balance, $mark, 0);
+                    $res = $res && $res1;
+                    $sp_money = bcmul($every_money_real, bcdiv($area_recommend_ratio, 100, 4), 2);
+                    if ($v['spread_uid'] && $sp_money > 0) {
+                        $sp = User::where('uid', $v['spread_uid'])->find();
+                        $balance = bcadd($sp['brokerage_price'], $sp_money, 2);
+                        $mark = $userInfo['nickname'] . '成功消费[实物产品]' . floatval($order['pay_price']) . '元,推荐代理分红' . floatval($sp_money);
+                        $res1 = UserBill::income('推荐代理分红', $sp['uid'], 'now_money', 'brokerage', $sp_money, $order['id'], $balance, $mark, 0);
+                        $res = $res && $res1;
+                    }
+                }
+                if ($every_money_virtual > 0) {
+                    $balance = bcadd($v['brokerage_price'], $every_money_virtual, 2);
+                    $mark = $userInfo['nickname'] . '成功消费[虚拟产品]' . floatval($order['pay_price']) . '元,市代理分红' . floatval($every_money_virtual);
+                    $res1 = UserBill::income('市代理分红', $v['uid'], 'now_money', 'brokerage', $every_money_virtual, $order['id'], $balance, $mark);
+                    $res2 = self::bcInc($v['uid'], 'brokerage_price', $every_money_virtual, 'uid');
+                    $res = $res && $res1 && $res2;
+                    $sp_money = bcmul($every_money_virtual, bcdiv($area_recommend_ratio, 100, 4), 2);
+                    if ($v['spread_uid'] && $sp_money > 0) {
+                        $sp = User::where('uid', $v['spread_uid'])->find();
+                        $balance = bcadd($sp['brokerage_price'], $sp_money, 2);
+                        $mark = $userInfo['nickname'] . '成功消费[虚拟产品]' . floatval($order['pay_price']) . '元,推荐代理分红' . floatval($sp_money);
+                        $res1 = UserBill::income('推荐代理分红', $sp['uid'], 'now_money', 'brokerage', $sp_money, $order['id'], $balance, $mark, 0);
+                        $res2 = self::bcInc($sp['uid'], 'brokerage_price', $sp_money, 'uid');
+                        $res = $res && $res1 && $res2;
+                    }
+                }
+            }
+        }
+        $province = User::where('area_admin', 3)->where('area_province', $order['province'])->select();
+        if (count($province) > 0) {
+            $money_real = bcmul(bcdiv($province_admin_ratio, 100, 4), $realPrice, 2);
+            $money_virtual = bcmul(bcdiv($province_admin_ratio, 100, 4), $virtualPrice, 2);
+            $every_money_real = bcdiv($money_real, count($province), 2);
+            $every_money_virtual = bcdiv($money_virtual, count($province), 2);
+            if ($every_money_real <= 0 && $every_money_virtual <= 0) return true;
+            $res = true;
+            foreach ($province as $v) {
+                if ($every_money_real > 0) {
+                    $balance = bcadd($v['brokerage_price'], $every_money_real, 2);
+                    $mark = $userInfo['nickname'] . '成功消费[实物产品]' . floatval($order['pay_price']) . '元,省代理分红' . floatval($every_money_real);
+                    $res1 = UserBill::income('省代理分红', $v['uid'], 'now_money', 'brokerage', $every_money_real, $order['id'], $balance, $mark, 0);
+                    $res = $res && $res1;
+                    $sp_money = bcmul($every_money_real, bcdiv($area_recommend_ratio, 100, 4), 2);
+                    if ($v['spread_uid'] && $sp_money > 0) {
+                        $sp = User::where('uid', $v['spread_uid'])->find();
+                        $balance = bcadd($sp['brokerage_price'], $sp_money, 2);
+                        $mark = $userInfo['nickname'] . '成功消费[实物产品]' . floatval($order['pay_price']) . '元,推荐代理分红' . floatval($sp_money);
+                        $res1 = UserBill::income('推荐代理分红', $sp['uid'], 'now_money', 'brokerage', $sp_money, $order['id'], $balance, $mark, 0);
+                        $res = $res && $res1;
+                    }
+                }
+                if ($every_money_virtual > 0) {
+                    $balance = bcadd($v['brokerage_price'], $every_money_virtual, 2);
+                    $mark = $userInfo['nickname'] . '成功消费[虚拟产品]' . floatval($order['pay_price']) . '元,省代理分红' . floatval($every_money_virtual);
+                    $res1 = UserBill::income('省代理分红', $v['uid'], 'now_money', 'brokerage', $every_money_virtual, $order['id'], $balance, $mark);
+                    $res2 = self::bcInc($v['uid'], 'brokerage_price', $every_money_virtual, 'uid');
+                    $res = $res && $res1 && $res2;
+                    $sp_money = bcmul($every_money_virtual, bcdiv($area_recommend_ratio, 100, 4), 2);
+                    if ($v['spread_uid'] && $sp_money > 0) {
+                        $sp = User::where('uid', $v['spread_uid'])->find();
+                        $balance = bcadd($sp['brokerage_price'], $sp_money, 2);
+                        $mark = $userInfo['nickname'] . '成功消费[虚拟产品]' . floatval($order['pay_price']) . '元,推荐代理分红' . floatval($sp_money);
+                        $res1 = UserBill::income('推荐代理分红', $sp['uid'], 'now_money', 'brokerage', $sp_money, $order['id'], $balance, $mark, 0);
+                        $res2 = self::bcInc($sp['uid'], 'brokerage_price', $sp_money, 'uid');
+                        $res = $res && $res1 && $res2;
+                    }
+                }
+            }
+        }
+        return $res;
+    }
 
     /*
      * 线下支付消息通知