shopId为空时 余额为0

This commit is contained in:
2024-06-05 09:31:05 +08:00
parent b7ce764bdb
commit 4aa5bd33b1

View File

@@ -29,6 +29,7 @@ import com.chaozhanggui.system.cashierservice.util.TokenUtil;
import com.chaozhanggui.system.cashierservice.wxUtil.WechatUtil; import com.chaozhanggui.system.cashierservice.wxUtil.WechatUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.digest.DigestUtils; import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@@ -78,7 +79,9 @@ public class UserContoller {
// } // }
@GetMapping("/shopUserInfo") @GetMapping("/shopUserInfo")
public Result shopUserInfo(@RequestParam("userId") String userId ,@RequestHeader("openId") String openId,@RequestParam("shopId") String shopId ) throws Exception { public Result shopUserInfo(@RequestParam("userId") String userId ,@RequestHeader("openId") String openId,@RequestParam("shopId") String shopId ) throws Exception {
TbShopUser shopUser = shopUserMapper.selectByUserIdAndShopId(userId,shopId); TbShopUser shopUser=new TbShopUser();
if (StringUtils.isNotBlank(shopId)) {
shopUser = shopUserMapper.selectByUserIdAndShopId(userId, shopId);
if (ObjectUtil.isEmpty(shopUser)) { if (ObjectUtil.isEmpty(shopUser)) {
TbUserInfo tbUserInfo = userInfoMapper.selectByPrimaryKey(Integer.valueOf(userId)); TbUserInfo tbUserInfo = userInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
shopUser = new TbShopUser(); shopUser = new TbShopUser();
@@ -103,6 +106,9 @@ public class UserContoller {
shopUser.setUpdatedAt(System.currentTimeMillis()); shopUser.setUpdatedAt(System.currentTimeMillis());
shopUserMapper.insert(shopUser); shopUserMapper.insert(shopUser);
} }
}else {
shopUser.setAmount(BigDecimal.ZERO);
}
return Result.success(CodeEnum.SUCCESS,shopUser); return Result.success(CodeEnum.SUCCESS,shopUser);
} }