| @@ -63,7 +63,23 @@ public class WxMerchantBUserController extends BaseController | |||||
| public ResultData findById(Long id) { | public ResultData findById(Long id) { | ||||
| return new ResultData(Result.SUCCESS,"查询成功",wxMerchantBUserService.getById(id)); | return new ResultData(Result.SUCCESS,"查询成功",wxMerchantBUserService.getById(id)); | ||||
| } | } | ||||
| @ApiOperation("手机号是否存在") | |||||
| @GetMapping("/hasphone") | |||||
| @ApiImplicitParam(name="phone",value="phone",dataType="String", paramType = "query",required=true) | |||||
| public ResultData hasphone(String phone) { | |||||
| boolean has=wxMerchantBUserService.hasphone(phone); | |||||
| return new ResultData(Result.SUCCESS,"查询成功",has); | |||||
| } | |||||
| @ApiOperation("修改密码") | |||||
| @GetMapping("/updatepwd") | |||||
| @ApiImplicitParams({ | |||||
| @ApiImplicitParam(name="phone",value="手机号",dataType="String", paramType = "query",required=true), | |||||
| @ApiImplicitParam(name="code",value="验证码",dataType="String", paramType = "query",required=true), | |||||
| @ApiImplicitParam(name="pwd",value="密码",dataType="String", paramType = "query",required=true)}) | |||||
| public ResultData updatepwd(String phone,String code,String pwd) { | |||||
| return wxMerchantBUserService.updatepwd(phone,code,pwd); | |||||
| } | |||||
| } | } | ||||
| @@ -1,6 +1,7 @@ | |||||
| package com.simple.service; | package com.simple.service; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.common.ResultData; | |||||
| import com.simple.domain.po.WxMerchantBUser; | import com.simple.domain.po.WxMerchantBUser; | ||||
| public interface WxMerchantBUserService { | public interface WxMerchantBUserService { | ||||
| @@ -52,12 +53,10 @@ public interface WxMerchantBUserService { | |||||
| * @param id | * @param id | ||||
| */ | */ | ||||
| void deleteById(Long id); | void deleteById(Long id); | ||||
| boolean hasphone(String phone); | |||||
| ResultData updatepwd(String phone, String code, String pwd); | |||||
| } | } | ||||
| @@ -1,6 +1,5 @@ | |||||
| package com.simple.service; | package com.simple.service; | ||||
| import java.util.*; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.domain.po.WxMerchant; | import com.simple.domain.po.WxMerchant; | ||||
| @@ -29,7 +28,7 @@ public interface WxMerchantService { | |||||
| * | * | ||||
| * @param record | * @param record | ||||
| */ | */ | ||||
| void saveOrUpdate(WxMerchant record); | |||||
| void saveOrUpdate(WxMerchant record); | |||||
| /** | /** | ||||
| * 根据Id删除实体 | * 根据Id删除实体 | ||||
| @@ -1,10 +1,15 @@ | |||||
| package com.simple.service.impl; | package com.simple.service.impl; | ||||
| import java.util.*; | import java.util.*; | ||||
| import java.util.stream.Collectors; | |||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.common.ResultData; | |||||
| import com.simple.domain.po.WxMerchantBUser; | import com.simple.domain.po.WxMerchantBUser; | ||||
| import com.simple.domain.po.WxMsgValidationcode; | |||||
| import com.simple.mapper.WxMerchantBUserMapper; | import com.simple.mapper.WxMerchantBUserMapper; | ||||
| import com.simple.mapper.WxMsgValidationcodeMapper; | |||||
| import com.simple.service.WxMerchantBUserService; | import com.simple.service.WxMerchantBUserService; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
| @@ -16,6 +21,8 @@ public class WxMerchantBUserServiceImpl implements WxMerchantBUserService { | |||||
| @Autowired | @Autowired | ||||
| WxMerchantBUserMapper wxMerchantBUserMapper; | WxMerchantBUserMapper wxMerchantBUserMapper; | ||||
| @Autowired | |||||
| WxMsgValidationcodeMapper wxMsgValidationcodeMapper; | |||||
| @Override | @Override | ||||
| public PageInfo<WxMerchantBUser> listAsPage(WxMerchantBUser record, Integer pageIndex, Integer pageSize) { | public PageInfo<WxMerchantBUser> listAsPage(WxMerchantBUser record, Integer pageIndex, Integer pageSize) { | ||||
| @@ -62,12 +69,38 @@ public class WxMerchantBUserServiceImpl implements WxMerchantBUserService { | |||||
| public void deleteById(Long id) { | public void deleteById(Long id) { | ||||
| wxMerchantBUserMapper.deleteByPrimaryKey(id); | wxMerchantBUserMapper.deleteByPrimaryKey(id); | ||||
| } | } | ||||
| @Override | |||||
| public boolean hasphone(String phone) { | |||||
| WxMerchantBUser bUser = new WxMerchantBUser(); | |||||
| bUser.setPhone(phone); | |||||
| List<WxMerchantBUser> list = wxMerchantBUserMapper.findList(bUser); | |||||
| return list.size()>=1?true:false; | |||||
| } | |||||
| @Override | |||||
| public ResultData updatepwd(String phone, String code, String pwd) { | |||||
| WxMsgValidationcode wxMsgValidationcode = new WxMsgValidationcode(); | |||||
| wxMsgValidationcode.setPhone(phone); | |||||
| wxMsgValidationcode.setCode(code); | |||||
| List<WxMsgValidationcode> wxmsgvalidationcodelist = wxMsgValidationcodeMapper.findList(wxMsgValidationcode); | |||||
| Date currentdate = new Date(); | |||||
| wxmsgvalidationcodelist = wxmsgvalidationcodelist.stream().filter(validationcode -> | |||||
| validationcode.getExpiretime().after(currentdate)).collect(Collectors.toList()); | |||||
| if(wxmsgvalidationcodelist.size()>0){ | |||||
| //更新 | |||||
| WxMerchantBUser bUser = new WxMerchantBUser(); | |||||
| bUser.setPhone(phone); | |||||
| List<WxMerchantBUser> list = wxMerchantBUserMapper.findList(bUser); | |||||
| if(list.size()>0){ | |||||
| bUser = list.get(0); | |||||
| bUser.setBUserPwd(pwd); | |||||
| wxMerchantBUserMapper.updateByPrimaryKeySelective(bUser); | |||||
| return new ResultData(200,"操作成功"); | |||||
| } | |||||
| } | |||||
| return new ResultData(500,"操作失败"); | |||||
| } | |||||
| } | } | ||||
| @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONArray; | |||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.common.IdWorker; | import com.simple.common.IdWorker; | ||||
| import com.simple.common.ResultData; | |||||
| import com.simple.domain.po.WxMerchant; | import com.simple.domain.po.WxMerchant; | ||||
| import com.simple.domain.po.WxMerchantBUser; | import com.simple.domain.po.WxMerchantBUser; | ||||
| import com.simple.domain.po.WxMerchantShop; | import com.simple.domain.po.WxMerchantShop; | ||||
| @@ -20,6 +21,8 @@ import org.springframework.transaction.annotation.Transactional; | |||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | |||||
| import java.util.stream.Collectors; | |||||
| @Service | @Service | ||||
| public class WxMerchantServiceImpl implements WxMerchantService { | public class WxMerchantServiceImpl implements WxMerchantService { | ||||
| @@ -81,7 +84,6 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| @Override | @Override | ||||
| public void saveOrUpdate(WxMerchant wxMerchant) { | public void saveOrUpdate(WxMerchant wxMerchant) { | ||||
| if (wxMerchant.getId() == null) { | if (wxMerchant.getId() == null) { | ||||
| final IdWorker idWorker = IdWorker.get(); | final IdWorker idWorker = IdWorker.get(); | ||||
| long merchantid = idWorker.nextId(); | long merchantid = idWorker.nextId(); | ||||
| @@ -114,21 +116,6 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| WxShopMapper.updateByPrimaryKeySelective(wxShop); | WxShopMapper.updateByPrimaryKeySelective(wxShop); | ||||
| } | } | ||||
| //保存商户关联用户 | |||||
| List<Long> useridlist = wxMerchant.getUserids(); | |||||
| for(Long userid:useridlist){ | |||||
| WxMerchantBUser wxMerchantBUser = new WxMerchantBUser(); | |||||
| wxMerchantBUser.setId(userid); | |||||
| List<WxMerchantBUser> buserlist = wxMerchantBUserMapper.findList(wxMerchantBUser); | |||||
| if(buserlist.size()>0){ | |||||
| wxMerchantBUser = buserlist.get(0); | |||||
| wxMerchantBUser.setMerchantId(merchantid); | |||||
| wxMerchantBUser.setUpdateDate(new Date()); | |||||
| wxMerchantBUserMapper.updateByPrimaryKey(wxMerchantBUser); | |||||
| } | |||||
| } | |||||
| } else { | } else { | ||||
| //更新商户 | //更新商户 | ||||
| @@ -174,21 +161,25 @@ public class WxMerchantServiceImpl implements WxMerchantService { | |||||
| WxShopMapper.updateByPrimaryKeySelective(wxShop); | WxShopMapper.updateByPrimaryKeySelective(wxShop); | ||||
| } | } | ||||
| } | |||||
| //保存商户关联用户 | |||||
| List<Long> useridlist = wxMerchant.getUserids(); | |||||
| for(Long userid:useridlist){ | |||||
| WxMerchantBUser wxMerchantBUser = new WxMerchantBUser(); | |||||
| wxMerchantBUser.setId(userid); | |||||
| List<WxMerchantBUser> buserlist = wxMerchantBUserMapper.findList(wxMerchantBUser); | |||||
| if(buserlist.size()>0){ | |||||
| wxMerchantBUser = buserlist.get(0); | |||||
| wxMerchantBUser.setMerchantId(wxMerchant.getId()); | |||||
| wxMerchantBUser.setUpdateDate(new Date()); | |||||
| wxMerchantBUserMapper.updateByPrimaryKey(wxMerchantBUser); | |||||
| } | |||||
| } | |||||
| //删除之前的关联用户 | |||||
| List<WxMerchantBUser> bUsers = wxMerchant.getbUsers(); | |||||
| for(WxMerchantBUser user:bUsers){ | |||||
| wxMerchantBUserMapper.deleteByPrimaryKey(user.getId()); | |||||
| } | |||||
| //保存商户关联用户 | |||||
| final IdWorker idWorker = IdWorker.get(); | |||||
| for(WxMerchantBUser user:bUsers){ | |||||
| long id = idWorker.nextId(); | |||||
| user.setId(id); | |||||
| user.setBUserId(id); | |||||
| Date date = new Date(); | |||||
| user.setCreateDate(date); | |||||
| user.setUpdateDate(date); | |||||
| wxMerchantBUserMapper.insertSelective(user); | |||||
| } | } | ||||