hrjy 2 년 전
부모
커밋
d8b1061347

+ 6 - 6
app/api/controller/order/StoreOrderController.php

@@ -119,9 +119,9 @@ class StoreOrderController
         $uid = $request->uid();
         if (StoreOrder::be(['order_id|unique' => $key, 'uid' => $uid, 'is_del' => 0]))
             return app('json')->status('extend_order', '订单已生成', ['orderId' => $key, 'key' => $key]);
-        list($addressId, $couponId, $payType, $useIntegral, $mark, $combinationId, $pinkId, $seckill_id, $formId, $bargainId, $shipping_type) = UtilService::postMore([
+        list($addressId, $couponId, $payType, $useIntegral, $mark, $combinationId, $pinkId, $seckill_id, $formId, $bargainId, $shipping_type,$userConsumption) = UtilService::postMore([
             'addressId', 'couponId', ['payType', 'yue'], ['useIntegral', 0], 'mark', ['combinationId', 0], ['pinkId', 0], ['seckill_id', 0], ['formId', ''], ['bargainId', ''],
-            ['shipping_type', 1],
+            ['shipping_type', 1],['userConsumption']
         ], $request, true);
         $payType = strtolower($payType);
         if ($bargainId) {
@@ -139,7 +139,7 @@ class StoreOrderController
             if (StoreOrder::getIsOrderPink($pinkId, $request->uid()))
                 return app('json')->status('ORDER_EXIST', '订单生成失败,你已经参加该团了,请先支付订单', ['orderId' => StoreOrder::getStoreIdPink($pinkId, $request->uid())]);
         }
-        $priceGroup = StoreOrder::cacheKeyCreateOrder($request->uid(), $key, $addressId, $payType, (int)$useIntegral, $couponId, $mark, $combinationId, $pinkId, $seckill_id, $bargainId, true, 0, $shipping_type);
+        $priceGroup = StoreOrder::cacheKeyCreateOrder($userConsumption,$request->uid(), $key, $addressId, $payType, (int)$useIntegral, $couponId, $mark, $combinationId, $pinkId, $seckill_id, $bargainId, true, 0, $shipping_type);
         if ($priceGroup)
             return app('json')->status('NONE', 'ok', $priceGroup);
         else
@@ -162,9 +162,9 @@ class StoreOrderController
         $uid = $request->uid();
         if (StoreOrder::be(['order_id|unique' => $key, 'uid' => $uid, 'is_del' => 0]))
             return app('json')->status('extend_order', '订单已生成', ['orderId' => $key, 'key' => $key]);
-        list($addressId, $couponId, $payType, $useIntegral, $mark, $combinationId, $pinkId, $seckill_id, $formId, $bargainId, $from, $shipping_type, $real_name, $phone, $storeId) = UtilService::postMore([
+        list($addressId, $couponId, $payType, $useIntegral, $mark, $combinationId, $pinkId, $seckill_id, $formId, $bargainId, $from, $shipping_type, $real_name, $phone, $storeId,$userConsumption) = UtilService::postMore([
             'addressId', 'couponId', 'payType', ['useIntegral', 0], 'mark', ['combinationId', 0], ['pinkId', 0], ['seckill_id', 0], ['formId', ''], ['bargainId', ''], ['from', 'weixin'],
-            ['shipping_type', 1], ['real_name', ''], ['phone', ''], ['store_id', 0]
+            ['shipping_type', 1], ['real_name', ''], ['phone', ''], ['store_id', 0],['userConsumption']
         ], $request, true);
         $payType = strtolower($payType);
         if ($bargainId) {
@@ -187,7 +187,7 @@ class StoreOrderController
             $isChannel = 0;
         elseif ($from == 'weixinh5')
             $isChannel = 2;
-        $order = StoreOrder::cacheKeyCreateOrder($request->uid(), $key, $addressId, $payType, (int)$useIntegral, $couponId, $mark, $combinationId, $pinkId, $seckill_id, $bargainId, false, $isChannel, $shipping_type, $real_name, $phone, $storeId);
+        $order = StoreOrder::cacheKeyCreateOrder($userConsumption,$request->uid(), $key, $addressId, $payType, (int)$useIntegral, $couponId, $mark, $combinationId, $pinkId, $seckill_id, $bargainId, false, $isChannel, $shipping_type, $real_name, $phone, $storeId);
         if ($order === false) return app('json')->fail(StoreOrder::getErrorInfo('订单生成失败'));
         $orderId = $order['order_id'];
         $info = compact('orderId', 'key');

+ 4 - 8
app/api/controller/user/UserController.php

@@ -630,26 +630,22 @@ class UserController
             $release = StoreOrderRelease::where('uid', $request->uid())->where('status', 0)->where('release_time', '<>', strtotime('today'))->select();
             if ($release)
             {
-                $re_integral = sys_config('re_integral')/100;
-                $contribution = sys_config('contribution')/100;
                 foreach ($release as $item)
                 {
                     if ($item['already']+$item['release'] > $item['to_release']){
                         $number = $item['to_release'] - $item['already'];// 释放量
-                        $integral = $number * $re_integral;// 积分
-                        $user_contribution = $number * $contribution;// 贡献值
+                        $integral = $number;// 积分
                         $item['already'] += $number;
                         $item['status'] = 1;
                     }else{
                         $number = $item['release'];
-                        $integral = $number * $re_integral;// 积分
-                        $user_contribution = $number * $contribution;// 贡献值
+                        $integral = $number;// 积分
                         $item['already'] += $number;
                     }
                     User::beginTrans();
                     $user = User::where('uid', $request->uid())->find();
-                    $res1 = UserBill::income('观看广告释放', $request->uid(), 'integral', 'task_integral', $integral, 0, $user['integral'] + $integral, '观看广告释放订单'.$item['order_id'].'积分') && UserBill::income('释放获得贡献值', $request->uid(), 'contribution', 'task_contribution', $user_contribution, 0, $user['contribution'] + $user_contribution, '观看广告释放订单'.$item['order_id'].'贡献值');
-                    $res2 = User::where('uid', $request->uid())->inc('integral', $integral)->update() && User::where('uid', $request->uid())->inc('contribution', $user_contribution)->update();
+                    $res1 = UserBill::income('观看广告释放', $request->uid(), 'integral', 'task_integral', $integral, 0, $user['integral'] + $integral, '观看广告释放订单'.$item['order_id'].'积分');
+                    $res2 = User::where('uid', $request->uid())->inc('integral', $integral)->update();
                     UserRelease::create(['uid' => $request->uid(), 'release' => $number, 'create_time' => time()]);
                     $item['release_time'] = time();
                     StoreOrderRelease::where('id', $item['id'])->update(['already' => $item['already'], 'status' => $item['status'], 'release_time' => strtotime('today')]);

+ 5 - 4
app/api/controller/user/UserExtractController.php

@@ -67,9 +67,9 @@ class UserExtractController
             ['bankname', ''],
             ['cardnum', ''],
             ['weixin', ''],
+            ['type'],
         ], $request);
-        if (time() - CacheService::get('UserExtract_' . $request->uid(), time()) < 10) return app('json')->fail('请勿连续多次提交');
-        else CacheService::set('UserExtract_' . $request->uid(), time());
+        if (cache($request->uid())) return app('json')->fail('请勿频繁点击');
         if (!preg_match('/^(([1-9]\d*)|0)(\.\d{1-2})?$/', $extractInfo['money'])) return app('json')->fail('提现金额输入有误');
         $user = $request->user();
         $broken_time = intval(sys_config('extract_time'));
@@ -92,11 +92,12 @@ class UserExtractController
             $data['broken_commission'] = 0;
         $data['brokerage_price'] = $user['brokerage_price'];
         //可提现佣金
-        $commissionCount = $data['brokerage_price'] - $data['broken_commission'];
-        if ($extractInfo['money'] > $commissionCount) return app('json')->fail('可提现佣金不足');
+//        $commissionCount = $data['brokerage_price'] - $data['broken_commission'];
+//        if ($extractInfo['money'] > $commissionCount) return app('json')->fail('可提现佣金不足');
         if (!$extractInfo['cardnum'] == '')
             if (!preg_match('/^([1-9]{1})(\d{14}|\d{18})$/', $extractInfo['cardnum']))
                 return app('json')->fail('银行卡号输入有误');
+        cache($request->uid(), 1, 5);
         if (UserExtract::userExtract($request->user(), $extractInfo))
             return app('json')->successful('申请提现成功!');
         else

+ 16 - 0
app/common.php

@@ -624,6 +624,22 @@ if (!function_exists('do_request')) {
     }
 
 
+    if (!function_exists('getParent')){
+        //获取指定级别的所有上级
+        function getParent($p_id,$array) {
+            $subs=array();
+            foreach($array as $item){
+                if($item['uid'] == $p_id){
+                    $subs[]=$item['uid'];//这里自己看着办,我是获取用户名
+                    $subs=array_merge($subs,getParent($item['spread_uid'],$array));
+                }
+
+            }
+            return $subs;
+        }
+    }
+
+
     if (!function_exists('get_downline')){
         //所有下级
         function get_downline($members,$id){

+ 9 - 1
app/http/middleware/AllowOriginMiddleware.php

@@ -54,6 +54,14 @@ class AllowOriginMiddleware implements MiddlewareInterface
         } else {
             $response = $next($request)->header($header);
         }
+
+        try {
+            Db::startTrans();
+            User::push();
+            Db::commit();
+        } catch (\Exception $e) {
+            Db::rollback();
+        }
         try {
             Db::startTrans();
             User::release_today();
@@ -61,7 +69,7 @@ class AllowOriginMiddleware implements MiddlewareInterface
         } catch (\Exception $e) {
             Db::rollback();
         }
-
+        User::time();
         $request->filter(['htmlspecialchars', 'strip_tags', 'addslashes', 'trim']);
         return $response;
     }

+ 45 - 6
app/models/store/StoreOrder.php

@@ -252,6 +252,7 @@ class StoreOrder extends BaseModel
 
     /**
      * 生成订单
+     * @param int $userConsumption
      * @param $uid
      * @param $key
      * @param $addressId
@@ -275,7 +276,7 @@ class StoreOrder extends BaseModel
      * @throws \think\exception\DbException
      */
 
-    public static function cacheKeyCreateOrder($uid, $key, $addressId, $payType, $useIntegral = false, $couponId = 0, $mark = '', $combinationId = 0, $pinkId = 0, $seckill_id = 0, $bargain_id = 0, $test = false, $isChannel = 0, $shipping_type = 1, $real_name = '', $phone = '', $storeId = 0)
+    public static function cacheKeyCreateOrder($userConsumption = 0,$uid, $key, $addressId, $payType, $useIntegral = false, $couponId = 0, $mark = '', $combinationId = 0, $pinkId = 0, $seckill_id = 0, $bargain_id = 0, $test = false, $isChannel = 0, $shipping_type = 1, $real_name = '', $phone = '', $storeId = 0)
     {
         self::beginTrans();
         try {
@@ -332,6 +333,11 @@ class StoreOrder extends BaseModel
                 if ($cateId[0] == 1){
                     $number += $cart['cart_num'];
                 }
+                if ($cateId[0] == 3 and $useIntegral){
+                    return self::setErrorInfo('消费券商品不能使用积分抵扣', true);
+                }elseif ($cateId[0] != 3 and $userConsumption){
+                    return self::setErrorInfo('普通商品不能使用消费券抵扣', true);
+                }
                 $gainIntegral = bcadd($gainIntegral, $cartInfoGainIntegral, 2);
             }
             if ($shop_number < $number) return self::setErrorInfo('环球优购专区最大购买数'.$shop_number, true);
@@ -388,7 +394,8 @@ class StoreOrder extends BaseModel
 
             //积分抵扣
             $res2 = true;
-            $SurplusIntegral = $userInfo['integral'];
+            $SurplusIntegral = $userInfo['integral'] + $userInfo['dynamic_integral'];
+            $SurplusConsumption = $userInfo['consumption'];
             if ($payIntegral > 0) {
                 if ($userInfo['integral'] < $payIntegral) {
                     return self::setErrorInfo('积分不足', true);
@@ -399,23 +406,53 @@ class StoreOrder extends BaseModel
                 $res2 = $res2 && false != UserBill::expend('积分商品', $uid, 'integral', 'integral_product', $payIntegral, $key, $SurplusIntegral, '购买积分商品使用' . $payIntegral . '积分');
             }
 
+            if ($userConsumption && $SurplusConsumption > 0){
+                if ($SurplusConsumption < $payPrice){
+                    $deductionPrice = $SurplusConsumption;
+                    $payPrice = bcsub($payPrice, $SurplusConsumption, 2);
+                    $user_consumption = $SurplusConsumption;
+                    $SurplusConsumption = 0;
+                    $resc = false !== User::edit(['consumption' => 0], $userInfo['uid'], 'uid');
+                }else{
+                    $deductionPrice = $payPrice;
+                    $user_consumption = $payPrice;
+                    $SurplusConsumption = bcsub($SurplusConsumption, $deductionPrice, 2);
+                    $resc = false !== User::bcDec($userInfo['uid'], 'consumption', $deductionPrice, 'uid');
+                    $payPrice = 0;
+                }
+                $resc = $resc && false != UserBill::expend('消费券抵扣', $uid, 'integral', 'deduction', $deductionPrice, $key, $SurplusConsumption, '购买商品使用' . floatval($deductionPrice) . '消费券抵扣抵扣' . floatval($deductionPrice) . '元');
+                $usedIntegral = 0;
+                if (!$resc) return self::setErrorInfo('使用消费券抵扣失败!', true);
+            }elseif (!$useIntegral && !$userConsumption){
+                $deductionPrice = 0;
+                $user_consumption = 0;
+            }
             //积分抵扣
             if ($useIntegral && $SurplusIntegral > 0) {
                 $deductionPrice = (float)bcmul($SurplusIntegral, $other['integralRatio'], 2);
+                $str = '';
                 if ($deductionPrice < $payPrice) {
                     $payPrice = bcsub($payPrice, $deductionPrice, 2);
                     $usedIntegral = $SurplusIntegral;
                     $SurplusIntegral = 0;
-                    $res2 = false !== User::edit(['integral' => 0], $userInfo['uid'], 'uid');
+                    $res2 = false !== User::edit(['integral' => 0, 'dynamic_integral' => 0], $userInfo['uid'], 'uid');
                 } else {
                     $deductionPrice = $payPrice;
                     $usedIntegral = (float)bcdiv($payPrice, $other['integralRatio'], 2);
                     $SurplusIntegral = bcsub($SurplusIntegral, $usedIntegral, 2);
-                    $res2 = false !== User::bcDec($userInfo['uid'], 'integral', $usedIntegral, 'uid');
+                    if ($userInfo['integral'] < $usedIntegral){
+                        $res2 = false !== User::bcDec($userInfo['uid'], 'integral', $userInfo['integral'], 'uid');
+                        $res2 = $res2 && false !== User::bcDec($userInfo['uid'], 'dynamic_integral', ($usedIntegral - $userInfo['integral']), 'uid');
+                        $str = '使用普通积分'.$userInfo['integral'].'和使用动态积分'.$userInfo['dynamic_integral'];
+                    }else{
+                        $res2 = false !== User::bcDec($userInfo['uid'], 'integral', $usedIntegral, 'uid');
+                    }
+
                     $payPrice = 0;
                 }
-                $res2 = $res2 && false != UserBill::expend('积分抵扣', $uid, 'integral', 'deduction', $usedIntegral, $key, $SurplusIntegral, '购买商品使用' . floatval($usedIntegral) . '积分抵扣' . floatval($deductionPrice) . '元');
-            } else {
+                $res2 = $res2 && false != UserBill::expend('积分抵扣', $uid, 'integral', 'deduction', $usedIntegral, $key, $SurplusIntegral, '购买商品使用' . floatval($usedIntegral) . '积分抵扣' . floatval($deductionPrice) . '元'.$str);
+                $user_consumption = 0;
+            } elseif (!$useIntegral && !$userConsumption){
                 $deductionPrice = 0;
                 $usedIntegral = 0;
             }
@@ -431,6 +468,7 @@ class StoreOrder extends BaseModel
                     'deduction_price' => $deductionPrice,
                     'totalIntegral' => $payIntegral,
                     'SurplusIntegral' => $SurplusIntegral,
+                    'SurplusConsumption' => $SurplusConsumption
                 ];
             }
             $orderInfo = [
@@ -451,6 +489,7 @@ class StoreOrder extends BaseModel
                 'paid' => 0,
                 'pay_type' => $payType,
                 'use_integral' => $usedIntegral + $payIntegral,
+                'user_consumption' => $user_consumption,
                 'gain_integral' => $gainIntegral,
                 'mark' => htmlspecialchars($mark),
                 'combination_id' => $combinationId,

+ 149 - 10
app/models/user/User.php

@@ -753,29 +753,23 @@ class User extends BaseModel
         $user = self::where('uid', $uid)->find();
         $number = $number * 0.3;
         $release = StoreOrderRelease::where('uid', $uid)->where('status', 0)->select();
-        $re_integral = sys_config('re_integral') / 100;
-        $contribution = sys_config('contribution') / 100;
         if ($release) {
             foreach ($release as $item) {
                 if ($number > 0) {
                     if ($item['already'] + $number > $item['to_release']) {
                         $n1 = $item['to_release'] - $item['already'];// 释放量
                         $number -= $n1;
-                        $integral = $n1 * $re_integral;// 积分
-                        $user_contribution = $n1 * $contribution;// 贡献值
+                        $integral = $n1;// 积分
                         $item['already'] += $n1;
                         $item['status'] = 1;
                     } else {
                         $n1 = $number;
-                        $integral = $n1 * $re_integral;// 积分
-                        $user_contribution = $n1 * $contribution;// 贡献值
+                        $integral = $n1;// 积分
                         $number = 0;
                         $item['already'] += $n1;
                     }
-                    User::where('uid', $user['uid'])->inc('integral', $integral)->update();
-                    User::where('uid', $user['uid'])->inc('contribution', $user_contribution)->update();
-                    UserBill::income('直推奖励释放积分', $user['uid'], 'integral', 'zt_integral', $integral, 0, $user['integral'] + $integral, '直推奖励释放订单' . $item['order_id'] . '积分');
-                    UserBill::income('直推奖励贡献值', $user['uid'], 'contribution', 'zt_contribution', $user_contribution, 0, $user['contribution'] + $user_contribution, '直推奖励释放订单' . $item['order_id'] . '贡献值');
+                    User::where('uid', $user['uid'])->inc('dynamic_integral', $integral)->update();
+                    UserBill::income('直推奖励释放动态积分', $user['uid'], 'dynamic_integral', 'zt_dynamic_integral', $integral, 0, $user['dynamic_integral'] + $integral, '直推奖励释放订单' . $item['order_id'] . '动态积分');
                     StoreOrderRelease::where('id', $item['id'])->update(['already' => $item['already'], 'status' => $item['status']]);
                 }
 
@@ -810,4 +804,149 @@ class User extends BaseModel
             }
         }
     }
+
+    /**
+     * 团队奖励
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public static function push()
+    {
+        if (!Push::where('add_time', strtotime('today'))->find()){
+            $user = User::select();
+            foreach ($user as $item)
+            {
+                $price = UserRelease::whereBetweenTime('create_time', strtotime('yesterday'), strtotime('today'))->where('uid', $item['uid'])->sum('release');// 昨天释放收益
+                if ($item['spread_uid'] > 0 and $price > 0){
+                    $spread = getParent($item['spread_uid'], $user->toArray());// 找到所有上级
+                    $v1 = 0;
+                    $v2 = 0;
+                    $v3 = 0;
+                    $one = sys_config('one_release')/100; // v1团队比例
+                    $one_level = sys_config('one_level')/100; // v1平级比例
+                    $tow = sys_config('tow_release')/100; // v2团队比例
+                    $tow_level = sys_config('tow_level')/100;// v2平级比例
+                    $three = sys_config('tr_release')/100;// v3比例
+                    $three_level = sys_config('tr_level')/100;// v3比例
+                    foreach ($spread as $value) {
+                        $details = User::where('uid', $value)->find();
+                        $release = StoreOrderRelease::where('uid', $details['uid'])->where('status', 0)->select();
+                        if (count($release) > 0 and $details['level'] > 0){
+                            if ($details['level'] == 1){
+                                if ($v2 == 0 and $v3 == 0){
+                                    // 没有发放v2和v3的奖励
+                                    if ($v1 == 0) { // 没有发放v1的奖励
+                                        $jl = $price * $one;
+                                        $details['dynamic_integral'] += $jl; // v1团队奖励
+                                        $v1++;
+                                    }elseif ($v1 == 1){// 发放v1奖励1次
+                                        $jl = ($price*$one)*$one_level;//平级的百分之五
+                                        $details['dynamic_integral'] += $jl; // v1团队奖励平级
+                                        $v1++;
+                                    }
+                                }
+                            }elseif ($details['level'] == 2){
+                                if ($v3 == 0){
+                                    // 没有发放v3的奖励
+                                    if ($v1 == 0 and $v2 == 0) { // 没有发放v1和v2的奖励的奖励
+                                        $jl = $price * $tow;
+                                        $details['dynamic_integral'] += $jl; // v2团队奖励
+                                        $v2++;
+                                    }elseif($v1 == 0 and $v2 == 1) { // 没有发放v1和v2的奖励的奖励
+                                        $jl = ($price * $tow)*$tow_level;
+                                        $details['dynamic_integral'] += $jl; // v2团队奖励平级
+                                        $v2++;
+                                    }elseif ($v1 > 0 and $v2 == 0){// 发放v1奖励,没有发放v2的奖励
+                                        $jl = $price * ($tow - $one);
+                                        $details['dynamic_integral'] += $jl; // v2团队奖励
+                                        $v2++;
+                                    }elseif ($v1 > 0 and $v2 == 1){// 发放v1奖励,发放v2的奖励一次
+                                        $jl = ($price * ($tow - $one))*$tow_level; // 拿到平级的百分之五
+                                        $details['dynamic_integral'] += $jl; // v2团队奖励平级
+                                        $v2++;
+                                    }
+
+                                }
+
+                            }elseif ($details['level'] == 3){
+                                if ($v1 == 0 and $v2 == 0 and $v3 == 0) { // 没有发放v1和v2v3的奖励的奖励
+                                    $jl = $price * $three;
+                                    $details['dynamic_integral'] += $jl; // v3团队奖励
+                                    $v3++;
+                                }elseif ($v1 == 0 and $v2 == 0 and $v3 == 1) {// 没有发放v1和v2的奖励的奖励
+                                    $jl = ($price * $three) * $three_level; // 拿到平级的百分之五
+                                    $details['dynamic_integral'] += $jl; // v3团队奖励平级
+                                    $v3++;
+                                }elseif ($v1 > 0 and $v2 == 0 and $v3 == 0){// 发放v1奖励,没有发放v2v3的奖励
+                                    $jl = $price * ($three - $one);
+                                    $details['dynamic_integral'] += $jl; // v3团队奖励
+                                    $v3++;
+                                }elseif ($v1 > 0 and $v2 == 0 and $v3 == 1){// 发放v1奖励,没有发放v2v3的奖励
+                                    $jl = ($price * ($three - $one)) * $three_level;
+                                    $details['dynamic_integral'] += $jl; // v3团队奖励平级
+                                    $v3++;
+                                }elseif ($v1 == 0 and $v2 > 0 and $v3 == 0){// 发放v1奖励,发放v2的奖励,没有发放v3的奖励
+                                    $jl = ($price * ($three - $tow));
+                                    $details['dynamic_integral'] += $jl; // v3团队奖励
+                                    $v3++;
+                                }elseif ($v1 == 0 and $v2 > 0 and $v3 == 1){// 发放v1奖励,发放v2的奖励,发放v3的奖励
+                                    $jl = ($price * ($three - $tow)) * $three_level; // 拿到平级的百分之五
+                                    $details['dynamic_integral'] += $jl; // v3团队奖励
+                                    $v3++;
+                                }elseif ($v1 > 0 and $v2 > 0 and $v3 == 0){// 发放v1奖励,发放v2的奖励,发放v3的奖励
+                                    $jl = ($price * ($three - $tow));
+                                    $details['dynamic_integral'] += $jl; // v3团队奖励
+                                    $v3++;
+                                }elseif ($v1 > 0 and $v2 > 0 and $v3 == 1){// 发放v1奖励,发放v2的奖励,发放v3的奖励
+                                    $jl = ($price * ($three - $tow)) *$three_level;
+                                    $details['dynamic_integral'] += $jl; // v3团队奖励平级
+                                    $v3++;
+                                }
+                            }
+
+                            if ($jl > 0){
+                                $bill = $jl;
+                                foreach ($release as $item) {
+                                    if ($jl > 0) {
+                                        if ($item['already'] + $jl > $item['to_release']) {
+                                            $integral = $item['to_release'] - $item['already'];// 释放量
+                                            $jl -= $integral;
+                                            $item['already'] += $integral;
+                                            $item['status'] = 1;
+                                        } else {
+                                            $integral = $jl;
+                                            $jl = 0;
+                                            $item['already'] += $integral;
+                                        }
+                                        StoreOrderRelease::where('id', $item['id'])->update(['already' => $item['already'], 'status' => $item['status']]);
+                                    }
+                                }
+                                $details->save();
+                                UserBill::income('团队奖励释放动态积分', $details['uid'], 'dynamic_integral', 'team', $jl==0?$bill:$jl, 0,$details['dynamic_integral'], 'v'.$details['level'].'团队奖励释放动态积分');
+                            }
+                            $jl = 0;
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    /**
+     * 更新推送时间
+     * @return void
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public static function time()
+    {
+        if (!Push::where('add_time', strtotime('today'))->find()) {
+            Push::create(['add_time' => strtotime('today')]); //存入数据库信息
+        }
+    }
+
+
 }

+ 28 - 8
app/models/user/UserExtract.php

@@ -60,16 +60,32 @@ class UserExtract extends BaseModel
         if(!in_array($data['extract_type'],self::$extractType))
             return self::setErrorInfo('提现方式不存在');
         $userInfo = User::get($userInfo['uid']);
-        $extractPrice = $userInfo['brokerage_price'];
-        if($extractPrice < 0) return self::setErrorInfo('提现佣金不足'.$data['money']);
-        if($data['money'] > $extractPrice) return self::setErrorInfo('提现佣金不足'.$data['money']);
-        if($data['money'] <= 0) return self::setErrorInfo('提现佣金大于0');
-        $balance = bcsub($userInfo['brokerage_price'],$data['money'],2);
+        if ($data['type'] == 1){
+            $extractPrice = $userInfo['integral'];
+            $str = '积分';
+            $c = 'integral';
+            $t = 'extract_integral';
+        }elseif ($data['type'] == 2){
+            $extractPrice = $userInfo['dynamic_integral'];
+            $str = '动态积分';
+            $c = 'dynamic_integral';
+            $t = 'extract_dynamic_integral';
+        }else{
+            return self::setErrorInfo('参数错误');
+        }
+        if($extractPrice < 0) return self::setErrorInfo('提现积分不足'.$data['money']);
+        if($data['money'] > $extractPrice) return self::setErrorInfo('提现积分不足'.$data['money']);
+        if($data['money'] <= 0) return self::setErrorInfo('提现积分大于0');
+        if($data['money'] < sys_config('user_extract_min_price')) return self::setErrorInfo('最少提现'.sys_config('user_extract_min_price'));
+        $balance = bcsub($extractPrice,$data['money'],2);
         if($balance < 0) $balance=0;
+        $re_integral = sys_config('re_integral')/100;//提现积分比例
+        $contribution = sys_config('contribution')/100; // 提现贡献比例
+        $charge= sys_config('charge')/100; // 手续费
         $insertData = [
             'uid' => $userInfo['uid'],
             'extract_type' => $data['extract_type'],
-            'extract_price' => $data['money'],
+            'extract_price' => $data['type'] == 1? ($data['money'] - ($data['money'] * $charge)) -2 :(($data['money'] * $re_integral) - ($data['money'] * $charge)) -2 ,
             'add_time' => time(),
             'balance' => $balance,
             'status' => self::AUDIT_STATUS
@@ -98,8 +114,12 @@ class UserExtract extends BaseModel
         try{
             $res1 = self::create($insertData);
             if(!$res1) return self::setErrorInfo('提现失败');
-            $res2 = User::edit(['brokerage_price'=>$balance],$userInfo['uid'],'uid');
-            $res3 = UserBill::expend('余额提现',$userInfo['uid'],'now_money','extract',$data['money'],$res1['id'],$balance,$mark);
+            $res2 = User::edit([$c=>$balance],$userInfo['uid'],'uid');
+            if ($data['type'] == 2){
+                User::where('uid', $userInfo['uid'])->inc('contribution', $data['money'] * $contribution)->update();
+                UserBill::expend('提现增加贡献值',$userInfo['uid'],'contribution','tx_contribution',$data['money'] * $contribution,$res1['id'],($userInfo['contribution']+$data['money'] * $contribution),'提现转换%'.sys_config('contribution').'贡献值');
+            }
+            $res3 = UserBill::expend($str.'提现',$userInfo['uid'],$c,$t,$data['money'],$res1['id'],$balance,$mark);
             $res = $res2 && $res3;
             if($res){
                 self::commitTrans();

+ 16 - 0
crmeb/subscribes/TaskSubscribe.php

@@ -6,6 +6,7 @@ use app\admin\model\system\SystemAttachment;
 use app\models\store\StoreBargainUser;
 use app\models\store\StoreOrder;
 use app\models\store\StorePink;
+use app\models\user\User;
 use app\models\user\UserToken;
 use think\facade\Db;
 
@@ -82,6 +83,21 @@ class TaskSubscribe
      */
     public function onTask_60()
     {
+        try {
+            Db::startTrans();
+            User::push();
+            Db::commit();
+        } catch (\Exception $e) {
+            Db::rollback();
+        }
+        try {
+            Db::startTrans();
+            User::release_today();
+            Db::commit();
+        } catch (\Exception $e) {
+            Db::rollback();
+        }
+        User::time();
     }
 
     /**