Your Name 4 年前
父节点
当前提交
3d61343554

+ 7
- 0
src/main/java/com/shigongli/controller/TaPersonController.java 查看文件

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

+ 15
- 0
src/main/java/com/shigongli/controller/TaShopKeeperController.java 查看文件

@@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 6
 import com.shigongli.common.BaseController;
7 7
 import com.shigongli.common.ResponseBean;
8 8
 import com.shigongli.constants.StatusConstant;
9
+import com.shigongli.entity.TaPerson;
10
+import com.shigongli.service.ITaPersonService;
9 11
 import io.swagger.annotations.Api;
10 12
 import io.swagger.annotations.ApiOperation;
11 13
 import io.swagger.annotations.ApiParam;
@@ -40,6 +42,9 @@ public class TaShopKeeperController extends BaseController {
40 42
     @Autowired
41 43
     public ITaShopKeeperService iTaShopKeeperService;
42 44
 
45
+    @Autowired
46
+    public ITaPersonService iTaPersonService;
47
+
43 48
 
44 49
     /**
45 50
      * 分页查询列表
@@ -72,6 +77,11 @@ public class TaShopKeeperController extends BaseController {
72 77
     @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
73 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 85
         if (iTaShopKeeperService.save(taShopKeeper)){
76 86
             return ResponseBean.success(taShopKeeper);
77 87
         }else {
@@ -106,6 +116,11 @@ public class TaShopKeeperController extends BaseController {
106 116
     public ResponseBean taShopKeeperUpdate(@ApiParam("对象ID") @PathVariable String id,
107 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 124
         if (iTaShopKeeperService.updateById(taShopKeeper)){
110 125
             return ResponseBean.success(iTaShopKeeperService.getById(id));
111 126
         }else {

+ 3
- 0
src/main/java/com/shigongli/service/ITaPersonService.java 查看文件

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

+ 6
- 0
src/main/java/com/shigongli/service/ITaShopKeeperService.java 查看文件

@@ -1,8 +1,11 @@
1 1
 package com.shigongli.service;
2 2
 
3
+import com.shigongli.entity.TaPerson;
3 4
 import com.shigongli.entity.TaShopKeeper;
4 5
 import com.baomidou.mybatisplus.extension.service.IService;
5 6
 
7
+import java.util.List;
8
+
6 9
 /**
7 10
  * <p>
8 11
  * 店主 服务类
@@ -13,4 +16,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
13 16
  */
14 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 查看文件

@@ -1,6 +1,10 @@
1 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 6
 import com.shigongli.entity.TaPerson;
7
+import com.shigongli.entity.TaShopKeeper;
4 8
 import com.shigongli.mapper.TaPersonMapper;
5 9
 import com.shigongli.service.ITaPersonService;
6 10
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -25,4 +29,17 @@ public class TaPersonServiceImpl extends ServiceImpl<TaPersonMapper, TaPerson> i
25 29
     public TaPerson getByOpenId(String openid) {
26 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 查看文件

@@ -1,11 +1,16 @@
1 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 6
 import com.shigongli.entity.TaShopKeeper;
4 7
 import com.shigongli.mapper.TaShopKeeperMapper;
5 8
 import com.shigongli.service.ITaShopKeeperService;
6 9
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7 10
 import org.springframework.stereotype.Service;
8 11
 
12
+import java.util.List;
13
+
9 14
 /**
10 15
  * <p>
11 16
  * 店主 服务实现类
@@ -17,4 +22,26 @@ import org.springframework.stereotype.Service;
17 22
 @Service
18 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
 }