From dc444e2ba2017fb8a476faf9448de9df335ea1c3 Mon Sep 17 00:00:00 2001 From: = <=> Date: Tue, 31 Aug 2021 23:05:58 +0800 Subject: [PATCH] =?UTF-8?q?'=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/HighUserCardController.java | 25 +++++++++++++++++-- .../cweb/controller/HighUserController.java | 10 +++++--- .../cweb/controller/pay/OrderController.java | 2 +- .../main/java/com/hai/model/UserModel.java | 19 ++++++++++++++ .../com/hai/service/HighUserCardService.java | 7 ++++++ .../service/impl/HighOrderServiceImpl.java | 10 ++++---- .../service/impl/HighUserCardServiceImpl.java | 11 ++++++++ 7 files changed, 72 insertions(+), 12 deletions(-) diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighUserCardController.java b/hai-cweb/src/main/java/com/cweb/controller/HighUserCardController.java index 84ee6b67..50c05130 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighUserCardController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighUserCardController.java @@ -10,11 +10,14 @@ import com.hai.common.security.UserCenter; import com.hai.common.utils.RedisUtil; import com.hai.common.utils.ResponseMsgUtil; import com.hai.config.HuiLianTongUnionCardConfig; +import com.hai.entity.HighUser; import com.hai.entity.HighUserCard; import com.hai.enum_type.UserCardType; import com.hai.model.HighUserModel; import com.hai.model.ResponseData; import com.hai.service.HighUserCardService; +import com.hai.service.HighUserPayPasswordService; +import com.hai.service.HighUserService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; @@ -45,6 +48,11 @@ public class HighUserCardController { @Resource private RedisUtil redisUtil; + @Resource + private HighUserService highUserService; + + @Resource + private HighUserPayPasswordService highUserPayPasswordService; @RequestMapping(value = "/getUserCardList", method = RequestMethod.GET) @ResponseBody @@ -125,7 +133,11 @@ public class HighUserCardController { SessionObject sessionObject = userCenter.getSessionObject(request); HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); - if (highUserCardService.getDetailByUserCardNo(userInfoModel.getHighUser().getId(), body.getString("cardNo")) == null) { + if (highUserCardService.isBindHtlCard(userInfoModel.getHighUser().getId()) == true) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "绑定失败!只能绑定一张工会卡"); + } + + if (highUserCardService.getDetailByUserCardNo(userInfoModel.getHighUser().getId(), body.getString("cardNo")) != null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已绑定此卡,请勿重复绑定"); } @@ -142,7 +154,16 @@ public class HighUserCardController { highUserCardService.editCard(userCard); redisUtil.del(body.getString("phone")); - return ResponseMsgUtil.success("操作成功"); + + // 定义个人所有数据 + HighUser user = highUserService.findByUserId(userInfoModel.getHighUser().getId()); + HighUserModel highUserModel = new HighUserModel(); + user.setPassword(null); + user.setIsSetPayPwd(highUserPayPasswordService.isSetPayPwd(user.getId())); + user.setIsSetHltCard(highUserCardService.isBindHtlCard(user.getId())); + highUserModel.setHighUser(user); + SessionObject so = new SessionObject(user.getUnionId(), 1 , highUserModel); + return ResponseMsgUtil.success(so); } throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "验证码错误"); diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighUserController.java b/hai-cweb/src/main/java/com/cweb/controller/HighUserController.java index 01a4c244..f2401946 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighUserController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighUserController.java @@ -12,10 +12,7 @@ import com.hai.entity.HighUserCoupon; import com.hai.entity.HighUserPayPassword; import com.hai.model.HighUserModel; import com.hai.model.ResponseData; -import com.hai.service.HighOrderService; -import com.hai.service.HighUserCouponService; -import com.hai.service.HighUserPayPasswordService; -import com.hai.service.HighUserService; +import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.apache.commons.lang3.StringUtils; @@ -51,6 +48,9 @@ public class HighUserController { @Resource private HighUserCouponService highUserCouponService; + @Resource + private HighUserCardService highUserCardService; + @Resource private HighOrderService highOrderService; @@ -72,6 +72,7 @@ public class HighUserController { highUser.setUnpaid(highOrderService.countOrderByUserId(highUser.getId() , 1)); highUser.setUnusedDiscount(highOrderService.countUnusedDiscountByUserId(highUser.getId() , 1)); highUser.setIsSetPayPwd(highUserPayPasswordService.isSetPayPwd(userInfoModel.getHighUser().getId())); + highUser.setIsSetHltCard(highUserCardService.isBindHtlCard(highUser.getId())); } return ResponseMsgUtil.success(highUser); @@ -162,6 +163,7 @@ public class HighUserController { HighUserModel highUserModel = new HighUserModel(); user.setPassword(null); user.setIsSetPayPwd(highUserPayPasswordService.isSetPayPwd(user.getId())); + user.setIsSetHltCard(highUserCardService.isBindHtlCard(user.getId())); highUserModel.setHighUser(user); SessionObject so = new SessionObject(user.getUnionId(), 1 , highUserModel); return ResponseMsgUtil.success(so); diff --git a/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java b/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java index 5bd580bf..0c0d85e8 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java @@ -313,7 +313,7 @@ public class OrderController { } // 查询用户与卡号的关系 - HighUserCard userCard = highUserCardService.getDetailByUserCardNo(1L, cardNo); + HighUserCard userCard = highUserCardService.getDetailByUserCardNo(userInfoModel.getHighUser().getId(), cardNo); if (userCard == null) { log.error("OrderController --> orderToPay() ERROR", "未绑定卡号"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未绑定卡号"); diff --git a/hai-service/src/main/java/com/hai/model/UserModel.java b/hai-service/src/main/java/com/hai/model/UserModel.java index 490b42ba..555f900b 100644 --- a/hai-service/src/main/java/com/hai/model/UserModel.java +++ b/hai-service/src/main/java/com/hai/model/UserModel.java @@ -19,6 +19,9 @@ public class UserModel { // 是否设置支付密码 private Boolean isSetPayPwd; + // 是否绑定汇联通工会卡 + private Boolean isSetHltCard; + public Integer getUnusedCouponNum() { return unusedCouponNum; } @@ -50,4 +53,20 @@ public class UserModel { public void setIsSetPayPwd(Boolean setPayPwd) { isSetPayPwd = setPayPwd; } + + public Boolean getSetPayPwd() { + return isSetPayPwd; + } + + public void setSetPayPwd(Boolean setPayPwd) { + isSetPayPwd = setPayPwd; + } + + public Boolean getIsSetHltCard() { + return isSetHltCard; + } + + public void setIsSetHltCard(Boolean setHltCard) { + isSetHltCard = setHltCard; + } } diff --git a/hai-service/src/main/java/com/hai/service/HighUserCardService.java b/hai-service/src/main/java/com/hai/service/HighUserCardService.java index 7ba4953d..cc1ca75a 100644 --- a/hai-service/src/main/java/com/hai/service/HighUserCardService.java +++ b/hai-service/src/main/java/com/hai/service/HighUserCardService.java @@ -36,4 +36,11 @@ public interface HighUserCardService { */ HighUserCard getDetailByUserCardNo(Long userId,String codeNo); + /** + * 是否绑定汇联通工会卡 + * @param userId + * @return + */ + Boolean isBindHtlCard(Long userId); + } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java index 9108ca36..38baf321 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java @@ -337,10 +337,6 @@ public class HighOrderServiceImpl implements HighOrderService { // 商品类型 商品类型 1:卡卷 2:金币充值 if (highChildOrder.getGoodsType() == 1) { highChildOrder.setChildOrdeStatus(2); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 - HighCouponCode code = highCouponCodeService.getCouponCodeByOrderId(highChildOrder.getId()); - code.setStatus(2); // 状态:1.待销售 2.未使用 3.已使用 99.预支付 - code.setReceiveTime(new Date()); - highCouponCodeService.updateCouponCode(code); HighCoupon coupon = highCouponService.getCouponById(highChildOrder.getGoodsId()); // 贵州中石化 @@ -350,7 +346,6 @@ public class HighOrderServiceImpl implements HighOrderService { if (!tokenObject.getString("result").equals("success")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取token失败"); } - Map push = new HashMap<>(); push.put("token", "data"); push.put("couTypeCode", coupon.getCouponKey()); @@ -399,6 +394,11 @@ public class HighOrderServiceImpl implements HighOrderService { highGasOrderPushMapper.insert(highGasOrderPush); } else { + HighCouponCode code = highCouponCodeService.getCouponCodeByOrderId(highChildOrder.getId()); + code.setStatus(2); // 状态:1.待销售 2.未使用 3.已使用 99.预支付 + code.setReceiveTime(new Date()); + highCouponCodeService.updateCouponCode(code); + // 卡卷关联用户 HighUserCoupon highUserCoupon = new HighUserCoupon(); highUserCoupon.setMerchantId(code.getMerchantId()); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighUserCardServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighUserCardServiceImpl.java index dee42d00..7b5f1ee5 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighUserCardServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighUserCardServiceImpl.java @@ -55,4 +55,15 @@ public class HighUserCardServiceImpl implements HighUserCardService { } return null; } + + @Override + public Boolean isBindHtlCard(Long userId) { + HighUserCardExample example = new HighUserCardExample(); + example.createCriteria().andUserIdEqualTo(userId).andStatusNotEqualTo(0); + List list = highUserCardMapper.selectByExample(example); + if (list.size() > 0) { + return true; + } + return false; + } }