From 991b21a822367325511c0852c814bce96d229d44 Mon Sep 17 00:00:00 2001 From: "Stormeye.Wu" Date: Wed, 12 Sep 2018 20:51:20 +0800 Subject: [PATCH] =?UTF-8?q?[=E7=94=A8=E6=88=B7ID=E5=90=8C=E6=AD=A5][?= =?UTF-8?q?=E6=96=B0=E5=A2=9E]:=E7=94=A8=E6=88=B7=E6=89=8B=E6=9C=BA?= =?UTF-8?q?=E7=9B=B8=E5=90=8C=E6=97=B6=E5=90=8C=E6=AD=A5ID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/WxUserGrantController.java | 19 +++++++++- .../com/simple/domain/vo/CUserBaseVo.java | 20 +++++++++++ .../simple/mapper/WxCUserBasicInfoMapper.java | 3 ++ .../service/WxCUserBasicInfoService.java | 36 ++++++++++++------- .../impl/WxCUserBasicInfoServiceImpl.java | 21 ++++++++--- .../mapper/WxCUserBasicInfoMapper.xml | 6 +++- 6 files changed, 87 insertions(+), 18 deletions(-) create mode 100644 mallinkService/src/main/java/com/simple/domain/vo/CUserBaseVo.java diff --git a/mallinkCApi/src/main/java/com/simple/controller/WxUserGrantController.java b/mallinkCApi/src/main/java/com/simple/controller/WxUserGrantController.java index f120442d0..c50f099b1 100755 --- a/mallinkCApi/src/main/java/com/simple/controller/WxUserGrantController.java +++ b/mallinkCApi/src/main/java/com/simple/controller/WxUserGrantController.java @@ -14,8 +14,10 @@ import com.simple.common.Result; import com.simple.common.ResultData; import com.simple.domain.po.WxAppinfo; import com.simple.domain.po.WxCUser; +import com.simple.domain.po.WxCUserBasicInfo; import com.simple.domain.po.WxCUserCar; import com.simple.service.WxAppinfoService; +import com.simple.service.WxCUserBasicInfoService; import com.simple.service.WxCUserCarService; import com.simple.service.WxCUserService; import com.simple.utils.CheckUtil; @@ -51,6 +53,9 @@ public class WxUserGrantController extends BaseController { @Autowired private WxCUserService wxCUserService; + @Autowired + private WxCUserBasicInfoService wxCUserBasicInfoService; + @Autowired private WxCUserCarService wxCUserCarService; @@ -249,7 +254,6 @@ public class WxUserGrantController extends BaseController { wxCUserService.saveOrUpdate(user); resultMap.put("msg","授权手机成功!"); resultMap.put("phone",phoneNoInfo.getPhoneNumber()); - return new ResultData(resultMap); } else { return new ResultData(ErrorCode.PHONE_DECODE_ERR, resultMap); } @@ -257,6 +261,19 @@ public class WxUserGrantController extends BaseController { this.logger.error(e.getMessage(), e); return new ResultData(ErrorCode.DB_FAIL.getCode(), "解密并保存出错", resultMap); } + + // update wx_c_user_basic_info + List list = wxCUserBasicInfoService.findByPhone(user.getTenantId(), user.getPhone()); + if (list.size() > 0) { + WxCUserBasicInfo basicInfo = list.get(0); + try { + wxCUserBasicInfoService.updateObj(basicInfo, user.getId()); + } catch (Exception e) { + + } + } + + return new ResultData(resultMap); } /** diff --git a/mallinkService/src/main/java/com/simple/domain/vo/CUserBaseVo.java b/mallinkService/src/main/java/com/simple/domain/vo/CUserBaseVo.java new file mode 100644 index 000000000..e7693f1ec --- /dev/null +++ b/mallinkService/src/main/java/com/simple/domain/vo/CUserBaseVo.java @@ -0,0 +1,20 @@ +package com.simple.domain.vo; + + +import com.simple.domain.po.WxCUserBasicInfo; + +/** + * Created by syf on 2018/8/30. + */ +public class CUserBaseVo extends WxCUserBasicInfo { + + private Long newId; + + public Long getNewId() { + return newId; + } + + public void setNewId(Long newId) { + this.newId = newId; + } +} diff --git a/mallinkService/src/main/java/com/simple/mapper/WxCUserBasicInfoMapper.java b/mallinkService/src/main/java/com/simple/mapper/WxCUserBasicInfoMapper.java index 11c5ef83f..9253f7268 100644 --- a/mallinkService/src/main/java/com/simple/mapper/WxCUserBasicInfoMapper.java +++ b/mallinkService/src/main/java/com/simple/mapper/WxCUserBasicInfoMapper.java @@ -3,6 +3,7 @@ package com.simple.mapper; import com.simple.common.CommonMapper; import com.simple.domain.dto.WxCUserBasicInfoDto; import com.simple.domain.po.WxCUserBasicInfo; +import com.simple.domain.vo.CUserBaseVo; import java.util.List; import java.util.Map; @@ -16,6 +17,8 @@ public interface WxCUserBasicInfoMapper extends CommonMapper list(WxCUserBasicInfoDto record); void updateScore(WxCUserBasicInfo record); + + void updateNewId(CUserBaseVo record); long findCountBySex(WxCUserBasicInfoDto dto); diff --git a/mallinkService/src/main/java/com/simple/service/WxCUserBasicInfoService.java b/mallinkService/src/main/java/com/simple/service/WxCUserBasicInfoService.java index b8adeacbd..616d50da8 100644 --- a/mallinkService/src/main/java/com/simple/service/WxCUserBasicInfoService.java +++ b/mallinkService/src/main/java/com/simple/service/WxCUserBasicInfoService.java @@ -8,11 +8,12 @@ import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.util.List; import java.util.Map; public interface WxCUserBasicInfoService { - /** + /** * 根据实体查询分页列表 * * @param record @@ -20,53 +21,64 @@ public interface WxCUserBasicInfoService { * @param limit * @return */ - PageInfo listAsPage(WxCUserBasicInfo record, Integer pageIndex, Integer pageSize); - - /** + PageInfo listAsPage(WxCUserBasicInfo record, Integer pageIndex, Integer pageSize); + + /** * 根据Id获得实体 * * @param id * @return */ WxCUserBasicInfo getById(Long id); - - /** + + /** * 保存或更新实体 * * @param record */ void saveOrUpdate(WxCUserBasicInfo record); + /** + * 保存或更新实体 + * + * @param record + */ + void updateObj(WxCUserBasicInfo record, Long newId); + /** * 根据Id删除实体 * * @param id */ void deleteById(Long id); - - - + + PageInfo list(WxCUserBasicInfoDto record, Integer pageIndex, Integer pageSize); + List findByPhone(String tenantId, String phone); + /** * 修改会员积分 + * * @param record */ void updateScore(WxCUserBasicInfo record); /** - * 根据性别查询数量 - * @param sex + * 根据性别查询数量 + * + * @param dto * @return */ long findCountBySex(WxCUserBasicInfoDto dto); /** * 根据年龄查询数量 + * * @param dto * @return */ - long findCountByAge(WxCUserBasicInfoDto dto); + long findCountByAge(WxCUserBasicInfoDto dto); PageInfo> queryListMap(WxCUserBasicInfoDto wxCUserBasicInfo, Integer pageNum, Integer pageSize); diff --git a/mallinkService/src/main/java/com/simple/service/impl/WxCUserBasicInfoServiceImpl.java b/mallinkService/src/main/java/com/simple/service/impl/WxCUserBasicInfoServiceImpl.java index ededb7edb..aaffd8b5e 100644 --- a/mallinkService/src/main/java/com/simple/service/impl/WxCUserBasicInfoServiceImpl.java +++ b/mallinkService/src/main/java/com/simple/service/impl/WxCUserBasicInfoServiceImpl.java @@ -10,6 +10,7 @@ import com.simple.common.ResultData; import com.simple.domain.dto.WxCUserBasicInfoDto; import com.simple.domain.po.WxCUser; import com.simple.domain.po.WxCUserBasicInfo; +import com.simple.domain.vo.CUserBaseVo; import com.simple.exception.MallinkException; import com.simple.mapper.WxCUserBasicInfoMapper; import com.simple.mapper.WxCUserMapper; @@ -54,13 +55,18 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCUserBasicInfoMapper.list(record)); } + @Override + public List findByPhone(String tenantId, String phone) { + WxCUserBasicInfo basicQ = new WxCUserBasicInfo(); + basicQ.setTenantId(tenantId); + basicQ.setPhone(phone); + return wxCUserBasicInfoMapper.select(basicQ); + } + @Override public void updateScore(WxCUserBasicInfo record) { wxCUserBasicInfoMapper.updateScore(record); - } - - @Override public WxCUserBasicInfo getById(Long id) { @@ -79,6 +85,14 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { } } + @Override + public void updateObj(WxCUserBasicInfo record, Long newId) { + CUserBaseVo userBaseVo = new CUserBaseVo(); + org.springframework.beans.BeanUtils.copyProperties(record, userBaseVo); + userBaseVo.setNewId(newId); + wxCUserBasicInfoMapper.updateNewId(userBaseVo); + } + @Override public void deleteById(Long id) { wxCUserBasicInfoMapper.deleteByPrimaryKey(id); @@ -88,7 +102,6 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { @Override public long findCountBySex(WxCUserBasicInfoDto dto) { - return wxCUserBasicInfoMapper.findCountBySex(dto); } diff --git a/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml b/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml index 7522c7a90..81e153bff 100644 --- a/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml +++ b/mallinkService/src/main/resources/mapper/WxCUserBasicInfoMapper.xml @@ -129,8 +129,12 @@ update wx_c_user_basic_info set poins=#{poins} where phone=#{phone} and tenant_id=#{tenantId} - and c_user_id=#{cUserId} + and id=#{cUserId} + + + update wx_c_user_basic_info set id=#{newId} where tenant_id=#{tenantId} + and id = #{id}