Your Name 4 years ago
parent
commit
3d61343554

+ 7
- 0
src/main/java/com/shigongli/controller/TaPersonController.java View File

6
 import com.baomidou.mybatisplus.core.metadata.IPage;
6
 import com.baomidou.mybatisplus.core.metadata.IPage;
7
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
7
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
8
 import com.shigongli.common.*;
8
 import com.shigongli.common.*;
9
+import com.shigongli.service.ITaShopKeeperService;
9
 import com.shigongli.vo.AuthPhoneParams;
10
 import com.shigongli.vo.AuthPhoneParams;
10
 import io.swagger.annotations.Api;
11
 import io.swagger.annotations.Api;
11
 import io.swagger.annotations.ApiOperation;
12
 import io.swagger.annotations.ApiOperation;
41
     @Autowired
42
     @Autowired
42
     public ITaPersonService iTaPersonService;
43
     public ITaPersonService iTaPersonService;
43
 
44
 
45
+    @Autowired
46
+    private ITaShopKeeperService iTaShopKeeperService;
47
+
44
     @Autowired
48
     @Autowired
45
     private WxUtils wxUtils;
49
     private WxUtils wxUtils;
46
 
50
 
63
         taPerson.setPhone(phone);
67
         taPerson.setPhone(phone);
64
         iTaPersonService.updateById(taPerson);
68
         iTaPersonService.updateById(taPerson);
65
 
69
 
70
+        // 绑定店主
71
+        iTaShopKeeperService.bindPerson(taPerson);
72
+
66
         return ResponseBean.success(taPerson);
73
         return ResponseBean.success(taPerson);
67
     }
74
     }
68
 
75
 

+ 15
- 0
src/main/java/com/shigongli/controller/TaShopKeeperController.java View File

6
 import com.shigongli.common.BaseController;
6
 import com.shigongli.common.BaseController;
7
 import com.shigongli.common.ResponseBean;
7
 import com.shigongli.common.ResponseBean;
8
 import com.shigongli.constants.StatusConstant;
8
 import com.shigongli.constants.StatusConstant;
9
+import com.shigongli.entity.TaPerson;
10
+import com.shigongli.service.ITaPersonService;
9
 import io.swagger.annotations.Api;
11
 import io.swagger.annotations.Api;
10
 import io.swagger.annotations.ApiOperation;
12
 import io.swagger.annotations.ApiOperation;
11
 import io.swagger.annotations.ApiParam;
13
 import io.swagger.annotations.ApiParam;
40
     @Autowired
42
     @Autowired
41
     public ITaShopKeeperService iTaShopKeeperService;
43
     public ITaShopKeeperService iTaShopKeeperService;
42
 
44
 
45
+    @Autowired
46
+    public ITaPersonService iTaPersonService;
47
+
43
 
48
 
44
     /**
49
     /**
45
      * 分页查询列表
50
      * 分页查询列表
72
     @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
77
     @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
73
     public ResponseBean taShopKeeperAdd(@ApiParam("保存内容") @RequestBody TaShopKeeper taShopKeeper) throws Exception{
78
     public ResponseBean taShopKeeperAdd(@ApiParam("保存内容") @RequestBody TaShopKeeper taShopKeeper) throws Exception{
74
 
79
 
80
+        TaPerson taPerson = iTaPersonService.getByPhone(taShopKeeper.getPhone());
81
+        if (null != taPerson) {
82
+            taShopKeeper.setPersonId(taPerson.getPersonId());
83
+        }
84
+
75
         if (iTaShopKeeperService.save(taShopKeeper)){
85
         if (iTaShopKeeperService.save(taShopKeeper)){
76
             return ResponseBean.success(taShopKeeper);
86
             return ResponseBean.success(taShopKeeper);
77
         }else {
87
         }else {
106
     public ResponseBean taShopKeeperUpdate(@ApiParam("对象ID") @PathVariable String id,
116
     public ResponseBean taShopKeeperUpdate(@ApiParam("对象ID") @PathVariable String id,
107
                                         @ApiParam("更新内容") @RequestBody TaShopKeeper taShopKeeper) throws Exception{
117
                                         @ApiParam("更新内容") @RequestBody TaShopKeeper taShopKeeper) throws Exception{
108
 
118
 
119
+        TaPerson taPerson = iTaPersonService.getByPhone(taShopKeeper.getPhone());
120
+        if (null != taPerson) {
121
+            taShopKeeper.setPersonId(taPerson.getPersonId());
122
+        }
123
+
109
         if (iTaShopKeeperService.updateById(taShopKeeper)){
124
         if (iTaShopKeeperService.updateById(taShopKeeper)){
110
             return ResponseBean.success(iTaShopKeeperService.getById(id));
125
             return ResponseBean.success(iTaShopKeeperService.getById(id));
111
         }else {
126
         }else {

+ 3
- 0
src/main/java/com/shigongli/service/ITaPersonService.java View File

2
 
2
 
3
 import com.shigongli.entity.TaPerson;
3
 import com.shigongli.entity.TaPerson;
4
 import com.baomidou.mybatisplus.extension.service.IService;
4
 import com.baomidou.mybatisplus.extension.service.IService;
5
+import com.shigongli.entity.TaShopKeeper;
5
 
6
 
6
 /**
7
 /**
7
  * <p>
8
  * <p>
14
 public interface ITaPersonService extends IService<TaPerson> {
15
 public interface ITaPersonService extends IService<TaPerson> {
15
 
16
 
16
     TaPerson getByOpenId(String openid);
17
     TaPerson getByOpenId(String openid);
18
+
19
+    TaPerson getByPhone(String phone);
17
 }
20
 }

+ 6
- 0
src/main/java/com/shigongli/service/ITaShopKeeperService.java View File

1
 package com.shigongli.service;
1
 package com.shigongli.service;
2
 
2
 
3
+import com.shigongli.entity.TaPerson;
3
 import com.shigongli.entity.TaShopKeeper;
4
 import com.shigongli.entity.TaShopKeeper;
4
 import com.baomidou.mybatisplus.extension.service.IService;
5
 import com.baomidou.mybatisplus.extension.service.IService;
5
 
6
 
7
+import java.util.List;
8
+
6
 /**
9
 /**
7
  * <p>
10
  * <p>
8
  * 店主 服务类
11
  * 店主 服务类
13
  */
16
  */
14
 public interface ITaShopKeeperService extends IService<TaShopKeeper> {
17
 public interface ITaShopKeeperService extends IService<TaShopKeeper> {
15
 
18
 
19
+    void bindPerson(TaPerson taPerson);
20
+
21
+    List<TaShopKeeper> getByPhone(String phone);
16
 }
22
 }

+ 17
- 0
src/main/java/com/shigongli/service/impl/TaPersonServiceImpl.java View File

1
 package com.shigongli.service.impl;
1
 package com.shigongli.service.impl;
2
 
2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.shigongli.common.StringUtils;
5
+import com.shigongli.constants.StatusConstant;
3
 import com.shigongli.entity.TaPerson;
6
 import com.shigongli.entity.TaPerson;
7
+import com.shigongli.entity.TaShopKeeper;
4
 import com.shigongli.mapper.TaPersonMapper;
8
 import com.shigongli.mapper.TaPersonMapper;
5
 import com.shigongli.service.ITaPersonService;
9
 import com.shigongli.service.ITaPersonService;
6
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
10
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
25
     public TaPerson getByOpenId(String openid) {
29
     public TaPerson getByOpenId(String openid) {
26
         return taPersonMapper.getByOpenId(openid);
30
         return taPersonMapper.getByOpenId(openid);
27
     }
31
     }
32
+
33
+    @Override
34
+    public TaPerson getByPhone(String phone) {
35
+        if (StringUtils.isEmpty(phone)) {
36
+            return null;
37
+        }
38
+
39
+        QueryWrapper<TaPerson> queryWrapper = new QueryWrapper<TaPerson>()
40
+                .eq("phone", phone)
41
+                .eq("status", StatusConstant.NORMAL);
42
+
43
+        return getOne(queryWrapper);
44
+    }
28
 }
45
 }

+ 27
- 0
src/main/java/com/shigongli/service/impl/TaShopKeeperServiceImpl.java View File

1
 package com.shigongli.service.impl;
1
 package com.shigongli.service.impl;
2
 
2
 
3
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
+import com.shigongli.constants.StatusConstant;
5
+import com.shigongli.entity.TaPerson;
3
 import com.shigongli.entity.TaShopKeeper;
6
 import com.shigongli.entity.TaShopKeeper;
4
 import com.shigongli.mapper.TaShopKeeperMapper;
7
 import com.shigongli.mapper.TaShopKeeperMapper;
5
 import com.shigongli.service.ITaShopKeeperService;
8
 import com.shigongli.service.ITaShopKeeperService;
6
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
9
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
 import org.springframework.stereotype.Service;
10
 import org.springframework.stereotype.Service;
8
 
11
 
12
+import java.util.List;
13
+
9
 /**
14
 /**
10
  * <p>
15
  * <p>
11
  * 店主 服务实现类
16
  * 店主 服务实现类
17
 @Service
22
 @Service
18
 public class TaShopKeeperServiceImpl extends ServiceImpl<TaShopKeeperMapper, TaShopKeeper> implements ITaShopKeeperService {
23
 public class TaShopKeeperServiceImpl extends ServiceImpl<TaShopKeeperMapper, TaShopKeeper> implements ITaShopKeeperService {
19
 
24
 
25
+    @Override
26
+    public void bindPerson(TaPerson taPerson) {
27
+        List<TaShopKeeper> shopKeeperList = getByPhone(taPerson.getPhone());
28
+
29
+        if (null == shopKeeperList) {
30
+            return ;
31
+        }
32
+
33
+        for (TaShopKeeper shopKeeper: shopKeeperList) {
34
+            shopKeeper.setPersonId(taPerson.getPersonId());
35
+            updateById(shopKeeper);
36
+        }
37
+    }
38
+
39
+    @Override
40
+    public List<TaShopKeeper> getByPhone(String phone) {
41
+        QueryWrapper<TaShopKeeper> queryWrapper = new QueryWrapper<TaShopKeeper>()
42
+                .eq("phone", phone)
43
+                .eq("status", StatusConstant.NORMAL);
44
+
45
+        return list(queryWrapper);
46
+    }
20
 }
47
 }