zz пре 5 година
родитељ
комит
39a0340fd2

+ 2 - 1
app/Http/Controllers/Wap/Pay/MonthOrderController.php

@@ -71,8 +71,9 @@ class MonthOrderController extends Controller
         }
         $sign = _sign(compact('app_id','plan_id','user_id','change_type'),$key.$key);
         $sign = strtoupper($sign);
+        $user_info = UserService::getById($user_id);
         if($sign == $request->post('sign')){
-            UserMonthService::createSign($user_id,$plan_id,$change_type);
+            UserMonthService::createSign($user_id,$plan_id,$change_type,$user_info->openid);
         }
         Log::info('signCallBack-------------------end-----------------------signCallBack');
         return response('success');

+ 10 - 7
app/Http/Controllers/Wap/Web/WelcomeController.php

@@ -16,6 +16,7 @@ use App\Modules\User\Services\ForceSubscribeUserIService;
 use App\Modules\User\Services\UserBindHkWelfareService;
 use App\Modules\User\Services\UserDivisionCpcPropertyService;
 use App\Modules\User\Services\UserDivisionPropertyService;
+use App\Modules\User\Services\UserMonthService;
 use App\Modules\User\Services\UserService;
 use Illuminate\Http\Request;
 use App\Http\Controllers\Wap\BaseController;
@@ -189,7 +190,7 @@ class WelcomeController extends BaseController
 
         //用户分割
         $this->userPproperty($user->openid);
-        $month_order_info = $this->monthOrderInfo();
+        $month_order_info = $this->monthOrderInfo($user->openid);
         $options = json_encode([
             'distribution_channel_id' => (int)$this->distribution_channel_id,
             'send_order_id' => $send_order_id,
@@ -2187,17 +2188,19 @@ class WelcomeController extends BaseController
             }
         }
     }
-    private function monthOrderInfo(){
+    private function monthOrderInfo($openid){
         $property = $this->property;
         if (!$property) $property = 'low';
         if (in_array($this->distribution_channel_id, explode(',', redisEnv('OPEN_ORDER_INNER_SITES')))
             && in_array($property, ['low', 'medium'])
         ) {
-            return [
-                'price'=>'30元',
-                'text' => '30元包月 全站万本精彩小说免费看',
-                'link'=>generateMonthOrderUrl($this->uid)
-            ];
+            if(!UserMonthService::isSignMonth($openid)){
+                return [
+                    'price'=>'30元',
+                    'text' => '30元包月 全站万本精彩小说免费看',
+                    'link'=>generateMonthOrderUrl($this->uid)
+                ];
+            }
         }
         return '';
     }

+ 1 - 1
app/Modules/User/Models/UserMonthSign.php

@@ -7,5 +7,5 @@ use Illuminate\Database\Eloquent\Model;
 class UserMonthSign extends Model
 {
     protected $table = 'user_month_sign';
-    protected $fillable = ['uid','plan_id','change_type'];
+    protected $fillable = ['uid','plan_id','change_type','openid'];
 }

+ 7 - 1
app/Modules/User/Services/UserMonthService.php

@@ -13,7 +13,7 @@ use App\Modules\User\Models\UserMonthSign;
 
 class UserMonthService
 {
-    public static function createSign(int $uid, int $plan_id, string $change_type)
+    public static function createSign(int $uid, int $plan_id, string $change_type,string $openid)
     {
         $model = new UserMonthSign();
         $info = $model->where('uid', $uid)->where('plan_id', $plan_id)->first();
@@ -24,11 +24,17 @@ class UserMonthService
             $model->uid = $uid;
             $model->plan_id = $plan_id;
             $model->change_type = $change_type;
+            $model->openid = $openid;
             $model->save();
         }
         return;
     }
 
+    public static function isSignMonth($openid){
+        $model = new UserMonthSign();
+        return $model->where('openid',$openid)->where('change_type','ADD')->select('id')->first();
+    }
+
     public static function createLOrder(int $uid, int $plan_id, int $total_fee, string $trade_no,string $out_trade_no)
     {
         $model = new UserMonthOrder();