diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighOilCardController.java b/hai-bweb/src/main/java/com/bweb/controller/HighOilCardController.java index 32c17ba4..146d3628 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighOilCardController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighOilCardController.java @@ -10,11 +10,13 @@ import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.SysCode; import com.hai.common.security.AESEncodeUtil; import com.hai.common.security.UserCenter; +import com.hai.common.utils.DateUtil; import com.hai.common.utils.ResponseMsgUtil; import com.hai.entity.HighCompanyTwoPwd; import com.hai.entity.HighOilCard; import com.hai.enum_type.OilCardStatusEnum; import com.hai.enum_type.UserObjectTypeEnum; +import com.hai.model.OilCardOrderModel; import com.hai.model.ResponseData; import com.hai.model.TyOrderModel; import com.hai.model.UserInfoModel; @@ -312,6 +314,145 @@ public class HighOilCardController { } } + @RequestMapping(value = "/getCardOrderList", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询油卡订单列表") + public ResponseData getCardOrderList(@RequestParam(name = "orgId", required = false) Long orgId, + @RequestParam(name = "cardNo", required = false) String cardNo, + @RequestParam(name = "goodsName", required = false) String goodsName, + @RequestParam(name = "status", required = false) Integer status, + @RequestParam(name = "payTimeS", required = false) String payTimeS, + @RequestParam(name = "payTimeE", required = false) String payTimeE, + @RequestParam(name = "pageNum", required = true) Integer pageNum, + @RequestParam(name = "pageSize", required = true) Integer pageSize) { + try { + + UserInfoModel userModel = userCenter.getSessionModel(UserInfoModel.class); + + Map param = new HashMap<>(); + param.put("companyId", userModel.getBsCompany().getId()); + + if (userModel.getSecUser().getAdminFlag() != 1) { + param.put("orgId", userModel.getBsOrganization().getId()); + } else { + param.put("orgId", orgId); + } + param.put("status", status); + param.put("cardNo", cardNo); + param.put("goodsName", goodsName); + param.put("payTimeS", payTimeS); + param.put("payTimeE", payTimeE); + + PageHelper.startPage(pageNum, pageSize); + return ResponseMsgUtil.success(new PageInfo<>(oilCardService.getOilCardOrderList(param))); + + } catch (Exception e) { + log.error("HighOilCardController --> getCardOrderList() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/exportCardOrder", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "导出油卡订单") + public ResponseData exportCardOrder(@RequestParam(name = "orgId", required = false) Long orgId, + @RequestParam(name = "cardNo", required = false) String cardNo, + @RequestParam(name = "goodsName", required = false) String goodsName, + @RequestParam(name = "status", required = false) Integer status, + @RequestParam(name = "payTimeS", required = false) String payTimeS, + @RequestParam(name = "payTimeE", required = false) String payTimeE, + @RequestParam(name = "pageNum", required = true) Integer pageNum, + @RequestParam(name = "pageSize", required = true) Integer pageSize) { + try { + + UserInfoModel userModel = userCenter.getSessionModel(UserInfoModel.class); + + Map param = new HashMap<>(); + param.put("companyId", userModel.getBsCompany().getId()); + + if (userModel.getSecUser().getAdminFlag() != 1) { + param.put("orgId", userModel.getBsOrganization().getId()); + } else { + param.put("orgId", orgId); + } + param.put("status", status); + param.put("cardNo", cardNo); + param.put("goodsName", goodsName); + param.put("payTimeS", payTimeS); + param.put("payTimeE", payTimeE); + + List cardOrderList = oilCardService.getOilCardOrderList(param); + List headList = new ArrayList<>(); + + if (userModel.getSecUser().getAdminFlag() == 1) { + headList.add("所属部门"); + headList.add("用户手机号"); + } + headList.add("油卡卡号"); + headList.add("平台订单号"); + headList.add("团油订单号"); + headList.add("加油金额"); + headList.add("优惠金额"); + headList.add("实付金额"); + headList.add("加油站"); + headList.add("油号"); + headList.add("油枪号"); + headList.add("团油油枪价"); + headList.add("平台油枪价格"); + headList.add("订单状态"); + headList.add("创建时间"); + headList.add("支付时间"); + headList.add("退款时间"); + + List> dataList = new ArrayList<>(); + List data; + + for (OilCardOrderModel cardOrder: cardOrderList) { + data = new ArrayList<>(); + if (userModel.getSecUser().getAdminFlag() == 1) { + data.add(cardOrder.getOrgName()); + data.add(cardOrder.getMerPhone()); + } + data.add(cardOrder.getMemCardNo()); + data.add(cardOrder.getOrderNo()); + data.add(cardOrder.getGasOrderNo()); + data.add(cardOrder.getTotalPrice()); + data.add(cardOrder.getDeductionPrice()); + data.add(cardOrder.getPayRealPrice()); + data.add(cardOrder.getGoodsName()); + data.add(cardOrder.getGasOilNo()); + data.add(cardOrder.getGasGunNo()); + data.add(cardOrder.getGasPriceGun()); + data.add(cardOrder.getPlatformPriceGun()); + data.add(cardOrder.getStatusName()); + data.add(DateUtil.format(cardOrder.getCreateTime(), "yyyy-MM-dd HH:mm:ss")); + data.add(DateUtil.format(cardOrder.getPayTime(), "yyyy-MM-dd HH:mm:ss")); + if (cardOrder.getRefundTime() != null) { + data.add(DateUtil.format(cardOrder.getRefundTime(), "yyyy-MM-dd HH:mm:ss")); + } else { + data.add(""); + } + dataList.add(data); + } + + String fileUrl = SysConst.getSysConfig().getFileUrl() + "/temporary/"; + String pathName = System.currentTimeMillis()+".xlsx"; + File file = new File(fileUrl); + if (!file.exists()) { + file.mkdirs(); + } + EasyExcel.write(fileUrl+pathName).head(generationHead(headList)).sheet("油卡订单").doWrite(dataList); + + return ResponseMsgUtil.success(pathName); + + } catch (Exception e) { + log.error("HighOilCardController --> getCardOrderList() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + + /** * 生成头部 * @param headList diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighOilCardRecordController.java b/hai-bweb/src/main/java/com/bweb/controller/HighOilCardRecordController.java index 325573f5..e7f7d902 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighOilCardRecordController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighOilCardRecordController.java @@ -30,18 +30,20 @@ public class HighOilCardRecordController { @ResponseBody @ApiOperation(value = "查询油卡记录列表") public ResponseData getOilCardRecordList(@RequestParam(name = "cardNo", required = true) String cardNo, - @RequestParam(name = "type", required = false) Integer type, - @RequestParam(name = "sourceType", required = false) String sourceType, - @RequestParam(name = "createTimeS", required = false) Long createTimeS, - @RequestParam(name = "createTimeE", required = false) Long createTimeE, - @RequestParam(name = "pageNum", required = true) Integer pageNum, - @RequestParam(name = "pageSize", required = true) Integer pageSize) { + @RequestParam(name = "sourceOrderNo", required = false) String sourceOrderNo, + @RequestParam(name = "type", required = false) Integer type, + @RequestParam(name = "sourceType", required = false) String sourceType, + @RequestParam(name = "createTimeS", required = false) Long createTimeS, + @RequestParam(name = "createTimeE", required = false) Long createTimeE, + @RequestParam(name = "pageNum", required = true) Integer pageNum, + @RequestParam(name = "pageSize", required = true) Integer pageSize) { try { Map param = new HashMap<>(); param.put("cardNo", cardNo); param.put("type", type); param.put("sourceType", sourceType); + param.put("sourceOrderNo", sourceOrderNo); param.put("createTimeS", createTimeS); param.put("createTimeE", createTimeE); diff --git a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java index 4a974aed..8073e896 100644 --- a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java +++ b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java @@ -118,6 +118,7 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/highUser/delCacheParam") .excludePathPatterns("/order/orderToH5Pay") .excludePathPatterns("/order/orderToPay") + .excludePathPatterns("/highGas/oilPriceCompute") .excludePathPatterns("/cmsContent/*") .excludePathPatterns("/highGas/*") .excludePathPatterns("/wechat/*") diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java b/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java index 28aacba2..f01b08a4 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighGasController.java @@ -130,6 +130,20 @@ public class HighGasController { } } + @RequestMapping(value="/oilPriceCompute",method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "油价计算") + public ResponseData oilPriceCompute(@RequestParam(name = "price", required = true) BigDecimal price, + @RequestParam(name = "gasPriceGun", required = true) BigDecimal gasPriceGun, + @RequestParam(name = "gasPriceVip", required = true) BigDecimal gasPriceVip) { + try { + return ResponseMsgUtil.success(new BigDecimal(price.toString()).divide(gasPriceGun,10,BigDecimal.ROUND_DOWN).multiply(gasPriceVip).setScale(2,BigDecimal.ROUND_DOWN)); + } catch (Exception e) { + log.error("HighGasController -> oilPriceCompute() error!",e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value="/getGasDetailByStoreKey",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据门店key 查询") diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighOilCardController.java b/hai-cweb/src/main/java/com/cweb/controller/HighOilCardController.java new file mode 100644 index 00000000..a41e1b16 --- /dev/null +++ b/hai-cweb/src/main/java/com/cweb/controller/HighOilCardController.java @@ -0,0 +1,102 @@ +package com.cweb.controller; + +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; +import com.hai.common.security.UserCenter; +import com.hai.common.utils.ResponseMsgUtil; +import com.hai.entity.HighOilCard; +import com.hai.enum_type.OilCardStatusEnum; +import com.hai.model.ResponseData; +import com.hai.model.UserInfoModel; +import com.hai.service.HighCompanyTwoPwdService; +import com.hai.service.HighOilCardRecordService; +import com.hai.service.HighOilCardService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.util.HashMap; +import java.util.Map; + +@Controller +@RequestMapping(value = "/oilCard") +@Api(value = "油卡") +public class HighOilCardController { + + private static Logger log = LoggerFactory.getLogger(HighOilCardController.class); + + @Resource + private UserCenter userCenter; + + @Resource + private HighOilCardService oilCardService; + + @Resource + private HighOilCardRecordService oilCardRecordService; + + @RequestMapping(value = "/getDetailByCardNo", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "根据卡号查询详情") + public ResponseData getDetailByCardNo(@RequestParam(name = "cardNo", required = true) String cardNo) { + try { + // 查询油卡 + HighOilCard card = oilCardService.getOilCardByCardNo(cardNo); + if (card == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "卡号不正确"); + } + if (StringUtils.isBlank(card.getContactPhone())) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "油卡未配置完成"); + } + + Map map = new HashMap<>(); + map.put("cardNo", card.getCardNo()); + map.put("amount", card.getAmount()); + map.put("status", card.getStatus()); + map.put("contactName", card.getContactName()); + map.put("contactPhone", card.getContactPhone()); + return ResponseMsgUtil.success(map); + + } catch (Exception e) { + log.error("HighOilCardController --> getDetailByCardNo() error!", e); + return ResponseMsgUtil.exception(e); + } + } + + @RequestMapping(value = "/getOilCardRecordList", method = RequestMethod.GET) + @ResponseBody + @ApiOperation(value = "查询油卡记录列表") + public ResponseData getOilCardRecordList(@RequestParam(name = "cardNo", required = true) String cardNo, + @RequestParam(name = "sourceOrderNo", required = false) String sourceOrderNo, + @RequestParam(name = "type", required = false) Integer type, + @RequestParam(name = "sourceType", required = false) String sourceType, + @RequestParam(name = "createTimeS", required = false) Long createTimeS, + @RequestParam(name = "createTimeE", required = false) Long createTimeE, + @RequestParam(name = "pageNum", required = true) Integer pageNum, + @RequestParam(name = "pageSize", required = true) Integer pageSize) { + try { + + Map param = new HashMap<>(); + param.put("cardNo", cardNo); + param.put("sourceOrderNo", sourceOrderNo); + param.put("type", type); + param.put("sourceType", sourceType); + param.put("createTimeS", createTimeS); + param.put("createTimeE", createTimeE); + + PageHelper.startPage(pageNum, pageSize); + return ResponseMsgUtil.success(new PageInfo<>(oilCardRecordService.getRecordList(param))); + + } catch (Exception e) { + log.error("HighOilCardRecordController --> getOilCardRecordList() error!", e); + return ResponseMsgUtil.exception(e); + } + } +} diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java index 34f4299a..4d07c68b 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java @@ -261,7 +261,7 @@ public class HighOrderController { // 团油的价格 childOrder.setGasPriceGun(priceDetail.getBigDecimal("priceGun")); childOrder.setGasPriceVip(priceDetail.getBigDecimal("priceVip")); - childOrder.setGoodsPrice(new BigDecimal(childOrder.getGoodsPrice().toString()).divide(childOrder.getGasPriceGun(),10,BigDecimal.ROUND_DOWN).multiply(childOrder.getGasPriceVip()).setScale(2,BigDecimal.ROUND_HALF_UP)); + // childOrder.setGoodsPrice(new BigDecimal(childOrder.getGoodsPrice().toString()).divide(childOrder.getGasPriceGun(),10,BigDecimal.ROUND_DOWN).multiply(childOrder.getGasPriceVip()).setScale(2,BigDecimal.ROUND_HALF_UP)); childOrder.setGoodsSpecName("默认"); childOrder.setTotalPrice(childOrder.getGoodsPrice().multiply(new BigDecimal(childOrder.getSaleCount().toString()))); @@ -422,6 +422,7 @@ public class HighOrderController { } } + @RequestMapping(value = "/getOrderById", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "根据id查询订单详情") 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 94873a11..69616e69 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighUserCardController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighUserCardController.java @@ -20,6 +20,7 @@ import com.hai.service.HighUserPayPasswordService; import com.hai.service.HighUserService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; +import org.apache.catalina.User; import org.apache.commons.lang3.StringUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -54,6 +55,66 @@ public class HighUserCardController { @Resource private HighUserPayPasswordService highUserPayPasswordService; + @RequestMapping(value = "/bindCard", method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "绑卡") + public ResponseData bindCard(@RequestBody JSONObject body, HttpServletRequest request) { + try { + if (body == null + || body.getInteger("type") == null + || StringUtils.isBlank(body.getString("cardNo")) + || StringUtils.isBlank(body.getString("phone")) + || StringUtils.isBlank(body.getString("smsCode"))) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + + if (UserCardType.getNameByType(body.getInteger("type")) == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的卡片类型"); + } + // 用户 + HighUserModel userInfoModel = userCenter.getSessionModel(HighUserModel.class); + + if (body.getInteger("type").equals(UserCardType.type1.getType())) { + if (highUserCardService.isBindHtlCard(userInfoModel.getHighUser().getId()) == true) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "绑定失败!只能绑定一张工会卡"); + } + } else if (body.getInteger("type").equals(UserCardType.type2.getType())) { + if (highUserCardService.getListByUser(userInfoModel.getHighUser().getId(), UserCardType.type2.getType()).size() != 0) { + 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, "已绑定此卡,请勿重复绑定"); + } + + // 获取手机号验证码 + String phoneSmsCode = (String) redisUtil.get("SMS_"+body.getString("phone")); + + // 验证码校验 + if (StringUtils.isNotBlank(phoneSmsCode) && Objects.equals(phoneSmsCode,body.getString("smsCode"))) { + + // 绑定卡片 + highUserCardService.bindCard(body.getInteger("type"),body.getString("cardNo"),userInfoModel.getHighUser().getId()); + + redisUtil.del("SMS_"+body.getString("phone")); + + // 定义个人所有数据 + HighUserModel highUserModel = new HighUserModel(); + HighUser detailData = highUserService.getDetailDataByUser(userInfoModel.getHighUser().getId()); + detailData.setPassword(null); + highUserModel.setHighUser(detailData); + SessionObject so = new SessionObject(detailData.getPhone(), 1 , highUserModel); + return ResponseMsgUtil.success(so); + } + + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "验证码错误"); + + } catch (Exception e) { + log.error("HighUserCardController --> bindCard() error!", e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value = "/getUserCardList", method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取用户卡号列表") @@ -81,17 +142,12 @@ public class HighUserCardController { SessionObject sessionObject = userCenter.getSessionObject(request); HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); - HighUserCard card = highUserCardService.getDetailByUserCardNo(userInfoModel.getHighUser().getId(), body.getString("cardNo")); - if (card == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到数据"); - } - card.setStatus(0); - highUserCardService.editCard(card); + highUserCardService.delUserCard(body.getString("cardNo"), userInfoModel.getHighUser().getId()); return ResponseMsgUtil.success("操作成功"); } catch (Exception e) { - log.error("HighUserCardController --> delCard() error!", e); + log.error("HighUserCardController --> delUserCard() error!", e); return ResponseMsgUtil.exception(e); } } @@ -160,7 +216,7 @@ public class HighUserCardController { HighUser detailData = highUserService.getDetailDataByUser(userInfoModel.getHighUser().getId()); detailData.setPassword(null); highUserModel.setHighUser(detailData); - SessionObject so = new SessionObject(detailData.getUnionId(), 1 , highUserModel); + SessionObject so = new SessionObject(detailData.getPhone(), 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/pay/OrderController.java b/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java index 081deb3e..a725c6cd 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 @@ -337,6 +337,109 @@ public class OrderController { } } + @RequestMapping(value="/oilCardPay",method = RequestMethod.POST) + @ResponseBody + @ApiOperation(value = "油卡支付") + public ResponseData oilCardPay(@RequestBody String reqBodyStr,HttpServletRequest request) { + try { + // 用户 + SessionObject sessionObject = userCenter.getSessionObject(request); + HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); + + if (StringUtils.isBlank(reqBodyStr)) { + log.error("orderToPay error!", "参数错误"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + JSONObject jsonObject = JSONObject.parseObject(reqBodyStr); + String cardNo = jsonObject.getString("cardNo"); + Long orderId = jsonObject.getLong("orderId"); + String password = jsonObject.getString("password"); + + if (StringUtils.isBlank(cardNo) || orderId == null) { + log.error("orderToPay error!", "参数错误"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } + // 查询用户支付密码 + HighUserPayPassword userPayPassword = highUserPayPasswordService.getDetailByUser(userInfoModel.getHighUser().getId()); + if (userPayPassword == null) { + log.error("orderToPay error!", "未设置支付密码"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_SET_USER_PAY_PWD, ""); + } + if (StringUtils.isBlank(password)) { + log.error("orderToPay error!", "未输入支付密码"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_ENTER_USER_PAY_PWD, ""); + } + // 校验支付密码是否一直 + if (!AESEncodeUtil.aesEncrypt(password).equals(userPayPassword.getPassword())) { + log.error("orderToPay error!", ""); + throw ErrorHelp.genException(SysCode.System, ErrorCode.USER_PAY_PWD_ERROR, ""); + } + + // 查询用户与卡号的关系 + HighUserCard userCard = highUserCardService.getDetailByUserCardNo(userInfoModel.getHighUser().getId(), cardNo); + if (userCard == null) { + log.error("OrderController --> orderToPay() ERROR", "未绑定卡号"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未绑定卡号"); + } + HighOrder order = highOrderService.getOrderById(orderId); + if(order == null) { + log.error("OrderController --> orderToPay() ERROR", "未找到订单信息"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, ""); + } + //校验订单状态 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 + if(order.getOrderStatus() != 1) { + log.error("OrderController --> orderToPay() ERROR", "订单不处于待支付状态"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.ORDER_NO_STAY_PAY, ""); + } + + // 商品类型 1:卡卷 2:金币充值 + for (HighChildOrder childOrder : order.getHighChildOrderList()) { + if (childOrder.getGoodsType() == 3) { + if (highOrderService.getGasTheDayOrderNum(order.getMemId()) >= 1) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已达到每日加油次数上限"); + } + // 查询账号余额 + JSONObject accountInfo2JD = TuanYouConfig.queryCompanyAccountInfo2JD(); + JSONArray result = accountInfo2JD.getJSONArray("result"); + for (Object accountObject : result) { + JSONObject account = (JSONObject)accountObject; + // 1:汽油:2:柴油;3:天然气 + if (account.getInteger("energyType") == childOrder.getGasOilType()) { + // 支付金额 大于 团油账号余额 + if(order.getPayPrice().compareTo(account.getBigDecimal("accountBalance")) == 1){ + log.error("OrderController --> orderToPay() ERROR", "无法进行支付,请联系平台客服"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法进行支付,请联系平台客服"); + } + } + } + } + } + + highOrderService.oilCardPayOrder(userCard.getId(), order.getId()); + + new Thread(() -> { + // 查询订单信息 + if (order == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, ""); + } + HighUser highUser = highUserService.findByUserId(order.getMemId()); + HighChildOrder presentation = highOrderService.getChildOrderByPresentation(order.getId()); + WxMsgConfig.pushOneUser( + presentation.getGoodsName() + "(" + GoodsType.getNameByType(presentation.getGoodsType()) + ")", + String.valueOf(order.getPayPrice()), + order.getOrderNo(), + order.getPayTime(), + PayType.getNameByType(order.getPayType()), order.getId(), + highUser.getOpenId()); + }).start(); + + return ResponseMsgUtil.success("支付成功"); + } catch (Exception e) { + log.error("orderToPay error!", e); + return ResponseMsgUtil.exception(e); + } + } + @RequestMapping(value="/hltUnionCardPay",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "汇联通工会卡支付") diff --git a/hai-service/src/main/java/com/hai/dao/HighOilCardMapperExt.java b/hai-service/src/main/java/com/hai/dao/HighOilCardMapperExt.java index c5c3767b..fb75a354 100644 --- a/hai-service/src/main/java/com/hai/dao/HighOilCardMapperExt.java +++ b/hai-service/src/main/java/com/hai/dao/HighOilCardMapperExt.java @@ -1,10 +1,13 @@ package com.hai.dao; import com.hai.entity.HighOilCard; +import com.hai.model.OilCardOrderModel; import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; import java.util.List; +import java.util.Map; /** * mapper扩展类 @@ -57,4 +60,67 @@ public interface HighOilCardMapperExt { }) void insertList(@Param(value = "list") List oilCardList); + @Select("") + List selectOilCardOrderList(@Param(value = "param") Map param); + } diff --git a/hai-service/src/main/java/com/hai/dao/HighOilCardRecordMapper.java b/hai-service/src/main/java/com/hai/dao/HighOilCardRecordMapper.java index 4e60776f..754cfe3b 100644 --- a/hai-service/src/main/java/com/hai/dao/HighOilCardRecordMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighOilCardRecordMapper.java @@ -42,17 +42,19 @@ public interface HighOilCardRecordMapper extends HighOilCardRecordMapperExt { "insert into high_oil_card_record (oil_card_id, card_no, ", "`type`, amount, before_amount, ", "after_amount, source_type, ", - "source_id, source_content, ", - "`status`, create_time, ", - "op_user_id, op_user_name, ", - "ext_1, ext_2, ext_3)", + "source_id, source_order_no, ", + "source_content, `status`, ", + "create_time, op_user_id, ", + "op_user_name, ext_1, ", + "ext_2, ext_3)", "values (#{oilCardId,jdbcType=BIGINT}, #{cardNo,jdbcType=VARCHAR}, ", "#{type,jdbcType=INTEGER}, #{amount,jdbcType=DECIMAL}, #{beforeAmount,jdbcType=DECIMAL}, ", "#{afterAmount,jdbcType=DECIMAL}, #{sourceType,jdbcType=INTEGER}, ", - "#{sourceId,jdbcType=BIGINT}, #{sourceContent,jdbcType=VARCHAR}, ", - "#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ", - "#{opUserId,jdbcType=BIGINT}, #{opUserName,jdbcType=VARCHAR}, ", - "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" + "#{sourceId,jdbcType=BIGINT}, #{sourceOrderNo,jdbcType=VARCHAR}, ", + "#{sourceContent,jdbcType=VARCHAR}, #{status,jdbcType=INTEGER}, ", + "#{createTime,jdbcType=TIMESTAMP}, #{opUserId,jdbcType=BIGINT}, ", + "#{opUserName,jdbcType=VARCHAR}, #{ext1,jdbcType=VARCHAR}, ", + "#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR})" }) @Options(useGeneratedKeys=true,keyProperty="id") int insert(HighOilCardRecord record); @@ -72,6 +74,7 @@ public interface HighOilCardRecordMapper extends HighOilCardRecordMapperExt { @Result(column="after_amount", property="afterAmount", jdbcType=JdbcType.DECIMAL), @Result(column="source_type", property="sourceType", jdbcType=JdbcType.INTEGER), @Result(column="source_id", property="sourceId", jdbcType=JdbcType.BIGINT), + @Result(column="source_order_no", property="sourceOrderNo", jdbcType=JdbcType.VARCHAR), @Result(column="source_content", property="sourceContent", jdbcType=JdbcType.VARCHAR), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @@ -86,8 +89,8 @@ public interface HighOilCardRecordMapper extends HighOilCardRecordMapperExt { @Select({ "select", "id, oil_card_id, card_no, `type`, amount, before_amount, after_amount, source_type, ", - "source_id, source_content, `status`, create_time, op_user_id, op_user_name, ", - "ext_1, ext_2, ext_3", + "source_id, source_order_no, source_content, `status`, create_time, op_user_id, ", + "op_user_name, ext_1, ext_2, ext_3", "from high_oil_card_record", "where id = #{id,jdbcType=BIGINT}" }) @@ -101,6 +104,7 @@ public interface HighOilCardRecordMapper extends HighOilCardRecordMapperExt { @Result(column="after_amount", property="afterAmount", jdbcType=JdbcType.DECIMAL), @Result(column="source_type", property="sourceType", jdbcType=JdbcType.INTEGER), @Result(column="source_id", property="sourceId", jdbcType=JdbcType.BIGINT), + @Result(column="source_order_no", property="sourceOrderNo", jdbcType=JdbcType.VARCHAR), @Result(column="source_content", property="sourceContent", jdbcType=JdbcType.VARCHAR), @Result(column="status", property="status", jdbcType=JdbcType.INTEGER), @Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP), @@ -131,6 +135,7 @@ public interface HighOilCardRecordMapper extends HighOilCardRecordMapperExt { "after_amount = #{afterAmount,jdbcType=DECIMAL},", "source_type = #{sourceType,jdbcType=INTEGER},", "source_id = #{sourceId,jdbcType=BIGINT},", + "source_order_no = #{sourceOrderNo,jdbcType=VARCHAR},", "source_content = #{sourceContent,jdbcType=VARCHAR},", "`status` = #{status,jdbcType=INTEGER},", "create_time = #{createTime,jdbcType=TIMESTAMP},", diff --git a/hai-service/src/main/java/com/hai/dao/HighOilCardRecordSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighOilCardRecordSqlProvider.java index 70e5ce48..2dc45fb5 100644 --- a/hai-service/src/main/java/com/hai/dao/HighOilCardRecordSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighOilCardRecordSqlProvider.java @@ -60,6 +60,10 @@ public class HighOilCardRecordSqlProvider { sql.VALUES("source_id", "#{sourceId,jdbcType=BIGINT}"); } + if (record.getSourceOrderNo() != null) { + sql.VALUES("source_order_no", "#{sourceOrderNo,jdbcType=VARCHAR}"); + } + if (record.getSourceContent() != null) { sql.VALUES("source_content", "#{sourceContent,jdbcType=VARCHAR}"); } @@ -110,6 +114,7 @@ public class HighOilCardRecordSqlProvider { sql.SELECT("after_amount"); sql.SELECT("source_type"); sql.SELECT("source_id"); + sql.SELECT("source_order_no"); sql.SELECT("source_content"); sql.SELECT("`status`"); sql.SELECT("create_time"); @@ -171,6 +176,10 @@ public class HighOilCardRecordSqlProvider { sql.SET("source_id = #{record.sourceId,jdbcType=BIGINT}"); } + if (record.getSourceOrderNo() != null) { + sql.SET("source_order_no = #{record.sourceOrderNo,jdbcType=VARCHAR}"); + } + if (record.getSourceContent() != null) { sql.SET("source_content = #{record.sourceContent,jdbcType=VARCHAR}"); } @@ -220,6 +229,7 @@ public class HighOilCardRecordSqlProvider { sql.SET("after_amount = #{record.afterAmount,jdbcType=DECIMAL}"); sql.SET("source_type = #{record.sourceType,jdbcType=INTEGER}"); sql.SET("source_id = #{record.sourceId,jdbcType=BIGINT}"); + sql.SET("source_order_no = #{record.sourceOrderNo,jdbcType=VARCHAR}"); sql.SET("source_content = #{record.sourceContent,jdbcType=VARCHAR}"); sql.SET("`status` = #{record.status,jdbcType=INTEGER}"); sql.SET("create_time = #{record.createTime,jdbcType=TIMESTAMP}"); @@ -270,6 +280,10 @@ public class HighOilCardRecordSqlProvider { sql.SET("source_id = #{sourceId,jdbcType=BIGINT}"); } + if (record.getSourceOrderNo() != null) { + sql.SET("source_order_no = #{sourceOrderNo,jdbcType=VARCHAR}"); + } + if (record.getSourceContent() != null) { sql.SET("source_content = #{sourceContent,jdbcType=VARCHAR}"); } diff --git a/hai-service/src/main/java/com/hai/entity/HighOilCardRecord.java b/hai-service/src/main/java/com/hai/entity/HighOilCardRecord.java index 15934382..1284983a 100644 --- a/hai-service/src/main/java/com/hai/entity/HighOilCardRecord.java +++ b/hai-service/src/main/java/com/hai/entity/HighOilCardRecord.java @@ -56,6 +56,11 @@ public class HighOilCardRecord implements Serializable { */ private Long sourceId; + /** + * 来源订单号 + */ + private String sourceOrderNo; + /** * 来源内容 */ @@ -161,6 +166,14 @@ public class HighOilCardRecord implements Serializable { this.sourceId = sourceId; } + public String getSourceOrderNo() { + return sourceOrderNo; + } + + public void setSourceOrderNo(String sourceOrderNo) { + this.sourceOrderNo = sourceOrderNo; + } + public String getSourceContent() { return sourceContent; } @@ -246,6 +259,7 @@ public class HighOilCardRecord implements Serializable { && (this.getAfterAmount() == null ? other.getAfterAmount() == null : this.getAfterAmount().equals(other.getAfterAmount())) && (this.getSourceType() == null ? other.getSourceType() == null : this.getSourceType().equals(other.getSourceType())) && (this.getSourceId() == null ? other.getSourceId() == null : this.getSourceId().equals(other.getSourceId())) + && (this.getSourceOrderNo() == null ? other.getSourceOrderNo() == null : this.getSourceOrderNo().equals(other.getSourceOrderNo())) && (this.getSourceContent() == null ? other.getSourceContent() == null : this.getSourceContent().equals(other.getSourceContent())) && (this.getStatus() == null ? other.getStatus() == null : this.getStatus().equals(other.getStatus())) && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) @@ -269,6 +283,7 @@ public class HighOilCardRecord implements Serializable { result = prime * result + ((getAfterAmount() == null) ? 0 : getAfterAmount().hashCode()); result = prime * result + ((getSourceType() == null) ? 0 : getSourceType().hashCode()); result = prime * result + ((getSourceId() == null) ? 0 : getSourceId().hashCode()); + result = prime * result + ((getSourceOrderNo() == null) ? 0 : getSourceOrderNo().hashCode()); result = prime * result + ((getSourceContent() == null) ? 0 : getSourceContent().hashCode()); result = prime * result + ((getStatus() == null) ? 0 : getStatus().hashCode()); result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); @@ -295,6 +310,7 @@ public class HighOilCardRecord implements Serializable { sb.append(", afterAmount=").append(afterAmount); sb.append(", sourceType=").append(sourceType); sb.append(", sourceId=").append(sourceId); + sb.append(", sourceOrderNo=").append(sourceOrderNo); sb.append(", sourceContent=").append(sourceContent); sb.append(", status=").append(status); sb.append(", createTime=").append(createTime); diff --git a/hai-service/src/main/java/com/hai/entity/HighOilCardRecordExample.java b/hai-service/src/main/java/com/hai/entity/HighOilCardRecordExample.java index 8ce4c561..7fca7c29 100644 --- a/hai-service/src/main/java/com/hai/entity/HighOilCardRecordExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighOilCardRecordExample.java @@ -676,6 +676,76 @@ public class HighOilCardRecordExample { return (Criteria) this; } + public Criteria andSourceOrderNoIsNull() { + addCriterion("source_order_no is null"); + return (Criteria) this; + } + + public Criteria andSourceOrderNoIsNotNull() { + addCriterion("source_order_no is not null"); + return (Criteria) this; + } + + public Criteria andSourceOrderNoEqualTo(String value) { + addCriterion("source_order_no =", value, "sourceOrderNo"); + return (Criteria) this; + } + + public Criteria andSourceOrderNoNotEqualTo(String value) { + addCriterion("source_order_no <>", value, "sourceOrderNo"); + return (Criteria) this; + } + + public Criteria andSourceOrderNoGreaterThan(String value) { + addCriterion("source_order_no >", value, "sourceOrderNo"); + return (Criteria) this; + } + + public Criteria andSourceOrderNoGreaterThanOrEqualTo(String value) { + addCriterion("source_order_no >=", value, "sourceOrderNo"); + return (Criteria) this; + } + + public Criteria andSourceOrderNoLessThan(String value) { + addCriterion("source_order_no <", value, "sourceOrderNo"); + return (Criteria) this; + } + + public Criteria andSourceOrderNoLessThanOrEqualTo(String value) { + addCriterion("source_order_no <=", value, "sourceOrderNo"); + return (Criteria) this; + } + + public Criteria andSourceOrderNoLike(String value) { + addCriterion("source_order_no like", value, "sourceOrderNo"); + return (Criteria) this; + } + + public Criteria andSourceOrderNoNotLike(String value) { + addCriterion("source_order_no not like", value, "sourceOrderNo"); + return (Criteria) this; + } + + public Criteria andSourceOrderNoIn(List values) { + addCriterion("source_order_no in", values, "sourceOrderNo"); + return (Criteria) this; + } + + public Criteria andSourceOrderNoNotIn(List values) { + addCriterion("source_order_no not in", values, "sourceOrderNo"); + return (Criteria) this; + } + + public Criteria andSourceOrderNoBetween(String value1, String value2) { + addCriterion("source_order_no between", value1, value2, "sourceOrderNo"); + return (Criteria) this; + } + + public Criteria andSourceOrderNoNotBetween(String value1, String value2) { + addCriterion("source_order_no not between", value1, value2, "sourceOrderNo"); + return (Criteria) this; + } + public Criteria andSourceContentIsNull() { addCriterion("source_content is null"); return (Criteria) this; diff --git a/hai-service/src/main/java/com/hai/enum_type/OrderPayModelEnum.java b/hai-service/src/main/java/com/hai/enum_type/OrderPayModelEnum.java new file mode 100644 index 00000000..2d9f8c62 --- /dev/null +++ b/hai-service/src/main/java/com/hai/enum_type/OrderPayModelEnum.java @@ -0,0 +1,37 @@ +package com.hai.enum_type; + +/** + * 支付模式 + * @author hurui + */ +public enum OrderPayModelEnum { + type1(1 , "金币"), + type2(2 , "第三方平台"), + type3(3 , "混合"), + type4(4 , "油卡"), + ; + + private Integer type; + private String name; + + OrderPayModelEnum(int type , String name) { + this.type = type; + this.name = name; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/hai-service/src/main/java/com/hai/enum_type/OrderPayTypeEnum.java b/hai-service/src/main/java/com/hai/enum_type/OrderPayTypeEnum.java new file mode 100644 index 00000000..c7879e90 --- /dev/null +++ b/hai-service/src/main/java/com/hai/enum_type/OrderPayTypeEnum.java @@ -0,0 +1,40 @@ +package com.hai.enum_type; + +/** + * 支付方式 + * @author hurui + */ +public enum OrderPayTypeEnum { + type1(1 , "支付宝"), + type2(2 , "微信"), + type3(3 , "金币"), + type4(4 , "汇联通工会卡"), + type5(5 , "银联"), + type6(6 , "银联分期"), + type7(7 , "嗨森逛油卡"), + ; + + private Integer type; + private String name; + + OrderPayTypeEnum(int type , String name) { + this.type = type; + this.name = name; + } + + public Integer getType() { + return type; + } + + public void setType(Integer type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/hai-service/src/main/java/com/hai/enum_type/UserCardType.java b/hai-service/src/main/java/com/hai/enum_type/UserCardType.java index 313389c1..4b669342 100644 --- a/hai-service/src/main/java/com/hai/enum_type/UserCardType.java +++ b/hai-service/src/main/java/com/hai/enum_type/UserCardType.java @@ -1,8 +1,14 @@ package com.hai.enum_type; +import java.util.Objects; + +/** + * 用户卡片类型 + */ public enum UserCardType { type1(1, "汇联通工会卡"), + type2(2, "嗨森逛油卡"), ; private Integer type; @@ -14,6 +20,13 @@ public enum UserCardType { this.name = name; } + public static String getNameByType(Integer type) { + for (UserCardType ele : values()) { + if(Objects.equals(type,ele.getType())) return ele.getName(); + } + return null; + } + public Integer getType() { return type; } diff --git a/hai-service/src/main/java/com/hai/model/OilCardOrderModel.java b/hai-service/src/main/java/com/hai/model/OilCardOrderModel.java new file mode 100644 index 00000000..e30ccf4f --- /dev/null +++ b/hai-service/src/main/java/com/hai/model/OilCardOrderModel.java @@ -0,0 +1,192 @@ +package com.hai.model; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 油卡订单 + * @author hurui + */ +public class OilCardOrderModel { + + private String orgName; + private String merPhone; + private String orderNo; + private String gasOrderNo; + private Integer payType; + private String payTypeName; + private String memCardNo; + private BigDecimal totalPrice; + private BigDecimal deductionPrice; + private BigDecimal payRealPrice; + private Integer status; + private String statusName; + private String goodsName; + private String gasOilNo; + private String gasGunNo; + private String gasPriceGun; + private String platformPriceGun; + private Date createTime; + private Date payTime; + private Date refundTime; + + public String getOrgName() { + return orgName; + } + + public void setOrgName(String orgName) { + this.orgName = orgName; + } + + public String getMerPhone() { + return merPhone; + } + + public void setMerPhone(String merPhone) { + this.merPhone = merPhone; + } + + public String getOrderNo() { + return orderNo; + } + + public void setOrderNo(String orderNo) { + this.orderNo = orderNo; + } + + public String getGasOrderNo() { + return gasOrderNo; + } + + public void setGasOrderNo(String gasOrderNo) { + this.gasOrderNo = gasOrderNo; + } + + public Integer getPayType() { + return payType; + } + + public void setPayType(Integer payType) { + this.payType = payType; + } + + public String getPayTypeName() { + return payTypeName; + } + + public void setPayTypeName(String payTypeName) { + this.payTypeName = payTypeName; + } + + public String getMemCardNo() { + return memCardNo; + } + + public void setMemCardNo(String memCardNo) { + this.memCardNo = memCardNo; + } + + public BigDecimal getTotalPrice() { + return totalPrice; + } + + public void setTotalPrice(BigDecimal totalPrice) { + this.totalPrice = totalPrice; + } + + public BigDecimal getDeductionPrice() { + return deductionPrice; + } + + public void setDeductionPrice(BigDecimal deductionPrice) { + this.deductionPrice = deductionPrice; + } + + public BigDecimal getPayRealPrice() { + return payRealPrice; + } + + public void setPayRealPrice(BigDecimal payRealPrice) { + this.payRealPrice = payRealPrice; + } + + public Integer getStatus() { + return status; + } + + public void setStatus(Integer status) { + this.status = status; + } + + public String getStatusName() { + return statusName; + } + + public void setStatusName(String statusName) { + this.statusName = statusName; + } + + public String getGoodsName() { + return goodsName; + } + + public void setGoodsName(String goodsName) { + this.goodsName = goodsName; + } + + public String getGasOilNo() { + return gasOilNo; + } + + public void setGasOilNo(String gasOilNo) { + this.gasOilNo = gasOilNo; + } + + public String getGasGunNo() { + return gasGunNo; + } + + public void setGasGunNo(String gasGunNo) { + this.gasGunNo = gasGunNo; + } + + public String getGasPriceGun() { + return gasPriceGun; + } + + public void setGasPriceGun(String gasPriceGun) { + this.gasPriceGun = gasPriceGun; + } + + public String getPlatformPriceGun() { + return platformPriceGun; + } + + public void setPlatformPriceGun(String platformPriceGun) { + this.platformPriceGun = platformPriceGun; + } + + public Date getCreateTime() { + return createTime; + } + + public void setCreateTime(Date createTime) { + this.createTime = createTime; + } + + public Date getPayTime() { + return payTime; + } + + public void setPayTime(Date payTime) { + this.payTime = payTime; + } + + public Date getRefundTime() { + return refundTime; + } + + public void setRefundTime(Date refundTime) { + this.refundTime = refundTime; + } +} 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 c28c68dd..2ab4c6d4 100644 --- a/hai-service/src/main/java/com/hai/model/UserModel.java +++ b/hai-service/src/main/java/com/hai/model/UserModel.java @@ -2,6 +2,8 @@ package com.hai.model; import com.hai.entity.HighUserCard; +import java.util.Map; + /** * @Auther: 胡锐 * @Description: @@ -27,6 +29,28 @@ public class UserModel { // 汇联通卡号 private HighUserCard hltCardNo; + // 是否绑定油卡 + private Boolean isSetOilCard; + + // 油卡信息 + private Map oilCard; + + public Boolean getIsSetOilCard() { + return isSetOilCard; + } + + public void setIsSetOilCard(Boolean setOilCard) { + isSetOilCard = setOilCard; + } + + public Map getOilCard() { + return oilCard; + } + + public void setOilCard(Map oilCard) { + this.oilCard = oilCard; + } + public Boolean getSetHltCard() { return isSetHltCard; } diff --git a/hai-service/src/main/java/com/hai/service/HighOilCardService.java b/hai-service/src/main/java/com/hai/service/HighOilCardService.java index 703abf66..35927088 100644 --- a/hai-service/src/main/java/com/hai/service/HighOilCardService.java +++ b/hai-service/src/main/java/com/hai/service/HighOilCardService.java @@ -1,6 +1,7 @@ package com.hai.service; import com.hai.entity.HighOilCard; +import com.hai.model.OilCardOrderModel; import java.math.BigDecimal; import java.util.List; @@ -26,6 +27,14 @@ public interface HighOilCardService { */ void recharge(String cardNo, BigDecimal price, Long orgId); + /** + * 油卡消费 + * @param cardNo 油卡卡号 + * @param amount 充值金额 + * @param otherParam 其他参数 + */ + void consume(String cardNo, BigDecimal amount, Map otherParam); + /** * 生成油卡 * @param orgId 部门id @@ -74,4 +83,11 @@ public interface HighOilCardService { */ List getOilCardList(Map param); + /** + * 查询油卡订单列表 + * @param param + * @return + */ + List getOilCardOrderList(Map param) throws Exception; + } diff --git a/hai-service/src/main/java/com/hai/service/HighOrderService.java b/hai-service/src/main/java/com/hai/service/HighOrderService.java index d48c04ad..ac1fda56 100644 --- a/hai-service/src/main/java/com/hai/service/HighOrderService.java +++ b/hai-service/src/main/java/com/hai/service/HighOrderService.java @@ -35,6 +35,14 @@ public interface HighOrderService { **/ void goldPayOrder(Long userId, Long orderId) throws Exception; + /** + * 油卡支付订单 + * @param userCardId 用户与卡号关系 + * @param orderId 订单id + * @throws Exception + */ + void oilCardPayOrder(Long userCardId, Long orderId) throws Exception; + /** * 汇联通工会卡支付 * @param userCardId 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 ed49c39b..09de3c4b 100644 --- a/hai-service/src/main/java/com/hai/service/HighUserCardService.java +++ b/hai-service/src/main/java/com/hai/service/HighUserCardService.java @@ -13,6 +13,20 @@ public interface HighUserCardService { */ void editCard(HighUserCard highUserCard); + /** + * 绑定卡片 + * @param type + * @param cardNo + */ + void bindCard(Integer type,String cardNo,Long userId); + + /** + * 解除卡片 + * @param cardNo + * @param userId + */ + void delUserCard(String cardNo,Long userId); + /** * 根据id查询详情 * @param id @@ -31,10 +45,17 @@ public interface HighUserCardService { /** * 根据用户和卡号查询 * @param userId - * @param codeNo + * @param cardNo + * @return + */ + HighUserCard getDetailByUserCardNo(Long userId,String cardNo); + + /** + * 查询详情 + * @param cardNo * @return */ - HighUserCard getDetailByUserCardNo(Long userId,String codeNo); + List getDetailByCardNo(String cardNo); /** * 是否绑定汇联通工会卡 diff --git a/hai-service/src/main/java/com/hai/service/impl/HighOilCardRecordServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighOilCardRecordServiceImpl.java index 0d3cf669..9833422a 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighOilCardRecordServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighOilCardRecordServiceImpl.java @@ -4,6 +4,7 @@ import com.hai.common.security.UserCenter; import com.hai.dao.HighOilCardRecordMapper; import com.hai.entity.HighOilCardRecord; import com.hai.entity.HighOilCardRecordExample; +import com.hai.model.HighUserModel; import com.hai.model.UserInfoModel; import com.hai.service.HighOilCardRecordService; import org.apache.commons.collections4.MapUtils; @@ -27,11 +28,17 @@ public class HighOilCardRecordServiceImpl implements HighOilCardRecordService { @Override public void insertRecord(HighOilCardRecord oilCardRecord) { UserInfoModel userInfoModel = userCenter.getSessionModel(UserInfoModel.class); + if (userInfoModel != null) { + oilCardRecord.setOpUserId(userInfoModel.getSecUser().getId()); + oilCardRecord.setOpUserName(userInfoModel.getSecUser().getUserName()); + } else { + HighUserModel userModel = userCenter.getSessionModel(HighUserModel.class); + oilCardRecord.setOpUserId(userModel.getHighUser().getId()); + oilCardRecord.setOpUserName(userModel.getHighUser().getName()); + } oilCardRecord.setCreateTime(new Date()); oilCardRecord.setStatus(1); - oilCardRecord.setOpUserId(userInfoModel.getSecUser().getId()); - oilCardRecord.setOpUserName(userInfoModel.getSecUser().getUserName()); oilCardRecordMapper.insert(oilCardRecord); } @@ -48,6 +55,10 @@ public class HighOilCardRecordServiceImpl implements HighOilCardRecordService { criteria.andCardNoEqualTo(MapUtils.getString(map, "cardNo")); } + if (StringUtils.isNotBlank(MapUtils.getString(map, "sourceOrderNo"))) { + criteria.andSourceOrderNoLike("%"+MapUtils.getString(map, "sourceOrderNo")+"%"); + } + if (MapUtils.getInteger(map, "type") != null) { criteria.andTypeEqualTo(MapUtils.getInteger(map, "type")); } diff --git a/hai-service/src/main/java/com/hai/service/impl/HighOilCardServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighOilCardServiceImpl.java index d375e4cc..fb100ab1 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighOilCardServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighOilCardServiceImpl.java @@ -6,12 +6,14 @@ import com.hai.common.exception.SysCode; import com.hai.common.security.AESEncodeUtil; import com.hai.common.security.UserCenter; import com.hai.common.utils.BankNumberUtil; +import com.hai.common.utils.DateUtil; import com.hai.dao.HighOilCardMapper; import com.hai.entity.*; import com.hai.enum_type.OilCardBindStatusEnum; import com.hai.enum_type.OilCardRecordSourceTypeEnum; import com.hai.enum_type.OilCardRecordTypeEnum; import com.hai.enum_type.OilCardStatusEnum; +import com.hai.model.OilCardOrderModel; import com.hai.model.UserInfoModel; import com.hai.service.*; import org.apache.commons.collections4.MapUtils; @@ -49,6 +51,9 @@ public class HighOilCardServiceImpl implements HighOilCardService { @Resource private UserCenter userCenter; + @Resource + private HighUserCardService userCardService; + @Override public void editData(HighOilCard oilCard) { if (oilCard.getId() == null) { @@ -77,7 +82,7 @@ public class HighOilCardServiceImpl implements HighOilCardService { Map consumeType = new HashMap<>(); consumeType.put("sourceType", "2"); consumeType.put("sourceId", oilCard.getId()); - consumeType.put("sourceContent", "油卡:"+oilCard.getCardNo()+",充值:"+price.toString()); + consumeType.put("sourceContent", "油卡:"+oilCard.getCardNo()+",充值:¥"+price.toString()); companyAccountService.consume(orgId, price, consumeType); // 变更前金额 @@ -96,10 +101,53 @@ public class HighOilCardServiceImpl implements HighOilCardService { record.setBeforeAmount(beforeAmount); record.setAfterAmount(afterAmount); record.setSourceType(OilCardRecordSourceTypeEnum.type1.getType()); + try { + record.setSourceOrderNo(DateUtil.date2String(new Date(), "yyyyMMddHHmmss")); + } catch (Exception e) { + e.printStackTrace(); + }; record.setSourceContent("充值油卡金额:" + record.getAmount()); oilCardRecordService.insertRecord(record); } + @Override + public void consume(String cardNo, BigDecimal amount, Map otherParam) { + // 油卡 + HighOilCard card = getOilCardByCardNo(cardNo); + if (card == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的卡号"); + } + if (!card.getStatus().equals(OilCardStatusEnum.status1.getStatus())) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "油卡状态异常,暂无法消费"); + } + // 油卡余额 是否小于 消费余额 + if (card.getAmount().compareTo(amount) == -1) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "油卡余额不足"); + } + // 变更前金额 + BigDecimal beforeAmount = card.getAmount(); + // 计算消费后金额 + card.setAmount(card.getAmount().subtract(amount)); + // 累积消费金额 + card.setAmountConsume(card.getAmountConsume().add(amount)); + editData(card); + // 变更后金额 + BigDecimal afterAmount = card.getAmount(); + + HighOilCardRecord record = new HighOilCardRecord(); + record.setOilCardId(card.getId()); + record.setCardNo(card.getCardNo()); + record.setType(OilCardRecordTypeEnum.type2.getType()); + record.setAmount(amount); + record.setBeforeAmount(beforeAmount); + record.setAfterAmount(afterAmount); + record.setSourceType(MapUtils.getInteger(otherParam, "sourceType")); + record.setSourceId(MapUtils.getLong(otherParam, "sourceId")); + record.setSourceOrderNo(MapUtils.getString(otherParam, "sourceOrderNo")); + record.setSourceContent(MapUtils.getString(otherParam, "sourceContent")); + oilCardRecordService.insertRecord(record); + } + @Override @Transactional(propagation= Propagation.REQUIRES_NEW, rollbackFor = Exception.class) public void generateCard(Long orgId, Integer generateNum) { @@ -147,17 +195,28 @@ public class HighOilCardServiceImpl implements HighOilCardService { if (phone != null && !phone.getId().equals(oilCard.getId())) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "联系电话已绑定其他油卡"); } + if (StringUtils.isBlank(oilCard.getContactPhone())) { + oilCardContactRecordService.insert(oilCard.getId(), oilCard.getCardNo(), "新设置:联系人【"+contactName+"】,联系电话【"+contactPhone+"】"); + + } else if (StringUtils.isNotBlank(oilCard.getContactPhone()) && !oilCard.getContactPhone().equals(contactPhone)) { + // 绑定状态 0:未绑定 1:已绑定 + if (oilCard.getBindStatus().equals(1)) { + oilCard.setBindTime(null); + oilCard.setBindStatus(0); + // 查询用户绑定油卡列表 + List userCardList = userCardService.getDetailByCardNo(oilCard.getCardNo()); + // 油卡解绑 + for (HighUserCard userCard : userCardList) { + userCard.setStatus(0); + userCardService.editCard(userCard); + } + } + oilCardContactRecordService.insert(oilCard.getId(), oilCard.getCardNo(), "联系信息变更:原联系人【"+oilCard.getContactName()+"】,联系电话【"+oilCard.getContactPhone()+"】。" + + "变跟后联系人【"+contactName+ "】,联系电话【"+contactPhone+"】"); + } oilCard.setContactName(contactName); oilCard.setContactPhone(contactPhone); editData(oilCard); - - // 绑定状态 0:未绑定 1:已绑定 - if (oilCard.getBindStatus() == 1) { - oilCardContactRecordService.insert(oilCard.getId(), oilCard.getCardNo(), "新设置:联系人【"+oilCard.getContactName()+"】,联系电话【"+oilCard.getContactPhone()+"】"); - } else { - oilCardContactRecordService.insert(oilCard.getId(), oilCard.getCardNo(), "联系信息变更:原联系人【"+oilCard.getContactName()+"】,联系电话【"+oilCard.getContactPhone()+"】。" + - "变跟后联系人【"+oilCard.getContactName()+ "】,联系电话【"+oilCard.getContactPhone()+"】"); - } } @Override @@ -275,4 +334,16 @@ public class HighOilCardServiceImpl implements HighOilCardService { example.setOrderByClause("create_time desc"); return oilCardMapper.selectByExample(example); } + + @Override + public List getOilCardOrderList(Map param) throws Exception { + if (MapUtils.getLong(param, "payTimeS") != null) { + param.put("payTimeS", DateUtil.date2String(new Date(MapUtils.getLong(param, "payTimeS")), "yyyy-MM-dd HH:mm:ss")); + } + + if (MapUtils.getLong(param, "payTimeE") != null) { + param.put("payTimeE", DateUtil.date2String(new Date(MapUtils.getLong(param, "payTimeE")), "yyyy-MM-dd HH:mm:ss")); + } + return oilCardMapper.selectOilCardOrderList(param); + } } 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 944dfa53..ce9cc2d9 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 @@ -10,7 +10,7 @@ import com.hai.common.utils.DateUtil; import com.hai.config.*; import com.hai.dao.*; import com.hai.entity.*; -import com.hai.enum_type.OrderPushType; +import com.hai.enum_type.*; import com.hai.model.*; import com.hai.service.*; import org.apache.commons.collections4.MapUtils; @@ -105,6 +105,9 @@ public class HighOrderServiceImpl implements HighOrderService { @Resource private HuiLianTongConfig huiLianTongConfig; + @Resource + private HighOilCardService oilCardService; + @Override @Transactional( isolation = Isolation.SERIALIZABLE, @@ -409,6 +412,212 @@ public class HighOrderServiceImpl implements HighOrderService { updateOrder(highOrder); } + @Override + @Transactional(propagation= Propagation.REQUIRES_NEW) + public void oilCardPayOrder(Long userCardId, Long orderId) throws Exception { + HighUserCard userCard = highUserCardService.getDetailById(userCardId); + if(userCard == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到用户绑定的卡号信息"); + } + if (!userCard.getType().equals(UserCardType.type2.getType())) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "卡片类型"); + } + // 查询订单信息 + HighOrder order = getOrderById(orderId); + if (order == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, ""); + } + if (!order.getOrderStatus().equals(1)) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单不处于待支付状态"); + } + // 油卡扣款 + Map consumeMap = new HashMap<>(); + consumeMap.put("sourceType", OilCardRecordSourceTypeEnum.type2.getType()); + consumeMap.put("sourceId", order.getId()); + consumeMap.put("sourceOrderNo", order.getOrderNo()); + consumeMap.put("sourceContent", "订单号:" + order.getOrderNo() + ",消费:¥" + order.getPayPrice()); + oilCardService.consume(userCard.getCardNo(), order.getPayPrice(), consumeMap); + + order.setMemCardType(userCard.getType()); + order.setMemCardId(userCard.getId()); + order.setMemCardNo(userCard.getCardNo()); + order.setPayTime(new Date()); // 支付时间 + order.setPayModel(OrderPayModelEnum.type4.getType()); // 支付模式:1 金币,2 第三方平台,3 混合 + order.setPayType(OrderPayTypeEnum.type7.getType()); // 支付方式: 1:支付宝 2:微信 3:金币 + order.setPayRealPrice(order.getPayPrice()); + order.setOrderStatus(2); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 + + // 查询用户 + HighUser highUser = highUserService.findByUserId(order.getMemId()); + + for (HighChildOrder highChildOrder : order.getHighChildOrderList()) { + if (!highChildOrder.getGoodsType().equals(1) && !highChildOrder.getGoodsType().equals(3)) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "不支持支付该商品"); + } + + // 商品类型 商品类型 1:卡卷 2:金币充值 + if (highChildOrder.getGoodsType() == 1) { + highChildOrder.setChildOrdeStatus(2); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 + + HighCoupon coupon = highCouponService.getCouponById(highChildOrder.getGoodsId()); + + // 是否预约 + if (coupon.getReserveStatus() == true) { + HighOrderPre orderPre = new HighOrderPre(); + orderPre.setCompanyId(coupon.getCompanyId()); + orderPre.setMerchantId(coupon.getMerchantId()); + orderPre.setMerchantStoreId(highChildOrder.getStoreId()); + orderPre.setPreOrderNo(System.currentTimeMillis()+""); + orderPre.setOrderId(order.getId()); + orderPre.setOrderNo(order.getOrderNo()); + orderPre.setChildOrderId(highChildOrder.getId()); + orderPre.setPayRealPrice(order.getPayRealPrice()); + orderPre.setGoodsType(1); + orderPre.setGoodsName(coupon.getCouponName()); + orderPre.setGoodsId(coupon.getId()); + orderPre.setPreUserId(order.getMemId()); + orderPre.setPreUserName(order.getMemName()); + orderPre.setPreUserPhone(order.getMemPhone()); + orderPre.setPreUserRemark(order.getRemarks()); + orderPre.setStatus(1); + highOrderPreService.insertOrderPre(orderPre); + } + + // 贵州中石化 + if (coupon.getCouponSource() == 4) { + // 获取token + String token = huiLianTongConfig.getToken(); + + Map push = new HashMap<>(); + push.put("token",token); + push.put("couTypeCode", coupon.getCouponKey()); + push.put("distCouCount", highChildOrder.getSaleCount()); + push.put("userPhone", highUser.getPhone()); + push.put("thirdUserId", highUser.getUnionId()); + + // 推送给高速 + JSONObject returnParam = HuiLianTongConfig.couJointDist(token, order.getOrderNo(),coupon.getCouponKey(), highChildOrder.getSaleCount(), highUser.getPhone(), highUser.getUnionId()); + if (returnParam != null && returnParam.getString("result").equals("success")) { + JSONArray dataArray = returnParam.getJSONArray("data"); + for (Object data : dataArray) { + JSONObject dataObject = (JSONObject) data; + HighCouponCodeOther couponCodeOther = new HighCouponCodeOther(); + couponCodeOther.setType(1); + couponCodeOther.setOrderId(order.getId()); + couponCodeOther.setChildOrderId(highChildOrder.getId()); + couponCodeOther.setCouTypeCode(dataObject.getString("couTypeCode")); + couponCodeOther.setCouNo(dataObject.getString("couNo")); + couponCodeOther.setStatus(20); + couponCodeOther.setCreateTime(new Date()); + couponCodeOther.setActiveTime(dataObject.getDate("activeTime")); + couponCodeOther.setValidStartDate(dataObject.getDate("validStartDate")); + couponCodeOther.setValidEndDate(dataObject.getDate("validEndDate")); + highCouponCodeOtherMapper.insert(couponCodeOther); + + // 卡卷关联用户 + HighUserCoupon highUserCoupon = new HighUserCoupon(); + highUserCoupon.setMerchantId(coupon.getMerchantId()); + highUserCoupon.setCouponId(coupon.getId()); + highUserCoupon.setUserId(order.getMemId()); + highUserCoupon.setCreateTime(new Date()); + highUserCoupon.setQrCodeImg(dataObject.getString("couNo")); + highUserCoupon.setUseEndTime(dataObject.getDate("validEndDate")); + highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用 + highUserCouponMapper.insert(highUserCoupon); + } + } + + // 推送记录 + HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); + highGasOrderPush.setType(OrderPushType.type6.getType()); + highGasOrderPush.setOrderNo(order.getOrderNo()); + highGasOrderPush.setCreateTime(new Date()); + highGasOrderPush.setCode(returnParam.getString("result")); + highGasOrderPush.setRequestContent(JSONObject.toJSONString(push)); + highGasOrderPush.setReturnContent(returnParam.toJSONString()); + 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()); + highUserCoupon.setCouponId(code.getCouponId()); + highUserCoupon.setUserId(order.getMemId()); + highUserCoupon.setCouponCodeId(code.getId()); + highUserCoupon.setCreateTime(new Date()); + highUserCoupon.setQrCodeImg(code.getExt1()); + + // 计算使用有效期 + Calendar userEndTime = Calendar.getInstance(); + userEndTime.setTime(new Date()); + userEndTime.set(Calendar.HOUR_OF_DAY, 23); + userEndTime.set(Calendar.MINUTE, 59); + userEndTime.set(Calendar.SECOND, 59); + userEndTime.add(Calendar.DATE, coupon.getRecycleDay()); + if (userEndTime.getTime().compareTo(code.getUseEndTime()) == 1) { + highUserCoupon.setUseEndTime(code.getUseEndTime()); + } else { + highUserCoupon.setUseEndTime(userEndTime.getTime()); + } + highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用 + highUserCouponMapper.insert(highUserCoupon); + } + + // 查询卡券是否有活动 + Map activity = highActivityInfoService.getNewActivityByCouponId(coupon.getId()); + if (activity != null && MapUtils.getLong(activity, "id") != null) { + highActivityUserLotteryNumService.addLotteryNum(MapUtils.getLong(activity, "id"),order.getMemId(), 1); + } + } + + if (highChildOrder.getGoodsType() == 3) { + highChildOrder.setChildOrdeStatus(3); + HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highChildOrder.getGoodsId()); + // 推送团油订单 + Map paramMap = new HashMap<>(); + paramMap.put("gasId", store.getStoreKey()); + paramMap.put("oilNo", highChildOrder.getGasOilNo()); + paramMap.put("gunNo", highChildOrder.getGasGunNo()); + BigDecimal priceGun = highChildOrder.getGasPriceGun(); + BigDecimal priceVip = highChildOrder.getGasPriceVip(); + paramMap.put("priceGun", priceGun); // 枪单价 + paramMap.put("priceVip", priceVip); // 优惠价 + paramMap.put("driverPhone", order.getMemPhone()); + paramMap.put("thirdSerialNo", order.getOrderNo()); + paramMap.put("refuelingAmount", highChildOrder.getTotalPrice()); + + // 油品类型 1:汽油:2:柴油;3:天然气 + if (highChildOrder.getGasOilType() == 1) { + paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouGasolineAccount()); + } else if (highChildOrder.getGasOilType() == 2) { + paramMap.put("accountNo", CommonSysConst.getSysConfig().getTuanYouDieselAccount()); + } + JSONObject orderPushObject = TuanYouConfig.refuelingOrderPush(paramMap); + // 推送团油订单记录 + HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); + highGasOrderPush.setType(OrderPushType.type1.getType()); + highGasOrderPush.setOrderNo(order.getOrderNo()); + highGasOrderPush.setCreateTime(new Date()); + highGasOrderPush.setCode(orderPushObject.getString("code")); + highGasOrderPush.setRequestContent(JSONObject.toJSONString(paramMap)); + highGasOrderPush.setReturnContent(orderPushObject.toJSONString()); + highGasOrderPushMapper.insert(highGasOrderPush); + + if (orderPushObject != null && orderPushObject.getString("code").equals("200")) { + highChildOrder.setGasOrderNo(orderPushObject.getJSONObject("result").getString("orderNo")); + } + } + + } + + updateOrder(order); + } + @Override @Transactional(propagation= Propagation.REQUIRES_NEW) public void hltUnionCardPay(Long userCardId, Long orderId) throws Exception { 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 e6531893..3cb60f0a 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 @@ -1,10 +1,21 @@ package com.hai.service.impl; +import com.hai.common.exception.ErrorCode; +import com.hai.common.exception.ErrorHelp; +import com.hai.common.exception.SysCode; +import com.hai.common.security.UserCenter; import com.hai.dao.HighUserCardMapper; +import com.hai.entity.HighOilCard; import com.hai.entity.HighUserCard; import com.hai.entity.HighUserCardExample; +import com.hai.enum_type.OilCardStatusEnum; +import com.hai.enum_type.UserCardType; +import com.hai.model.HighUserModel; +import com.hai.service.HighOilCardService; import com.hai.service.HighUserCardService; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import java.util.Date; @@ -16,6 +27,12 @@ public class HighUserCardServiceImpl implements HighUserCardService { @Resource private HighUserCardMapper highUserCardMapper; + @Resource + private UserCenter userCenter; + + @Resource + private HighOilCardService oilCardService; + @Override public void editCard(HighUserCard highUserCard) { if(highUserCard.getId() == null){ @@ -29,6 +46,54 @@ public class HighUserCardServiceImpl implements HighUserCardService { } } + @Override + @Transactional(propagation= Propagation.REQUIRES_NEW) + public void bindCard(Integer type, String cardNo,Long userId) { + HighUserCard userCard = new HighUserCard(); + userCard.setType(type); + userCard.setUserId(userId); + userCard.setCardNo(cardNo); + editCard(userCard); + + if (type.equals(UserCardType.type2.getType())) { + // 查询卡号 + HighOilCard card = oilCardService.getOilCardByCardNo(cardNo); + if (card == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "油卡卡号错误"); + } + if (!card.getStatus().equals(OilCardStatusEnum.status1.getStatus())) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "油卡状态异常"); + } + if (card.getBindStatus() == 1) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "油卡已被绑定,请勿重复绑定"); + } + card.setBindTime(new Date()); + card.setBindStatus(1); + oilCardService.editData(card); + } + } + + @Override + public void delUserCard(String cardNo, Long userId) { + HighUserCard card = getDetailByUserCardNo(userId, cardNo); + if (card == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到数据"); + } + card.setStatus(0); + editCard(card); + + if (card.getType().equals(UserCardType.type2.getType())) { + // 查询卡号 + HighOilCard oilCard = oilCardService.getOilCardByCardNo(cardNo); + if (oilCard == null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "油卡卡号错误"); + } + oilCard.setBindTime(null); + oilCard.setBindStatus(0); + oilCardService.editData(oilCard); + } + } + @Override public HighUserCard getDetailById(Long id) { return highUserCardMapper.selectByPrimaryKey(id); @@ -56,6 +121,13 @@ public class HighUserCardServiceImpl implements HighUserCardService { return null; } + @Override + public List getDetailByCardNo(String cardNo) { + HighUserCardExample example = new HighUserCardExample(); + example.createCriteria().andCardNoEqualTo(cardNo).andStatusNotEqualTo(0); + return highUserCardMapper.selectByExample(example); + } + @Override public Boolean isBindHtlCard(Long userId) { HighUserCardExample example = new HighUserCardExample(); diff --git a/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java index dbe01991..371309bd 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighUserServiceImpl.java @@ -8,10 +8,7 @@ import com.hai.common.security.UserCenter; import com.hai.common.utils.DateUtil; import com.hai.dao.HighGoldRecMapper; import com.hai.dao.HighUserMapper; -import com.hai.entity.HighGoldRec; -import com.hai.entity.HighGoldRecExample; -import com.hai.entity.HighUser; -import com.hai.entity.HighUserExample; +import com.hai.entity.*; import com.hai.model.HighUserModel; import com.hai.service.*; import org.apache.commons.lang3.StringUtils; @@ -22,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; import java.util.Date; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -55,9 +53,11 @@ public class HighUserServiceImpl implements HighUserService { @Resource private HighGoldRecMapper highGoldRecMapper; + @Resource + private HighOilCardService oilCardService; + @Override public List getListUser(Map map) { - HighUserExample example = new HighUserExample(); HighUserExample.Criteria criteria = example.createCriteria(); @@ -100,6 +100,23 @@ public class HighUserServiceImpl implements HighUserService { user.setIsSetPayPwd(highUserPayPasswordService.isSetPayPwd(userId)); user.setIsSetHltCard(highUserCardService.isBindHtlCard(userId)); user.setHltCardNo(highUserCardService.getUserHtlCardNo(userId)); + + // 查询油卡 + List oilCardList = highUserCardService.getListByUser(userId, 2); + if (oilCardList.size() > 0) { + user.setIsSetOilCard(true); + // 查询油卡 + HighOilCard oilCard = oilCardService.getOilCardByCardNo(oilCardList.get(0).getCardNo()); + if (oilCard != null) { + Map oilCardMap = new HashMap<>(); + oilCardMap.put("cardNo", oilCard.getCardNo()); + oilCardMap.put("amount", oilCard.getAmount()); + user.setOilCard(oilCardMap); + } + } else { + user.setIsSetOilCard(false); + } + return user; }