修改新增时,如选了默认地址,先清除当前默认地址
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package com.peanut.common.utils;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.lang.time.DateUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@@ -38,7 +39,9 @@ public class DataMigrationUtil extends Thread {
|
||||
Connection yljkconn = DriverManager.getConnection(
|
||||
"jdbc:mysql://goldorchid.mysql.rds.aliyuncs.com:3309/everhealth?",
|
||||
"yljkmaster", "Wu751019!@");
|
||||
PreparedStatement statement = yljkconn.prepareStatement("select * from t_curriculum_catalogue where valid = 1 and poid in (select oid from t_curriculum_catalogue where valid = 1 and poid is null) and (courseFee like '%,%' or courseFee = '0' or poid = '00000000000000000000000000000070' )");
|
||||
PreparedStatement statement = yljkconn.prepareStatement("select * from t_curriculum_catalogue where valid = 1" +
|
||||
" and poid in (select oid from t_curriculum_catalogue where valid = 1 and poid is null) " +
|
||||
"and (courseFee like '%,%' or courseFee = '0' or courseFee = '' or poid = '00000000000000000000000000000070' )");
|
||||
ResultSet resultSet = statement.executeQuery();
|
||||
List<Map> list = new ArrayList();
|
||||
while(resultSet.next()){
|
||||
@@ -135,7 +138,9 @@ public class DataMigrationUtil extends Thread {
|
||||
halfFee = "0";
|
||||
fee = "0";
|
||||
}
|
||||
if ("0".equals(resultSet.getString("courseFee"))){
|
||||
if ("0".equals(resultSet.getString("courseFee"))
|
||||
||("".equals(resultSet.getString("courseFee"))
|
||||
&&!"00000000000000000000000000000070".equals(resultSet.getString("ppoid")))){
|
||||
preparedStatement.setInt(1,0);
|
||||
}else if ("00000000000000000000000000000070".equals(resultSet.getString("ppoid"))){
|
||||
preparedStatement.setInt(1,2);
|
||||
@@ -278,15 +283,16 @@ public class DataMigrationUtil extends Thread {
|
||||
ResultSet resultSet = statement.executeQuery();
|
||||
Map map = new HashMap();
|
||||
while(resultSet.next()){
|
||||
map.put("videoType",resultSet.getString("videoType"));
|
||||
if (map.get("videoType").toString().equals("01")){
|
||||
map.put("type","0");
|
||||
map.put("video",resultSet.getString("videos"));
|
||||
}else if (map.get("videoType").equals("02")){
|
||||
if (StringUtils.isNotEmpty(resultSet.getString("videoId"))){
|
||||
map.put("type","1");
|
||||
map.put("video",resultSet.getString("videoId"));
|
||||
}else if (StringUtils.isNotEmpty(resultSet.getString("videos"))){
|
||||
map.put("type","0");
|
||||
map.put("video",resultSet.getString("videos"));
|
||||
}else if (StringUtils.isNotEmpty(resultSet.getString("voices"))){
|
||||
map.put("type","2");
|
||||
map.put("video",resultSet.getString("voices"));
|
||||
}
|
||||
map.put("createDate",resultSet.getString("createDate"));
|
||||
if (map.size() > 0){
|
||||
String[] tt = map.get("video").toString().split(",");
|
||||
if (tt.length>0){
|
||||
@@ -295,7 +301,7 @@ public class DataMigrationUtil extends Thread {
|
||||
preparedStatement.setString(1,fzdslist.get(q-1).get("cccid").toString());
|
||||
preparedStatement.setString(2,map.get("type").toString());
|
||||
preparedStatement.setString(3,tt[r]);
|
||||
preparedStatement.setString(4,map.get("createDate").toString());
|
||||
preparedStatement.setString(4,resultSet.getString("createDate"));
|
||||
preparedStatement.setString(5,r+1+"");
|
||||
// 添加到批处理中
|
||||
preparedStatement.addBatch();
|
||||
|
||||
@@ -41,9 +41,8 @@ public class UserAddressController {
|
||||
*/
|
||||
@RequestMapping("/save")
|
||||
public R save(@RequestBody UserAddress userAddress) {
|
||||
// 判断是否已经有默认的地址了
|
||||
if ((userAddressService.getUserDefaultAddressCount(userAddress.getUserId()) >= 1) && userAddress.getIsDefault() == 1) {
|
||||
return R.error("已经存在默认地址");
|
||||
if (userAddress.getIsDefault()==1){
|
||||
userAddressService.clearUserDefaultAddress(userAddress.getUserId());
|
||||
}
|
||||
if(userAddress.getRegionCode()==null||userAddress.getRegionCode().equals("")){
|
||||
return R.error("地址异常添加失败!");
|
||||
@@ -58,14 +57,8 @@ public class UserAddressController {
|
||||
|
||||
@RequestMapping("/update")
|
||||
public R update(@RequestBody UserAddress userAddress) {
|
||||
LambdaQueryWrapper<UserAddress> wrapper = new LambdaQueryWrapper();
|
||||
wrapper.eq(UserAddress::getId,userAddress.getId());
|
||||
wrapper.eq(UserAddress::getIsDefault,1);
|
||||
UserAddress ua = userAddressService.getOne(wrapper);
|
||||
if (ua == null){
|
||||
if ((userAddressService.getUserDefaultAddressCount(userAddress.getUserId()) >= 1) && userAddress.getIsDefault() == 1) {
|
||||
return R.error("已经存在默认地址");
|
||||
}
|
||||
if (userAddress.getIsDefault()==1){
|
||||
userAddressService.clearUserDefaultAddress(userAddress.getUserId());
|
||||
}
|
||||
String str = userAddress.getConsigneeName()+userAddress.getConsigneePhone()+userAddress.getDetailAddress();
|
||||
if(str.contains("+")||str.contains("&")){
|
||||
|
||||
@@ -12,6 +12,6 @@ public interface UserAddressService extends IService<UserAddress> {
|
||||
|
||||
UserAddressVo getAddressName(UserAddressVo vo, String regionCode);
|
||||
|
||||
int getUserDefaultAddressCount(Integer userId);
|
||||
boolean clearUserDefaultAddress(Integer userId);
|
||||
|
||||
}
|
||||
@@ -63,10 +63,12 @@ public class UserAddressServiceImpl extends ServiceImpl<UserAddressDao, UserAddr
|
||||
return vo;
|
||||
}
|
||||
|
||||
public int getUserDefaultAddressCount(Integer userId) {
|
||||
public boolean clearUserDefaultAddress(Integer userId) {
|
||||
QueryWrapper<UserAddress> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("user_id", userId);
|
||||
queryWrapper.eq("is_default", 1);
|
||||
return this.count(queryWrapper);
|
||||
UserAddress userAddress = this.getOne(queryWrapper);
|
||||
userAddress.setIsDefault(0);
|
||||
return this.updateById(userAddress);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user