parent
4691fa8c31
commit
1d4963c548
|
|
@ -82,8 +82,8 @@ public class UserContoller {
|
|||
// return jsonObject;
|
||||
// }
|
||||
@GetMapping("/shopUserInfo")
|
||||
public Result shopUserInfo(@RequestParam("userId") String userId ,@RequestHeader("openId") String openId,@RequestParam("shopId") String shopId ) throws Exception {
|
||||
TbShopUser shopUser=new TbShopUser();
|
||||
public Result shopUserInfo(@RequestParam("userId") String userId, @RequestHeader("openId") String openId, @RequestParam("shopId") String shopId) throws Exception {
|
||||
TbShopUser shopUser = new TbShopUser();
|
||||
TbShopInfo tbShopInfo = shopInfoMapper.selectByPrimaryKey(Integer.valueOf(shopId));
|
||||
if (StringUtils.isNotBlank(shopId) && !shopId.equals("null")) {
|
||||
shopUser = shopUserMapper.selectByUserIdAndShopId(userId, shopId);
|
||||
|
|
@ -91,73 +91,77 @@ public class UserContoller {
|
|||
TbUserInfo tbUserInfo = userInfoMapper.selectByPrimaryKey(Integer.valueOf(userId));
|
||||
// shopUser = shopUserMapper.selectByPhoneAndShopId(tbUserInfo.getTelephone(), shopId);
|
||||
// if(ObjectUtil.isEmpty(shopUser)){
|
||||
shopUser=new TbShopUser();
|
||||
shopUser.setName(tbUserInfo.getNickName());
|
||||
shopUser.setSex(tbUserInfo.getSex());
|
||||
shopUser.setBirthDay(tbUserInfo.getBirthDay());
|
||||
shopUser.setLevel(Byte.parseByte("1"));
|
||||
String dynamicCode = RandomUtil.randomNumbers(8);
|
||||
shopUser.setCode(dynamicCode);
|
||||
shopUser.setTelephone(tbUserInfo.getTelephone());
|
||||
shopUser.setAmount(BigDecimal.ZERO);
|
||||
shopUser.setIsVip(Byte.parseByte("0"));
|
||||
shopUser.setCreditAmount(BigDecimal.ZERO);
|
||||
shopUser.setConsumeAmount(BigDecimal.ZERO);
|
||||
shopUser.setConsumeNumber(0);
|
||||
shopUser.setLevelConsume(BigDecimal.ZERO);
|
||||
shopUser.setStatus(Byte.parseByte("1"));
|
||||
shopUser.setShopId(shopId);
|
||||
shopUser.setUserId(userId);
|
||||
shopUser.setMiniOpenId(openId);
|
||||
shopUser.setCreatedAt(System.currentTimeMillis());
|
||||
shopUser.setUpdatedAt(System.currentTimeMillis());
|
||||
shopUserMapper.insert(shopUser);
|
||||
shopUser = new TbShopUser();
|
||||
shopUser.setName(tbUserInfo.getNickName());
|
||||
shopUser.setSex(tbUserInfo.getSex());
|
||||
shopUser.setBirthDay(tbUserInfo.getBirthDay());
|
||||
shopUser.setLevel(Byte.parseByte("1"));
|
||||
String dynamicCode = RandomUtil.randomNumbers(8);
|
||||
shopUser.setCode(dynamicCode);
|
||||
shopUser.setTelephone(tbUserInfo.getTelephone());
|
||||
shopUser.setAmount(BigDecimal.ZERO);
|
||||
shopUser.setIsVip(Byte.parseByte("0"));
|
||||
shopUser.setCreditAmount(BigDecimal.ZERO);
|
||||
shopUser.setConsumeAmount(BigDecimal.ZERO);
|
||||
shopUser.setConsumeNumber(0);
|
||||
shopUser.setLevelConsume(BigDecimal.ZERO);
|
||||
shopUser.setStatus(Byte.parseByte("1"));
|
||||
shopUser.setShopId(shopId);
|
||||
shopUser.setUserId(userId);
|
||||
shopUser.setMiniOpenId(openId);
|
||||
shopUser.setCreatedAt(System.currentTimeMillis());
|
||||
shopUser.setUpdatedAt(System.currentTimeMillis());
|
||||
shopUserMapper.insert(shopUser);
|
||||
// }else {
|
||||
// shopUser.setUserId(userId);
|
||||
// shopUser.setUpdatedAt(System.currentTimeMillis());
|
||||
// shopUserMapper.updateByPrimaryKey(shopUser);
|
||||
// }
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
shopUser.setAmount(BigDecimal.ZERO);
|
||||
}
|
||||
shopUser.setShopName(tbShopInfo.getShopName());
|
||||
return Result.success(CodeEnum.SUCCESS,shopUser);
|
||||
if (tbShopInfo != null) {
|
||||
shopUser.setShopName(tbShopInfo.getShopName());
|
||||
}else {
|
||||
shopUser.setShopName("");
|
||||
}
|
||||
return Result.success(CodeEnum.SUCCESS, shopUser);
|
||||
}
|
||||
|
||||
@GetMapping("/userCoupon")
|
||||
public Result userCoupon(@RequestParam("userId") String userId ,@RequestParam("orderNum") BigDecimal orderNum ) throws Exception {
|
||||
int num = userService.userCoupon(userId,orderNum);
|
||||
return Result.success(CodeEnum.SUCCESS,num);
|
||||
public Result userCoupon(@RequestParam("userId") String userId, @RequestParam("orderNum") BigDecimal orderNum) throws Exception {
|
||||
int num = userService.userCoupon(userId, orderNum);
|
||||
return Result.success(CodeEnum.SUCCESS, num);
|
||||
}
|
||||
|
||||
@PostMapping("/modityIntegral")
|
||||
public JSONObject modityIntegral(@RequestHeader String token,@RequestBody IntegralVo integralVo ) throws Exception {
|
||||
public JSONObject modityIntegral(@RequestHeader String token, @RequestBody IntegralVo integralVo) throws Exception {
|
||||
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
|
||||
String userSign = jsonObject.getString("userSign");
|
||||
return userService.modityIntegral(integralVo,userSign);
|
||||
return userService.modityIntegral(integralVo, userSign);
|
||||
}
|
||||
|
||||
@PostMapping("/userIntegral")
|
||||
public JSONObject userIntegral(@RequestHeader String token,@RequestBody IntegralFlowVo integralFlowVo ) throws Exception {
|
||||
public JSONObject userIntegral(@RequestHeader String token, @RequestBody IntegralFlowVo integralFlowVo) throws Exception {
|
||||
JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
|
||||
String userSign = jsonObject.getString("userSign");
|
||||
return userService.userIntegral(integralFlowVo,userSign);
|
||||
return userService.userIntegral(integralFlowVo, userSign);
|
||||
}
|
||||
|
||||
@PostMapping("/userAllIntegral")
|
||||
public JSONObject userAllIntegral(@RequestBody IntegralFlowVo integralFlowVo ) throws Exception {
|
||||
public JSONObject userAllIntegral(@RequestBody IntegralFlowVo integralFlowVo) throws Exception {
|
||||
// JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
|
||||
// String userSign = jsonObject.getString("userSign");
|
||||
return userService.userAllIntegral(integralFlowVo,"userSign");
|
||||
return userService.userAllIntegral(integralFlowVo, "userSign");
|
||||
}
|
||||
|
||||
@PostMapping("/userAll")
|
||||
public JSONObject userAll(@RequestBody IntegralFlowVo integralFlowVo ) throws Exception {
|
||||
public JSONObject userAll(@RequestBody IntegralFlowVo integralFlowVo) throws Exception {
|
||||
// JSONObject jsonObject = TokenUtil.parseParamFromToken(token);
|
||||
// String userSign = jsonObject.getString("userSign");
|
||||
return userService.userAll(integralFlowVo,"userSign");
|
||||
return userService.userAll(integralFlowVo, "userSign");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ public interface TbShopUserMapper {
|
|||
|
||||
TbShopUser selectByUserIdAndShopId(@Param("userId") String userId,@Param("shopId") String shopId);
|
||||
TbShopUser selectByPhoneAndShopId(@Param("phone") String phone,@Param("shopId") String shopId);
|
||||
TbShopUser selectPCByPhoneAndShopId(@Param("phone") String phone,@Param("shopId") String shopId);
|
||||
List<TbShopUser> selectAllByUserId(@Param("userId") String userId);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -359,7 +359,7 @@ public class CartService {
|
|||
if (cashierCart.getSkuId().equals(skuId)) {
|
||||
cashierCart.setTotalNumber(cashierCart.getTotalNumber() + buyNum);
|
||||
cashierCart.setNumber(cashierCart.getNumber() + buyNum);
|
||||
if (buyNum < 0 && tbProductSkuWithBLOBs.getSuit() != null && tbProductSkuWithBLOBs.getSuit() > 1 && cashierCart.getNumber() <= tbProductSkuWithBLOBs.getSuit()) {
|
||||
if (buyNum < 0 && tbProductSkuWithBLOBs.getSuit() != null && tbProductSkuWithBLOBs.getSuit() > 1 && cashierCart.getNumber() < tbProductSkuWithBLOBs.getSuit()) {
|
||||
cashierCartMapper.deleteByPrimaryKey(cashierCart.getId());
|
||||
continue;
|
||||
}
|
||||
|
|
@ -502,18 +502,27 @@ public class CartService {
|
|||
}
|
||||
TbCashierCart cashierCart = new TbCashierCart();
|
||||
if (productSku.getSuit() != null && productSku.getSuit() > 1) {
|
||||
if (productSku.getSuit() > productSku.getStockNumber()) {
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "fail");
|
||||
jsonObject1.put("msg", "该商品" + productSku.getSuit() + "起售,现库存不足");
|
||||
jsonObject1.put("data", new ArrayList<>());
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, userId.toString(), true);
|
||||
log.error("购物车添加商品异常,该商品起售库存不足:{}", productId);
|
||||
throw new MsgException("该商品起售库存不足");
|
||||
if (product.getIsStock() == 1) {
|
||||
boolean isSale = false;
|
||||
// 1:共享库存 0:独立库存
|
||||
if (Integer.valueOf(product.getIsDistribute()).equals(1)) {
|
||||
if (productSku.getSuit() > product.getStockNumber()) isSale = true;
|
||||
} else {
|
||||
if (productSku.getSuit() > productSku.getStockNumber()) isSale = true;
|
||||
}
|
||||
if (isSale) {
|
||||
JSONObject jsonObject1 = new JSONObject();
|
||||
jsonObject1.put("status", "fail");
|
||||
jsonObject1.put("msg", "该商品库存不足");
|
||||
jsonObject1.put("data", new ArrayList<>());
|
||||
PushToAppChannelHandlerAdapter.getInstance().AppSendInfo(jsonObject1.toString(), key, userId.toString(), true);
|
||||
log.error("购物车添加商品异常,该商品起售库存不足:{}", productId);
|
||||
throw new MsgException("该商品起售库存不足");
|
||||
}
|
||||
}
|
||||
cashierCart.setNumber(productSku.getSuit());
|
||||
cashierCart.setTotalNumber(productSku.getSuit());
|
||||
}else {
|
||||
} else {
|
||||
cashierCart.setNumber(num);
|
||||
cashierCart.setTotalNumber(num);
|
||||
}
|
||||
|
|
@ -558,6 +567,7 @@ public class CartService {
|
|||
try {
|
||||
String shopId = jsonObject.getString("shopId");
|
||||
String tableId = jsonObject.getString("tableId");
|
||||
String remark = StringUtils.isBlank(jsonObject.getString("remark"))?"":jsonObject.getString("remark");
|
||||
String key = tableId + "-" + shopId;
|
||||
JSONArray array = JSON.parseArray(redisUtil.getMessage(RedisCst.TABLE_CART.concat(jsonObject.getString("tableId").concat("-").concat(shopId))));
|
||||
List<Integer> ids = new ArrayList<>();
|
||||
|
|
@ -752,7 +762,7 @@ public class CartService {
|
|||
orderInfo.setProductAmount(saleAmount);
|
||||
orderInfo.setIsBuyCoupon(isBuyYhq);
|
||||
orderInfo.setIsUseCoupon(isuseYhq);
|
||||
// orderInfo.setRemark(StringUtils.isBlank(jsonObject.getString("remark"))?"":jsonObject.getString("remark"));
|
||||
orderInfo.setRemark(remark);
|
||||
orderInfoMapper.updateByPrimaryKeySelective(orderInfo);
|
||||
|
||||
} else {
|
||||
|
|
@ -763,6 +773,7 @@ public class CartService {
|
|||
orderInfo.setIsBuyCoupon(isBuyYhq);
|
||||
orderInfo.setIsUseCoupon(isuseYhq);
|
||||
orderInfo.setUserCouponAmount(couponAmount);
|
||||
orderInfo.setRemark(remark);
|
||||
|
||||
JSONObject object = new JSONObject();
|
||||
String outNumber = redisUtil.getMessage(RedisCst.OUT_NUMBER.concat(jsonObject.getString("shopId")));
|
||||
|
|
|
|||
|
|
@ -119,9 +119,6 @@ public class LoginService {
|
|||
userInfo.setUpdatedAt(System.currentTimeMillis());
|
||||
tbUserInfoMapper.insert(userInfo);
|
||||
}else {
|
||||
userInfo.setHeadImg(ObjectUtil.isNotNull(headImage)?headImage:"");
|
||||
userInfo.setNickName(ObjectUtil.isNotNull(nickName)?nickName:"微信用户");
|
||||
userInfo.setTelephone(ObjectUtil.isNotNull(telephone)?telephone:"");
|
||||
userInfo.setUpdatedAt(System.currentTimeMillis());
|
||||
userInfo.setLastLogInAt(System.currentTimeMillis());
|
||||
tbUserInfoMapper.updateByPrimaryKeySelective(userInfo);
|
||||
|
|
|
|||
|
|
@ -51,6 +51,15 @@
|
|||
where telephone = #{phone,jdbcType=VARCHAR}
|
||||
</select>
|
||||
|
||||
<select id="selectByShopIdAndPhone" resultMap="BaseResultMap">
|
||||
select
|
||||
<include refid="Base_Column_List" />
|
||||
from tb_shop_user
|
||||
where
|
||||
shop_id=#{shopId}
|
||||
and telephone = #{phone,jdbcType=VARCHAR}
|
||||
</select>
|
||||
|
||||
<delete id="deleteByPrimaryKey" parameterType="java.lang.String">
|
||||
delete from tb_shop_user
|
||||
where id = #{id,jdbcType=VARCHAR}
|
||||
|
|
@ -397,6 +406,10 @@
|
|||
select * from tb_shop_user where telephone=#{phone} and shop_id=#{shopId}
|
||||
</select>
|
||||
|
||||
<select id="selectPCByPhoneAndShopId" resultMap="BaseResultMap">
|
||||
select * from tb_shop_user where telephone=#{phone} and shop_id=#{shopId} and user_id is null
|
||||
</select>
|
||||
|
||||
<select id="selectAllByUserId" resultMap="BaseResultMap">
|
||||
select * from tb_shop_user where user_id=#{userId}
|
||||
</select>
|
||||
|
|
|
|||
Loading…
Reference in New Issue