|
|
|
@ -208,6 +208,7 @@ public class ApeopersionController { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//这个功能是个人中心的地址管设置默认地址
|
|
|
|
|
@RequestMapping(value = "/sdqx", method = RequestMethod.GET) |
|
|
|
|
public Result<?> sdqx(@RequestParam(name="id",required=true) String id) { |
|
|
|
|
//根据id查询需要设置成默认收货地址的收货地址
|
|
|
|
@ -224,9 +225,75 @@ public class ApeopersionController { |
|
|
|
|
customerReceivingAddressService.updatec(cusm.getId(),sort); |
|
|
|
|
customerReceivingAddressService.updates(id); |
|
|
|
|
} |
|
|
|
|
return Result.OK("成功!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//这个功能是个人中心的地址添加收货地址,不是默认收货地址
|
|
|
|
|
@RequestMapping(value = "/addadressress", method = RequestMethod.GET) |
|
|
|
|
public Result<?> addadressress(@RequestParam(name = "form", required = true) String form) { |
|
|
|
|
System.out.println(form); |
|
|
|
|
//这里方便获取当前登陆信息
|
|
|
|
|
LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
|
//这里获取当前登陆的用户名
|
|
|
|
|
String Username = loginUser.getUsername(); |
|
|
|
|
//将前台传过来的json数据包转化成map
|
|
|
|
|
Map map = JSON.parseObject(form,Map.class); |
|
|
|
|
//获取flag的数据
|
|
|
|
|
String flag = map.get("flag").toString(); |
|
|
|
|
//通过flag判断是否是需要的设置成默认地址
|
|
|
|
|
if (flag.equals("false")){ |
|
|
|
|
//寻找之前的排序的最后一个
|
|
|
|
|
CustomerReceivingAddress cus = customerReceivingAddressService.getcreatbuyuser(Username); |
|
|
|
|
CustomerReceivingAddress cus2 =new CustomerReceivingAddress(); |
|
|
|
|
cus2.setUserId(loginUser.getId()); |
|
|
|
|
cus2.setCityId((String)map.get("addr")); |
|
|
|
|
cus2.setUsernamme((String)map.get("name")); |
|
|
|
|
cus2.setAddress((String)map.get("detailed")); |
|
|
|
|
cus2.setMobile((String)map.get("phone")); |
|
|
|
|
cus2.setSort(cus.getSort()+1); |
|
|
|
|
customerReceivingAddressService.save(cus2); |
|
|
|
|
} else if (flag.equals("true")){ |
|
|
|
|
//寻找之前的排序的最后一个
|
|
|
|
|
CustomerReceivingAddress cus = customerReceivingAddressService.getcreatbuyuser(Username); |
|
|
|
|
//开始寻找之前的默认地址
|
|
|
|
|
CustomerReceivingAddress cusm = customerReceivingAddressService.getneedyls(Username); |
|
|
|
|
//开始组装需要的新的默认地址
|
|
|
|
|
CustomerReceivingAddress cus2 =new CustomerReceivingAddress(); |
|
|
|
|
cus2.setUserId(loginUser.getId()); |
|
|
|
|
cus2.setCityId((String)map.get("addr")); |
|
|
|
|
cus2.setUsernamme((String)map.get("name")); |
|
|
|
|
cus2.setAddress((String)map.get("detailed")); |
|
|
|
|
cus2.setMobile((String)map.get("phone")); |
|
|
|
|
cus2.setSort(0); |
|
|
|
|
//将新的数据写入数据库
|
|
|
|
|
customerReceivingAddressService.save(cus2); |
|
|
|
|
//将老的默认收货地址放在排序的最后一个
|
|
|
|
|
cusm.setSort(cus.getSort()+1); |
|
|
|
|
customerReceivingAddressService.updateById(cusm); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return Result.OK("成功!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//这个功能是个人中心的地址添加收货地址,不是默认收货地址
|
|
|
|
|
@RequestMapping(value = "/updateadressress", method = RequestMethod.GET) |
|
|
|
|
public Result<?> updateadressress(@RequestParam(name = "form", required = true) String form) { |
|
|
|
|
//将前台传过来的json数据包转化成map
|
|
|
|
|
Map map = JSON.parseObject(form,Map.class); |
|
|
|
|
//查询需要的对象
|
|
|
|
|
CustomerReceivingAddress needc = customerReceivingAddressService.getById((String)map.get("id")); |
|
|
|
|
needc.setMobile((String)map.get("phone")); |
|
|
|
|
needc.setUsernamme((String)map.get("name")); |
|
|
|
|
needc.setAddress((String)map.get("detailed")); |
|
|
|
|
needc.setCityId((String)map.get("addr")); |
|
|
|
|
customerReceivingAddressService.updateById(needc); |
|
|
|
|
return Result.OK("成功!"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|