zz 6 år sedan
förälder
incheckning
9724f26e92

+ 11 - 0
app/Modules/User/Models/UserDivisionProperty.php

@@ -0,0 +1,11 @@
+<?php
+
+namespace App\Modules\User\Models;
+
+use Illuminate\Database\Eloquent\Model;
+
+class UserDivisionProperty extends Model
+{
+    protected $table = 'user_division_property';
+    protected $fillable = ['uid','property','is_enable'];
+}

+ 40 - 0
app/Modules/User/Services/UserDivisionPropertyService.php

@@ -0,0 +1,40 @@
+<?php
+/**
+ * Created by PhpStorm.
+ * User: z-yang
+ * Date: 2019/3/22
+ * Time: 10:53
+ */
+
+namespace App\Modules\User\Services;
+
+use App\Modules\User\Models\UserDivisionProperty;
+use DB;
+
+class userDivisionPropertyService
+{
+    public static function getUserPropertyFromTable($uid){
+        return UserDivisionProperty::where('uid',$uid)->where('is_enable',1)->select('property','created_at')->first();
+    }
+
+    public static function getUserPropertyFromStats($uid){
+        $sql = "SELECT f.uid,f.subscribe_time,f.appid,(o.price) FROM force_subscribe_users f  LEFT JOIN orders o on f.uid = o.uid and  o.`status` = 'PAID' 
+and o.created_at>=f.subscribe_time and o.created_at <= DATE_ADD(f.subscribe_time,INTERVAL 3 day) where f.is_subscribed = 1 and f.uid = %s ";
+        $res = DB::select(sprintf($sql,$uid));
+        if(!$res){
+            return '';
+        }
+        $data = [];
+        foreach ($res as $value){
+            $data[] = ['subscribe_time'=>$value->subscribe_time,'appid'=>$value->appid,'price'=>$value->price];
+        }
+        if(!$data) return '';
+        $collection = collect($data);
+        $sort = $collection->groupBy('appid')->sortByDesc(function($item, $key){
+            return $item[0]['subscribe_time'];
+        });
+
+        print_r($sort->all());
+
+    }
+}