Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
@@ -13,7 +13,7 @@ import org.apache.ibatis.annotations.Select;
|
|||||||
public interface ShopUserMapper extends BaseMapper<TbShopUser> {
|
public interface ShopUserMapper extends BaseMapper<TbShopUser> {
|
||||||
|
|
||||||
@Select("<script>" +
|
@Select("<script>" +
|
||||||
"SELECT su.id as id, su.head_img as headImg, su.name as nickName, su.sex as sex, " +
|
"SELECT su.id as id, su.user_id as user_id, su.head_img as headImg, su.name as nickName, su.sex as sex, " +
|
||||||
"su.amount as amount, 0 as totalScore, su.telephone as telephone, u.last_log_in_at as lastLoginAt, " +
|
"su.amount as amount, 0 as totalScore, su.telephone as telephone, u.last_log_in_at as lastLoginAt, " +
|
||||||
"su.birth_day as birthDay, su.is_vip as isVip, su.created_at as createAt " +
|
"su.birth_day as birthDay, su.is_vip as isVip, su.created_at as createAt " +
|
||||||
"FROM tb_shop_user su " +
|
"FROM tb_shop_user su " +
|
||||||
|
|||||||
@@ -73,10 +73,15 @@ public class TbShopUserServiceImpl implements TbShopUserService {
|
|||||||
shopUserInfoVo.setTotalScore(0);
|
shopUserInfoVo.setTotalScore(0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Integer orderNumber=tbOrderInfoRepository.countByUserIdAndStatusAndShopId(shopUserInfoVo.getId().toString(),criteria.getShopId());
|
|
||||||
shopUserInfoVo.setOrderNumber(Objects.isNull(orderNumber)?0:orderNumber);
|
|
||||||
shopUserInfoVo.setInMoney(tbShopUserRepository.sumAmount(shopUserInfoVo.getId()));
|
|
||||||
|
|
||||||
|
if (shopUserInfoVo.getUserId() == null) {
|
||||||
|
shopUserInfoVo.setUserId(0);
|
||||||
|
shopUserInfoVo.setOrderNumber(0);
|
||||||
|
} else {
|
||||||
|
Integer orderNumber = tbOrderInfoRepository.countByUserIdAndStatusAndShopId(shopUserInfoVo.getUserId().toString(), criteria.getShopId());
|
||||||
|
shopUserInfoVo.setOrderNumber(Objects.isNull(orderNumber) ? 0 : orderNumber);
|
||||||
|
}
|
||||||
|
shopUserInfoVo.setInMoney(tbShopUserRepository.sumAmount(shopUserInfoVo.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return PageUtil.toPlusPage(iPage.getRecords(), Integer.valueOf(iPage.getTotal() + ""));
|
return PageUtil.toPlusPage(iPage.getRecords(), Integer.valueOf(iPage.getTotal() + ""));
|
||||||
@@ -194,51 +199,49 @@ public class TbShopUserServiceImpl implements TbShopUserService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modfiyAccount(Map<String, Object> map) {
|
public void modfiyAccount(Map<String, Object> map) {
|
||||||
if(ObjectUtil.isNull(map)||ObjectUtil.isEmpty(map)||!map.containsKey("id")||!map.containsKey("type")||!map.containsKey("amount")
|
if (ObjectUtil.isNull(map) || ObjectUtil.isEmpty(map) || !map.containsKey("id") || !map.containsKey("type") || !map.containsKey("amount")
|
||||||
||ObjectUtil.isEmpty(map.get("id"))||ObjectUtil.isNull(map.get("id"))||ObjectUtil.isNull(map.get("type"))||ObjectUtil.isEmpty(map.get("type"))
|
|| ObjectUtil.isEmpty(map.get("id")) || ObjectUtil.isNull(map.get("id")) || ObjectUtil.isNull(map.get("type")) || ObjectUtil.isEmpty(map.get("type"))
|
||||||
||ObjectUtil.isEmpty(map.get("amount"))||ObjectUtil.isNull(map.get("amount"))||!map.containsKey("operationType")||ObjectUtil.isEmpty(map.get("operationType"))||ObjectUtil.isNull(map.get("operationType"))
|
|| ObjectUtil.isEmpty(map.get("amount")) || ObjectUtil.isNull(map.get("amount")) || !map.containsKey("operationType") || ObjectUtil.isEmpty(map.get("operationType")) || ObjectUtil.isNull(map.get("operationType"))
|
||||||
|
|
||||||
){
|
) {
|
||||||
throw new BadRequestException("参数错误");
|
throw new BadRequestException("参数错误");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
String regex = "^(([1-9][0-9]*)|(([0]\\.\\d{1,2}|[1-9][0-9]*\\.\\d{1,2})))$";
|
String regex = "^(([1-9][0-9]*)|(([0]\\.\\d{1,2}|[1-9][0-9]*\\.\\d{1,2})))$";
|
||||||
if(!map.get("amount").toString().matches(regex)){
|
if (!map.get("amount").toString().matches(regex)) {
|
||||||
throw new BadRequestException("请输入正确的数字");
|
throw new BadRequestException("请输入正确的数字");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
TbShopUser tbShopUser = tbShopUserRepository.getById(Integer.valueOf(map.get("id") + ""));
|
||||||
TbShopUser tbShopUser= tbShopUserRepository.getById(Integer.valueOf(map.get("id")+""));
|
if (ObjectUtil.isNull(tbShopUser)) {
|
||||||
if(ObjectUtil.isNull(tbShopUser)){
|
throw new BadRequestException("不存在的会员信息");
|
||||||
throw new BadRequestException("不存在的会员信息");
|
|
||||||
}
|
}
|
||||||
String operationType=map.get("operationType").toString();
|
String operationType = map.get("operationType").toString();
|
||||||
|
|
||||||
BigDecimal amount=new BigDecimal(map.get("amount").toString());
|
BigDecimal amount = new BigDecimal(map.get("amount").toString());
|
||||||
if("out".equals(operationType)){
|
if ("out".equals(operationType)) {
|
||||||
if(amount.compareTo(tbShopUser.getAmount())>0){
|
if (amount.compareTo(tbShopUser.getAmount()) > 0) {
|
||||||
throw new BadRequestException("账户余额不足,请输入正确的金额");
|
throw new BadRequestException("账户余额不足,请输入正确的金额");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String type = map.get("type").toString();
|
||||||
|
TbShopUserFlow flow = new TbShopUserFlow();
|
||||||
|
|
||||||
String type=map.get("type").toString();
|
if ("in".equals(operationType)) {
|
||||||
TbShopUserFlow flow=new TbShopUserFlow();
|
|
||||||
|
|
||||||
if("in".equals(operationType)){
|
|
||||||
flow.setType("+");
|
flow.setType("+");
|
||||||
flow.setBizName("inMoney".equals(type)?"充值":"消费退款");
|
flow.setBizName("inMoney".equals(type) ? "充值" : "消费退款");
|
||||||
flow.setBizCode("inMoney".equals(type)?"inMoneyIn":"consumeIn");
|
flow.setBizCode("inMoney".equals(type) ? "inMoneyIn" : "consumeIn");
|
||||||
tbShopUser.setAmount(tbShopUser.getAmount().add(amount));
|
tbShopUser.setAmount(tbShopUser.getAmount().add(amount));
|
||||||
}else if("out".equals(operationType)){
|
} else if ("out".equals(operationType)) {
|
||||||
flow.setBizName("inMoneyOut".equals(type)?"充值退款":"消费");
|
flow.setBizName("inMoneyOut".equals(type) ? "充值退款" : "消费");
|
||||||
flow.setBizCode("inMoneyOut".equals(type)?"inMoneyOut":"consumeOut");
|
flow.setBizCode("inMoneyOut".equals(type) ? "inMoneyOut" : "consumeOut");
|
||||||
flow.setType("-");
|
flow.setType("-");
|
||||||
tbShopUser.setAmount(tbShopUser.getAmount().subtract(amount));
|
tbShopUser.setAmount(tbShopUser.getAmount().subtract(amount));
|
||||||
}else {
|
} else {
|
||||||
throw new BadRequestException("错误的请求类型");
|
throw new BadRequestException("错误的请求类型");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,8 +257,6 @@ public class TbShopUserServiceImpl implements TbShopUserService {
|
|||||||
tbShopUserFlowMapper.insert(flow);
|
tbShopUserFlowMapper.insert(flow);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import java.math.BigDecimal;
|
|||||||
@Data
|
@Data
|
||||||
public class ShopUserInfoVo implements Serializable {
|
public class ShopUserInfoVo implements Serializable {
|
||||||
private Integer id;
|
private Integer id;
|
||||||
|
private Integer userId;
|
||||||
private String headImg;
|
private String headImg;
|
||||||
private String nickName;
|
private String nickName;
|
||||||
private Object sex;
|
private Object sex;
|
||||||
|
|||||||
Reference in New Issue
Block a user