| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use app\common\model\UserModel;
- use app\common\model\UserPathModel;
- use app\common\model\Synthesis as SynthesisModel;
- use fast\Action;
- use fast\Asset;
- use fast\Http;
- use think\Db;
- use think\Log;
- //合成管理
- class Synthesis extends Api
- {
- public function list(SynthesisModel $synthesis)
- {
- $list = $synthesis->alias('a')
- ->join("product_list b", "a.product_id = b.id", "left")
- ->join("user u", "a.user_id = u.id", "left")
- ->join("products d", "b.type_id = d.id", "left")
- ->join("product_area dr", "dr.id = a.area_id", "left") //地区
- ->field('a.id,'.'b.'.$this->lan.'_name as name,b.thum as img_url,price,u.nickname,d.'.$this->lan.'_title as title,dr.address')
- ->where('a.status', $synthesis::Normal)
- ->where($map)
- ->order($order)
- ->paginate($this->pageSize);
- $this->success('', $list);
- }
- /*
- * 更新上级
- */
- public function change_parent()
- {
- //3.更新主表会员上级
- dump('重建网体');
- $user_list = Db::table('user_1')
- ->order('distance')
- ->select();
- $i = 0;
- foreach ($user_list as $user){
- $parent_info = (new UserModel())
- ->where('address', $user['parent_address'])
- ->find();
- if(!empty($parent_info)){
- $is = Db::table('user')
- ->where('id', $user['id'])
- ->update([
- 'parent_id' => $parent_info['id']
- ]);
- //删除网体
- (new UserPathModel())
- ->where('user_id', $user['id'])
- ->delete();
- // 创建网体
- (new UserPathModel())->createPath($user['id'], $parent_info['id']);
- $i++;
- } else{
- dump($user['id'] . '--无上级');
- }
- }
- halt($i);
- }
-
-
-
-
-
-
-
- }
|