From a9bcd6800f2d303839781f473244003d930a1e9d Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Thu, 12 Jan 2023 10:40:46 +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 --- .../bweb/controller/HighGasController.java | 4 +- .../cweb/controller/HighOrderController.java | 696 --------- .../controller/pay/CzOrderController.java | 556 ------- .../cweb/controller/pay/OrderController.java | 1219 ---------------- .../controller/pay/QzOrderController.java | 108 -- .../controller/pay/ThirdOrderController.java | 256 ---- .../controller/pay/TuanYouController.java | 228 --- .../controller/pay/UnionPayController.java | 587 -------- .../controller/pay/WechatPayController.java | 212 --- .../web/controller/OrderPayController.java | 2 +- .../business/OrderThirdPartyController.java | 4 +- .../java/com/hai/dao/HighGasOrderMapper.java | 97 +- .../com/hai/dao/HighGasOrderSqlProvider.java | 14 + .../java/com/hai/entity/HighGasOrder.java | 16 + .../com/hai/entity/HighGasOrderExample.java | 70 + .../com/hai/enum_type/OrderPayTypeEnum.java | 50 - .../hai/order/service/OrderPayService.java | 2 +- .../service/impl/OrderPayServiceImpl.java | 17 +- .../com/hai/service/HighOrderService.java | 32 - .../hai/service/impl/ApiOpenServiceImpl.java | 2 - .../impl/HighFleetOilCardServiceImpl.java | 5 +- .../service/impl/HighOilCardServiceImpl.java | 5 +- .../service/impl/HighOrderServiceImpl.java | 1286 +---------------- .../service/impl/HighUserCardServiceImpl.java | 4 +- .../hai/service/impl/HighUserServiceImpl.java | 2 +- 25 files changed, 183 insertions(+), 5291 deletions(-) delete mode 100644 hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java delete mode 100644 hai-cweb/src/main/java/com/cweb/controller/pay/CzOrderController.java delete mode 100644 hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java delete mode 100644 hai-cweb/src/main/java/com/cweb/controller/pay/QzOrderController.java delete mode 100644 hai-cweb/src/main/java/com/cweb/controller/pay/ThirdOrderController.java delete mode 100644 hai-cweb/src/main/java/com/cweb/controller/pay/TuanYouController.java delete mode 100644 hai-cweb/src/main/java/com/cweb/controller/pay/UnionPayController.java delete mode 100644 hai-cweb/src/main/java/com/cweb/controller/pay/WechatPayController.java delete mode 100644 hai-service/src/main/java/com/hai/enum_type/OrderPayTypeEnum.java diff --git a/hai-bweb/src/main/java/com/bweb/controller/HighGasController.java b/hai-bweb/src/main/java/com/bweb/controller/HighGasController.java index 9711d8e3..709ed8b7 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/HighGasController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/HighGasController.java @@ -21,6 +21,7 @@ import com.hai.entity.*; import com.hai.enum_type.*; import com.hai.model.*; import com.hai.msg.entity.MsgTopic; +import com.hai.order.type.OrderPayType; import com.hai.service.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -774,7 +775,6 @@ public class HighGasController { } } - @RequestMapping(value="/refuelingOrderRefund",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "订单退款") @@ -876,7 +876,7 @@ public class HighGasController { //order.setRefundTime(new Date()); //order.setRefundPrice(order.getPayRealPrice()); highOrderService.updateOrderDetail(order); - } else if (order.getPayType().equals(OrderPayTypeEnum.type7.getType())) { + } else if (order.getPayType().equals(OrderPayType.PAY_TYPE7.getNumber())) { // 油卡退款 oilCardService.refund(order.getOrderNo()); } diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java deleted file mode 100644 index 2a4d2d9e..00000000 --- a/hai-cweb/src/main/java/com/cweb/controller/HighOrderController.java +++ /dev/null @@ -1,696 +0,0 @@ -/* -package com.cweb.controller; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -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.AESEncodeUtil; -import com.hai.common.security.SessionObject; -import com.hai.common.security.UserCenter; -import com.hai.common.utils.DateUtil; -import com.hai.common.utils.IDGenerator; -import com.hai.common.utils.ResponseMsgUtil; -import com.hai.config.CommonSysConfig; -import com.hai.config.CommonSysConst; -import com.hai.config.TuanYouConfig; -import com.hai.entity.*; -import com.hai.enum_type.DiscountUseScope; -import com.hai.enum_type.GasClassGroupTaskStatus; -import com.hai.enum_type.MerAccountMarketingType; -import com.hai.enum_type.OrderChildGoodsTypeEnum; -import com.hai.model.GasPayPriceModel; -import com.hai.model.HighMerchantStoreModel; -import com.hai.model.HighUserModel; -import com.hai.model.ResponseData; -import com.hai.service.*; -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.beans.factory.annotation.Autowired; -import org.springframework.dao.DeadlockLoserDataAccessException; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import java.math.BigDecimal; -import java.math.MathContext; -import java.math.RoundingMode; -import java.net.URLDecoder; -import java.util.*; -import java.util.stream.Collectors; - -*/ -/** - * @Auther: 胡锐 - * @Description: - * @Date: 2021/3/26 23:08 - *//* - -@Controller -@RequestMapping(value = "/highOrder") -@Api(value = "订单接口") -public class HighOrderController { - private static Logger log = LoggerFactory.getLogger(HighMerchantStoreController.class); - - @Autowired - private UserCenter userCenter; - - @Resource - private CommonService commonService; - - @Resource - private HighOrderService highOrderService; - - @Resource - private HighCouponService highCouponService; - - @Resource - private HighMerchantStoreService highMerchantStoreService; - - @Resource - private HighMerchantAccountMarketingService merchantAccountMarketingService; - - @Resource - private HighCouponCodeService highCouponCodeService; - - @Resource - private HighDiscountUserRelService highDiscountUserRelService; - - @Resource - private HighDiscountCouponRelService highDiscountCouponRelService; - - @Resource - private HighDiscountPackageService discountPackageService; - - @Resource - private HighDiscountPackageActualService discountPackageActualService; - - @Resource - private HighUserService highUserService; - - @Resource - private HighTyAgentOilStationService tyAgentOilStationService; - - @Resource - private HighTyAgentPriceService tyAgentPriceService; - - @Resource - private HighGasDiscountOilPriceService gasDiscountOilPriceService; - - @Resource - private HighGasStaffService gasStaffService; - - @Resource - private HighGasClassGroupTaskService gasClassGroupTaskService; - - @Resource - private BsCompanyService bsCompanyService; - - @RequestMapping(value="/addOrder",method = RequestMethod.POST) - @ResponseBody - @ApiOperation(value = "增加订单") - public ResponseData addOrder(@RequestBody HighOrder highOrder, HttpServletRequest request) { - try { - // 用户 - SessionObject sessionObject = userCenter.getSessionObject(request); - HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); - - if (highOrder.getHighChildOrderList() == null - || highOrder.getHighChildOrderList().size() == 0 - ) { - log.error("HighOrderController --> addOrder() error!", "参数错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - - if (StringUtils.isBlank(userInfoModel.getHighUser().getPhone())) { - log.error("HighOrderController --> addOrder() error!", "未绑定手机号"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.NO_BIND_PHONE, ""); - } - - HighDiscountUserRel highDiscountUserRel = null; - if (highOrder.getMemDiscountId() != null) { - // 卡优惠券信息 - highDiscountUserRel = highDiscountUserRelService.getRelById(highOrder.getMemDiscountId()); - if (highDiscountUserRel == null || highDiscountUserRel.getStatus() != 1) { - log.error("HighOrderController --> addOrder() error!", "优惠券状态错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券状态错误"); - } - } - - // 定义当前卡券是否可以直冲积分 - boolean buyPoints = false; - - BigDecimal totalPrice = new BigDecimal("0"); - BigDecimal totalActualPrice = new BigDecimal("0"); - for (HighChildOrder childOrder : highOrder.getHighChildOrderList()) { - if (childOrder.getGoodsType() == null || childOrder.getGoodsId() == null || childOrder.getSaleCount() == null) { - log.error("HighOrderController --> addOrder() error!", "参数错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - - // 商品类型 1:卡卷 2:金币充值 3:团油【加油站】 - if (childOrder.getGoodsType() == 1) { - if (childOrder.getSaleCount() != 1) { - log.error("HighOrderController --> addOrder() error!", "卡卷只能购买一张"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "卡卷只能购买一张"); - } - // 查询卡卷信息 - HighCoupon coupon = highCouponService.getCouponById(childOrder.getGoodsId()); - - - // 判断是否实物商品 - if (coupon.getWherePost() != null && coupon.getWherePost()) { - if (highOrder.getPostData().getString("address").length() == 0 || highOrder.getPostData().getString("user").length() == 0 || highOrder.getPostData().getString("phone").length() == 0 ) { - log.error("HighOrderController --> addOrder() error!", "请输入收货相关信息"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请输入收货相关信息"); - } - // 先把String对象转换成Json对象 - highOrder.setRemarks(highOrder.getPostData().toString()); - - } - - if (coupon == null) { - log.error("HighOrderController --> addOrder() error!", "未找到卡卷信息"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_COUPON, ""); - } - if (coupon.getReserveStatus() == true) { - if (childOrder.getStoreId() == null) { - log.error("HighOrderController --> addOrder() error!", "未选择门店"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未选择门店"); - } - // 查询门店信息 - HighMerchantStoreModel merchantStore = highMerchantStoreService.getMerchantStoreById(childOrder.getStoreId()); - if (merchantStore == null) { - log.error("HighOrderController --> addOrder() error!", "未选择门店"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到门店信息"); - } - if (!merchantStore.getMerchantId().equals(coupon.getMerchantId())) { - log.error("HighOrderController --> addOrder() error!", "卡券无法在此门店消费"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "卡券无法在此门店消费"); - } - } - // 支付类型:1.微信支付 2.金币支付 - if(coupon.getPayType() == 2) { - highOrder.setPayModel(1); // 支付模式:1 金币,2 第三方平台,3 混合 - highOrder.setPayType(3); // 支付方式: 1:支付宝 2:微信 3:金币 - } - // 是否达到限购数量 - if (highCouponService.userBuyLimitNumber(userInfoModel.getHighUser().getId(), coupon.getId()) == true) { - log.error("HighOrderController --> addOrder() error!", "已达到限购数量"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, coupon.getCouponName() + ",已达到限购数量"); - } - // 校验优惠券是否可用 如果使用优惠券就只能使用卡券的原价 - if (highDiscountUserRel != null) { - List discountCouponRelList = highDiscountCouponRelService.getRelByCoupon(coupon.getId()); - if (discountCouponRelList.size() > 0) { - HighDiscountUserRel finalHighDiscountUserRel = highDiscountUserRel; - List collect = discountCouponRelList.stream().filter(o -> o.getDiscountId().equals(finalHighDiscountUserRel.getDiscountId())).collect(Collectors.toList()); - if (collect == null || collect.size() == 0) { - log.error("HighOrderController --> addOrder() error!", "无法使用优惠券"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法使用优惠券"); - } - } - childOrder.setGoodsPrice(coupon.getSalesPrice()); - } else { - childOrder.setGoodsPrice(coupon.getDiscountPrice()); - } - // 贵州中石化 - if (coupon.getCouponSource() != 4 && coupon.getCouponSource() != 5) { - if (highCouponCodeService.getStockCountByCoupon(coupon.getId()) <= 0) { - log.error("HighOrderController --> addOrder() error!", "卡卷库存数量不足"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "系统维护中"); - } - } - - if (coupon.getBuyPoints()) { - buyPoints = true; - } - - childOrder.setGoodsActualPrice(childOrder.getGoodsPrice()); - childOrder.setGoodsName(coupon.getCouponName()); - childOrder.setGoodsImg(coupon.getCouponImg()); - childOrder.setGoodsSpecName("默认"); - childOrder.setExt1(coupon.getCouponSource().toString()); - } - - if (childOrder.getGoodsType() == 2) { - if (childOrder.getGoodsPrice() == null) { - log.error("HighOrderController --> addOrder() error!", "请设置充值金额"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请设置充值金额"); - } - // 查询用户信息 - HighUser user = highUserService.findByUserId(childOrder.getGoodsId()); - if (user == null) { - log.error("HighOrderController --> addOrder() error!", "未找到用户"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, ""); - } - childOrder.setGoodsActualPrice(childOrder.getGoodsPrice()); - childOrder.setGoodsName(user.getName()); - childOrder.setGoodsImg(user.getHeaderImg()); - childOrder.setGoodsSpecName("默认"); - } - - if (childOrder.getGoodsType() == 3) { - if (childOrder.getGasPriceGun() == null || childOrder.getGasPriceVip() == null || StringUtils.isBlank(childOrder.getGasGunNo()) || StringUtils.isBlank(childOrder.getGasOilNo()) || childOrder.getGasOilType() == null) { - log.error("HighOrderController --> addOrder() error!", "参数错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - - // 加油限制 - if (childOrder.getGasOilType().equals(1)) { - SecDictionary refuelLimit = commonService.mappingSysName("REFUEL_LIMIT", "汽油"); - if (refuelLimit != null && childOrder.getGoodsPrice().compareTo(new BigDecimal(refuelLimit.getCodeValue())) == 1) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "汽油加油金额不能超过" + refuelLimit.getCodeValue()+"元"); - } - } else if (childOrder.getGasOilType().equals(2)){ - SecDictionary refuelLimit = commonService.mappingSysName("REFUEL_LIMIT", "柴油"); - if (refuelLimit != null && childOrder.getGoodsPrice().compareTo(new BigDecimal(refuelLimit.getCodeValue())) == 1) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "柴油加油金额不能超过" + refuelLimit.getCodeValue()+"元"); - } - } - - if (highOrderService.getGasTheDayOrderNum(userInfoModel.getHighUser().getId()) >= 1) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已达到每日加油次数上限"); - } - - if (StringUtils.isNotBlank(highOrder.getGasStaffCode())) { - String qrCodeSignKey = commonService.getDictionaryCodeName("QR_CODE_SIGN_KEY", "1"); - if (StringUtils.isBlank(qrCodeSignKey)) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知秘钥"); - } - - String staffId; - try { - staffId = AESEncodeUtil.aesDecryptByBytes(AESEncodeUtil.base64Decode(URLDecoder.decode(highOrder.getGasStaffCode(),"UTF-8")), qrCodeSignKey); - } catch (Exception e) { - log.error("HighOrderController --> addOrder() error!", "收银员code解析失败"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "收银员code解析失败"); - } - - // 查询员工 - HighGasStaff gasStaff = gasStaffService.getStaffDetailById(Long.parseLong(staffId)); - if (gasStaff == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知收银员"); - } - if (gasStaff.getMerchantStoreId().equals(childOrder.getGoodsId())) { - childOrder.setGasStaffId(gasStaff.getId()); - childOrder.setGasStaffName(gasStaff.getName()); - } - } - - // 查询加油站是否开启班组 - Map classGroup = new HashMap<>(); - classGroup.put("merchantStoreId", childOrder.getGoodsId()); - classGroup.put("status", GasClassGroupTaskStatus.status1.getStatus()); - List groupTaskList = gasClassGroupTaskService.getGroupTaskList(classGroup); - if (groupTaskList.size() > 0) { - HighGasClassGroupTask groupTask = groupTaskList.get(0); - childOrder.setGasClassGroupId(groupTask.getGasClassGroupId()); - childOrder.setGasClassGroupName(groupTask.getGasClassGroupName()); - childOrder.setGasClassGroupTaskId(groupTask.getId()); - } - - // 查询门店 - HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(childOrder.getGoodsId()); - if (store == null) { - log.error("HighOrderController --> addOrder() error!", "未找到门店信息"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到门店信息"); - } - if (highOrder.getIsTyAgent() != null && highOrder.getIsTyAgent().equals(true)) { - // 查询加油站 - HighTyAgentOilStation oilStation = tyAgentOilStationService.getDetailByOilStationId(childOrder.getGoodsId()); - if (oilStation != null) { - childOrder.setGasSalesmanId(oilStation.getTySalesmanId()); - childOrder.setGasSalesmanName(oilStation.getTySalesmanName()); - childOrder.setGasAgentId(oilStation.getTyAgentId()); - childOrder.setGasAgentName(oilStation.getTyAgentName()); - childOrder.setGasOrgId(oilStation.getOrganizationId()); - childOrder.setGasOrgName(oilStation.getOrganizationName()); - } - } - - // 营销减免的金额 - BigDecimal marketingPrice = merchantAccountMarketingService.getPrice(store.getMerchantId(), MerAccountMarketingType.type3.getType(), Integer.valueOf(childOrder.getGasOilNo())); - - // 计算价格 - GasPayPriceModel priceModel = gasDiscountOilPriceService.oilPriceDiscountCompute(childOrder.getGoodsPrice(), childOrder.getGoodsId(), childOrder.getGasOilNo(), highOrder.getIsTyAgent()); - - // 使用了优惠价 - if (highDiscountUserRel != null) { - // 支付价格 - childOrder.setGoodsActualPrice(childOrder.getGoodsPrice()); - // 油价信息 - childOrder.setGasPriceGun(priceModel.getPriceGun()); - childOrder.setGasPriceVip(priceModel.getPriceGun()); - childOrder.setGasPriceOfficial(new BigDecimal("0")); - childOrder.setGasPricePlatform(priceModel.getPriceGun()); - childOrder.setGasOilLiters(priceModel.getOilLiters()); - childOrder.setGasDiscount(new BigDecimal("0")); - childOrder.setExt1(childOrder.getGasPricePlatform().toString()); - childOrder.setGasOilSubsidy(new BigDecimal("0")); - childOrder.setGasLitersPreferences(new BigDecimal("0")); - childOrder.setGasPricePreferences(priceModel.getPriceGun()); - } else { - // 支付价格 - childOrder.setGoodsActualPrice(priceModel.getPayPrice()); - // 油价信息 - childOrder.setGasPriceGun(priceModel.getPriceGun()); - childOrder.setGasPriceVip(priceModel.getPriceVip()); - childOrder.setGasPriceOfficial(priceModel.getPriceOfficial()); - childOrder.setGasPricePlatform(priceModel.getPricePlatform()); - childOrder.setGasOilLiters(priceModel.getOilLiters()); - childOrder.setGasDiscount(priceModel.getDiscount()); - childOrder.setExt1(priceModel.getPricePlatform().toString()); - childOrder.setGasOilSubsidy(priceModel.getPreferentialMargin()); - childOrder.setGasLitersPreferences(priceModel.getLitersPreferences()); - childOrder.setGasPricePreferences(priceModel.getPricePreferences()); - } - - - // 来源类型 1:平台自建 2:团油 - if (store.getSourceType().equals(1)) { - childOrder.setGoodsImg(CommonSysConst.getSysConfig().getHsgDomainName()+"/filesystem/"+store.getStoreLogo()); - } else { - childOrder.setGoodsImg(store.getStoreLogo()); - } - - childOrder.setGoodsName(store.getStoreName()); - childOrder.setGoodsSpecName("默认"); - childOrder.setTotalPrice(childOrder.getGoodsPrice().multiply(new BigDecimal(childOrder.getSaleCount().toString()))); - - // 成本价 油站价 减 营销策略价 - childOrder.setGasPriceCost(priceModel.getPriceGun().subtract(marketingPrice)); - if (marketingPrice.compareTo(new BigDecimal("0")) <= 0) { - childOrder.setGasPriceCostTotal(childOrder.getTotalPrice()); - } else { - childOrder.setGasPriceCostTotal(childOrder.getGasPriceCost().multiply(childOrder.getGasOilLiters()).setScale(2, BigDecimal.ROUND_HALF_DOWN)); - } - } - - if (childOrder.getGoodsType() == 7) { - // 查询优惠券包 - HighDiscountPackage discountPackage = discountPackageService.findDiscountPackageById(childOrder.getGoodsId().intValue()); - - if (discountPackage == null) { - log.error("HighOrderController --> addOrder() error!", ""); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到优惠券包"); - } - if (discountPackage.getStatus() != 1) { - log.error("HighOrderController --> addOrder() error!", ""); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券包不可用"); - } - if (discountPackageActualService.getStockByPackageId(discountPackage.getId()) == 0) { - log.error("HighOrderController --> addOrder() error!", ""); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "库存数量不足"); - } - - if (discountPackage.getPurchaseNum() < discountPackageActualService.userPurchaseByUserId(userInfoModel.getHighUser().getId().intValue(), discountPackage.getId())) { - log.error("HighOrderController --> addOrder() error!", ""); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "超过购买限制"); - } - - childOrder.setGoodsActualPrice(childOrder.getGoodsPrice()); - childOrder.setGoodsName(discountPackage.getTitle()); - childOrder.setGoodsImg(discountPackage.getListImg()); - childOrder.setGoodsPrice(discountPackage.getPrice()); - childOrder.setGoodsActualPrice(discountPackage.getPrice()); - childOrder.setGoodsSpecName("默认"); - } - // 汇联通充值 - if (childOrder.getGoodsType() == 8) { - if (childOrder.getGoodsPrice() == null) { - log.error("HighOrderController --> addOrder() error!", "请设置充值金额"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请设置充值金额"); - } - if (highOrder.getMemCardNo() == null) { - log.error("HighOrderController --> addOrder() error!", "请设置充值卡号"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请设置充值卡号"); - } - // 查询用户信息 - HighUser user = highUserService.findByUserId(childOrder.getGoodsId()); - if (user == null) { - log.error("HighOrderController --> addOrder() error!", "未找到用户"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, ""); - } - highOrder.setPayType(2); // 第三方平台 - childOrder.setGoodsActualPrice(childOrder.getGoodsPrice()); - childOrder.setGoodsName(user.getName()); - childOrder.setGoodsImg(user.getHeaderImg()); - childOrder.setGoodsSpecName("默认"); - } - - childOrder.setMemId(userInfoModel.getHighUser().getId()); - childOrder.setTotalPrice(childOrder.getGoodsPrice().multiply(new BigDecimal(childOrder.getSaleCount().toString()))); - childOrder.setGiveawayType(false); // 是否是赠品 0:否 1:是 - childOrder.setChildOrdeStatus(1); // 1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 - childOrder.setPraiseStatus(0); - - // 累计订单价格 - totalPrice = totalPrice.add(childOrder.getTotalPrice()); - totalActualPrice = totalActualPrice.add(childOrder.getGoodsActualPrice()); - } - - // 积分抵扣金额 - BigDecimal integralDeductionPrice = new BigDecimal(0); - if (buyPoints && highOrder.getPayGold() != null) { - integralDeductionPrice = new BigDecimal(highOrder.getPayGold()).divide(new BigDecimal(100)); - String remark = "订单" + highOrder.getOrderNo() + "购买,使用积分:" + highOrder.getPayGold(); - highUserService.goldHandle(userInfoModel.getHighUser().getId(), highOrder.getPayGold(), 2, 2, highOrder.getId() , remark); - BigDecimal payGold = new BigDecimal(highOrder.getPayGold()); - - if (payGold.compareTo(totalActualPrice.subtract(integralDeductionPrice)) < 0) { - highOrder.setPayModel(2); // 支付模式:1 金币,2 第三方平台,3 混合 - highOrder.setPayType(2); // 支付方式: 1:支付宝 2:微信 3:金币 - } - } - - if (request.getHeader("regionId") != null && request.getHeader("regionId").length() != 0) { - SecRegion region = commonService.getParentByRegion(Long.valueOf(request.getHeader("regionId"))); - if (region != null) { - BsCompany bsCompany = bsCompanyService.selectCompanyByRegion(region.getRegionId().toString()); - if (bsCompany != null) { - highOrder.setCompanyId(bsCompany.getId()); - } - } - } - - highOrder.setMerchId(request.getHeader("mchId")); - highOrder.setWhetherRebate(false); - highOrder.setTotalPrice(totalPrice); - highOrder.setPayablePrice(totalActualPrice); - - // 是否使用了优惠券 - if (highDiscountUserRel != null) { - highOrder.setMemDiscountName(highDiscountUserRel.getHighDiscount().getDiscountName()); - - // 优惠券使用范围 - if (highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type1.getType())) { - // 暂无限制 - } else if (highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type2.getType())) { - // 1:卡卷 2:金币充值 3:团油【加油站】 4: KFC 5:电影票 6:话费充值 - if (!highOrder.getHighChildOrderList().get(0).getGoodsType().equals(1)) { - log.error("HighOrderController --> addOrder() error!", "此优惠券只能购买卡券商品使用"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "此优惠券只能购买卡券商品使用"); - } - } else if (highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type3.getType())) { - if (!highOrder.getHighChildOrderList().get(0).getGoodsType().equals(6)) { - log.error("HighOrderController --> addOrder() error!", "此优惠券只能充值话费中使用"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "此优惠券只能充值话费中使用"); - } - } else if (highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type7.getType())) { - if (!highOrder.getHighChildOrderList().get(0).getGoodsType().equals(3)) { - log.error("HighOrderController --> addOrder() error!", "此优惠券只能充值话费中使用"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "此优惠券只能充值话费中使用"); - } - } else { - log.error("HighOrderController --> addOrder() error!", "暂时无法使用此优惠券"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法使用此优惠券"); - } - - // 卡卷类型 1:满减 2:抵扣 3:折扣 - if (highDiscountUserRel.getHighDiscount().getDiscountType() == 1) { - // 如果订单总额 小于 满减价格 - if (highOrder.getTotalPrice().compareTo(highDiscountUserRel.getHighDiscount().getDiscountCondition()) > 1) { - log.error("HighOrderController --> addOrder() error!", "订单未达到满减额度"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "订单未达到"+highDiscountUserRel.getHighDiscount().getDiscountCondition()+"元,无法使用此优惠券"); - } - // 订单总额 - 满减额度 - BigDecimal payablePrice = highOrder.getTotalPrice().subtract(highDiscountUserRel.getHighDiscount().getDiscountPrice()); - - highOrder.setDeductionPrice(highDiscountUserRel.getHighDiscount().getDiscountPrice()); - // 如果总额小于0 - if (payablePrice.compareTo(new BigDecimal("0")) < 0) { - highOrder.setPayablePrice(new BigDecimal("0")); - } else { - highOrder.setPayablePrice(payablePrice); - } - } - - // 卡卷类型 1:满减 2:抵扣 3:折扣 - if (highDiscountUserRel.getHighDiscount().getDiscountType() == 2) { - // 订单总额 - 满减额度 - BigDecimal payablePrice = highOrder.getTotalPrice().subtract(highDiscountUserRel.getHighDiscount().getDiscountPrice()); - highOrder.setDeductionPrice(highDiscountUserRel.getHighDiscount().getDiscountPrice()); - - // 如果总额小于0 - if (payablePrice.compareTo(new BigDecimal("0")) == -1) { - highOrder.setPayablePrice(new BigDecimal("0")); - } else { - highOrder.setPayablePrice(payablePrice); - } - } - - // 卡卷类型 1:满减 2:抵扣 3:折扣 - if (highDiscountUserRel.getHighDiscount().getDiscountType() == 3) { - // 折扣除100 - BigDecimal discountPrice = highDiscountUserRel.getHighDiscount().getDiscountPrice(); - // 订单总额 * 折扣 - BigDecimal payablePrice = highOrder.getTotalPrice().multiply(discountPrice).setScale(2, BigDecimal.ROUND_HALF_DOWN); - highOrder.setDeductionPrice(highOrder.getTotalPrice().subtract(payablePrice)); - highOrder.setPayablePrice(payablePrice); - } - } - - highOrder.setOrderNo("HF" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5)); - highOrder.setMemId(userInfoModel.getHighUser().getId()); - highOrder.setMemName(userInfoModel.getHighUser().getName()); - highOrder.setMemPhone(userInfoModel.getHighUser().getPhone()); - highOrder.setCreateTime(new Date()); - highOrder.setOrderStatus(1); - highOrder.setPrintStatus(false); - highOrder.setPrintNum(0); - highOrder.setPayPrice(highOrder.getPayablePrice().subtract(integralDeductionPrice)); - highOrder.setDeductionPrice(highOrder.getTotalPrice().subtract(highOrder.getPayPrice())); - - highOrderService.insertOrder(highOrder); - - return ResponseMsgUtil.success(highOrderService.getOrderById(highOrder.getId())); - - } catch (DeadlockLoserDataAccessException deadlockLoserDataAccessException) { - log.error("HighActivityController -> userLottery() error!", "服务器繁忙"); - return ResponseMsgUtil.builderResponse(ErrorCode.SERVER_BUSY_ERROR.getCode(),ErrorCode.SERVER_BUSY_ERROR.getMsg(),null); - - } catch (Exception e) { - log.error("HighOrderController -> addOrder() error!",e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/getOrderByOrderNo", method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "根据订单号查询订单详情") - public ResponseData getOrderByOrderNo(@RequestParam(name = "orderNo", required = true) String orderNo) { - try { - - return ResponseMsgUtil.success(highOrderService.getOrderByOrderNo(orderNo)); - - } catch (Exception e) { - log.error("HighOrderController --> getOrderByOrderNo() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/getOrderById", method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "根据id查询订单详情") - public ResponseData getOrderById(@RequestParam(name = "orderId", required = true) Long orderId) { - try { - return ResponseMsgUtil.success(highOrderService.getOrderById(orderId)); - } catch (Exception e) { - log.error("HighOrderController --> getOrderById() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/cancelOrder", method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "根据订单id 取消订单") - public ResponseData cancelOrder(@RequestParam(name = "orderId", required = true) Long orderId) { - try { - - highOrderService.cancelOrder(orderId); - - return ResponseMsgUtil.success("操作成功"); - - } catch (Exception e) { - log.error("HighOrderController --> cancelOrder() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/orderCheck", method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "根据订单id查看订单") - public ResponseData orderCheck(@RequestParam(name = "orderId", required = true) Long orderId) { - try { - - highOrderService.orderCheck(orderId); - - return ResponseMsgUtil.success("操作成功"); - - } catch (Exception e) { - log.error("HighOrderController --> cancelOrder() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/cancelOrderByOrderNo", method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "根据订单号 取消订单") - public ResponseData cancelOrderByOrderNo(@RequestParam(name = "orderNo", required = true) String orderNo) { - try { - - HighOrder order = highOrderService.getOrderByOrderNo(orderNo); - if (order == null) { - log.error("HighOrderController --> addOrder() error!", "未找到订单"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, ""); - } - highOrderService.cancelOrder(order.getId()); - - return ResponseMsgUtil.success("操作成功"); - - } catch (Exception e) { - log.error("HighOrderController --> cancelOrderByOrderNo() error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value = "/getUserOrderList", method = RequestMethod.GET) - @ResponseBody - @ApiOperation(value = "获取用户订单") - public ResponseData getUserOrderList( - @RequestParam(name = "status", required = false) String status, - @RequestParam(name = "orderNo", required = false) String orderNo, - @RequestParam(name = "pageNum", required = true) Integer pageNum, - @RequestParam(name = "pageSize", required = true) Integer pageSize, - HttpServletRequest request) { - try { - - // 用户 - SessionObject sessionObject = userCenter.getSessionObject(request); - HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); - - Map map = new HashMap<>(); - map.put("memId", userInfoModel.getHighUser().getId()); - map.put("status", status); - map.put("orderNo", orderNo); - - PageHelper.startPage(pageNum,pageSize); - return ResponseMsgUtil.success(new PageInfo<>(highOrderService.getOrderList(map))); - - } catch (Exception e) { - log.error("HighOrderController --> getUserOrderList() error!", e); - return ResponseMsgUtil.exception(e); - } - } - -} -*/ diff --git a/hai-cweb/src/main/java/com/cweb/controller/pay/CzOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/pay/CzOrderController.java deleted file mode 100644 index 89f54843..00000000 --- a/hai-cweb/src/main/java/com/cweb/controller/pay/CzOrderController.java +++ /dev/null @@ -1,556 +0,0 @@ -package com.cweb.controller.pay; - -import com.alibaba.fastjson.JSONObject; -import com.cweb.config.SysConst; -import com.cweb.config.WxMsgConfig; -import com.google.gson.JsonObject; -import com.hai.common.exception.ErrorCode; -import com.hai.common.exception.ErrorHelp; -import com.hai.common.exception.SysCode; -import com.hai.common.pay.WechatPayUtil; -import com.hai.common.pay.entity.WeChatPayReqInfo; -import com.hai.common.pay.util.MD5Util; -import com.hai.common.security.AESEncodeUtil; -import com.hai.common.security.SessionObject; -import com.hai.common.security.UserCenter; -import com.hai.common.utils.*; -import com.hai.config.CommonSysConst; -import com.hai.config.UnionPayConfig; -import com.hai.dao.HighGasOrderPushMapper; -import com.hai.dao.HighGasOrderRefundMapper; -import com.hai.entity.*; -import com.hai.enum_type.OrderPushType; -import com.hai.enum_type.RechargePayType; -import com.hai.model.HighUserModel; -import com.hai.model.ResponseData; -import com.hai.service.*; -import com.hai.service.pay.impl.GoodsOrderServiceImpl; -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 javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.PrintWriter; -import java.math.BigDecimal; -import java.util.*; -import java.util.concurrent.ThreadLocalRandom; - -@Controller -@RequestMapping(value = "/czOrder") -@Api(value = "充值回调") -public class CzOrderController { - - private static Logger log = LoggerFactory.getLogger(TuanYouController.class); - - @Resource - private UserCenter userCenter; - - @Resource - private OutRechargeOrderService outRechargeOrderService; - - @Resource - private OutRechargeChildOrderService outRechargeChildOrderService; - - @Resource - private BsRequestRecordService bsRequestRecordService; - - @Resource - private HighUserService highUserService; - - @Resource - private UnionPayConfig unionPayConfig; - - @Resource - private HighUserPayPasswordService highUserPayPasswordService; - - @Resource - private HighUserCardService highUserCardService; - - @Resource - private HighGasOrderPushMapper highGasOrderPushMapper; - - @Resource - private WechatPayUtil wechatPayUtil; - - @Resource - private ApiOrderRecordService apiOrderRecordService; - - @Resource - private BsIntegralRebateService bsIntegralRebateService; - - @Resource - private HighGoldRecService highGoldRecService; - - @RequestMapping(value = "/rechargeCallbackByJj", method = RequestMethod.POST) - @ApiOperation(value = "尖椒充值回调") - @ResponseBody - public void rechargeCallbackByJj(@RequestBody String reqBodyStr, HttpServletRequest request, HttpServletResponse response) { - try { - - JSONObject dataObject = JSONObject.parseObject(reqBodyStr, JSONObject.class); - - // 推送记录 - HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); - highGasOrderPush.setType(OrderPushType.type2.getType()); - highGasOrderPush.setOrderNo(dataObject.getString("out_order_id")); - highGasOrderPush.setCreateTime(new Date()); - highGasOrderPush.setCode(dataObject.getString("status")); - highGasOrderPush.setRequestContent(JSONObject.toJSONString(dataObject)); - highGasOrderPush.setReturnContent(dataObject.toJSONString()); - highGasOrderPushMapper.insert(highGasOrderPush); - - - // 1 尖椒 2 龙阅 - dataObject.put("orderNo" , dataObject.getString("out_order_id")); - - OutRechargeChildOrder childOrder = outRechargeChildOrderService.findByOrderNo(dataObject.getString("out_order_id")); - - OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderId(childOrder.getParentOrderId()); - - BsRequestRecord bsRequestRecord = bsRequestRecordService.findRequestRecordByOrderNo(childOrder.getOrderNo()); - - bsRequestRecord.setReturnContent(String.valueOf(dataObject)); - bsRequestRecord.setUpdateTime(new Date()); - bsRequestRecordService.updateRequestRecord(bsRequestRecord); - - // 判断是否充值成功 - if (dataObject.getInteger("status") == 3) { - if (rechargeOrder.getRechargeStatus() ==201) { - new Thread(() -> { - HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId()); - WxMsgConfig.rechargedSuccess( - rechargeOrder.getRechargeContent() + "充值成功", - String.valueOf(rechargeOrder.getPayRealPrice()), - rechargeOrder.getOrderNo(), - rechargeOrder.getFinishTime(), - RechargePayType.getNameByType(rechargeOrder.getPayType()), - highUser.getOpenId()); - }).start(); - } - - childOrder.setStatus(101); - rechargeOrder.setRechargeStatus(202); - rechargeOrder.setPayStatus(100); - - outRechargeOrderService.updateOrder(rechargeOrder); - outRechargeChildOrderService.updateOrder(childOrder); - if (rechargeOrder.getPayType() == 6) { - apiOrderRecord(rechargeOrder); - } - - } else { - callbackResult(childOrder , rechargeOrder); - } - - response.setCharacterEncoding("UTF-8"); - response.setContentType("text/html;charset=utf-8"); - PrintWriter writer= response.getWriter(); - writer.write("SUCCESS"); - - - } catch (Exception e) { - log.error("WechatPayController --> wechatNotify() error!", e); - } - } - - @RequestMapping(value = "/rechargeCallbackByLy", method = RequestMethod.POST) - @ApiOperation(value = "龙阅充值回调") - @ResponseBody - public void rechargeCallbackByLy( - @RequestParam(name = "out_trade_num", required = true) String out_trade_num, - @RequestParam(name = "userid", required = true) Long userid, - @RequestParam(name = "state", required = true) Long state, - @RequestBody String reqBodyStr , - HttpServletRequest request, HttpServletResponse response) { - try { - // 推送记录 - HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); - highGasOrderPush.setType(OrderPushType.type2.getType()); - highGasOrderPush.setOrderNo(out_trade_num); - highGasOrderPush.setCreateTime(new Date()); - highGasOrderPush.setCode(state.toString()); - highGasOrderPush.setReturnContent(reqBodyStr); - highGasOrderPushMapper.insert(highGasOrderPush); - - OutRechargeChildOrder childOrder = outRechargeChildOrderService.findByOrderNo(out_trade_num); - - OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderId(childOrder.getParentOrderId()); - - BsRequestRecord bsRequestRecord = bsRequestRecordService.findRequestRecordByOrderNo(childOrder.getOrderNo()); - - bsRequestRecord.setReturnContent(reqBodyStr); - bsRequestRecord.setUpdateTime(new Date()); - bsRequestRecordService.updateRequestRecord(bsRequestRecord); - - - // 判断是否充值成功 - if (state == 1) { - - if (rechargeOrder.getRechargeStatus() ==201) { - new Thread(() -> { - HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId()); - WxMsgConfig.rechargedSuccess( - rechargeOrder.getRechargeContent() + "充值成功", - String.valueOf(rechargeOrder.getPayRealPrice()), - rechargeOrder.getOrderNo(), - rechargeOrder.getFinishTime(), - RechargePayType.getNameByType(rechargeOrder.getPayType()), - highUser.getOpenId()); - }).start(); - } - childOrder.setStatus(101); - rechargeOrder.setRechargeStatus(202); - rechargeOrder.setPayStatus(100); - rechargeOrder.setFinishTime(new Date()); - - outRechargeOrderService.updateOrder(rechargeOrder); - outRechargeChildOrderService.updateOrder(childOrder); - if (rechargeOrder.getPayType() == 6) { - apiOrderRecord(rechargeOrder); - } - } else { - callbackResult(childOrder , rechargeOrder); - } - - response.setCharacterEncoding("UTF-8"); - response.setContentType("text/html;charset=utf-8"); - PrintWriter writer= response.getWriter(); - writer.write("SUCCESS"); - - - } catch (Exception e) { - log.error("WechatPayController --> wechatNotify() error!", e); - } - } - - @RequestMapping(value = "/rechargeCallbackByCy", method = RequestMethod.POST) - @ApiOperation(value = "城宇充值回调") - @ResponseBody - public void rechargeCallbackByCy(@RequestBody String reqBodyStr, HttpServletRequest request, HttpServletResponse response) { - try { - - JSONObject dataObject = JSONObject.parseObject(reqBodyStr, JSONObject.class); - - // 推送记录 - HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); - highGasOrderPush.setType(OrderPushType.type2.getType()); - highGasOrderPush.setOrderNo(dataObject.getString("out_order_id")); - highGasOrderPush.setCreateTime(new Date()); - highGasOrderPush.setCode(dataObject.getString("status")); - highGasOrderPush.setRequestContent(JSONObject.toJSONString(dataObject)); - highGasOrderPush.setReturnContent(dataObject.toJSONString()); - highGasOrderPushMapper.insert(highGasOrderPush); -// -// -// // 1 尖椒 2 龙阅 -// dataObject.put("orderNo" , dataObject.getString("out_order_id")); -// -// OutRechargeChildOrder childOrder = outRechargeChildOrderService.findByOrderNo(dataObject.getString("out_order_id")); -// -// OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderId(childOrder.getParentOrderId()); -// -// BsRequestRecord bsRequestRecord = bsRequestRecordService.findRequestRecordByOrderNo(childOrder.getOrderNo()); -// -// bsRequestRecord.setReturnContent(String.valueOf(dataObject)); -// bsRequestRecord.setUpdateTime(new Date()); -// bsRequestRecordService.updateRequestRecord(bsRequestRecord); -// -// // 判断是否充值成功 -// if (dataObject.getInteger("status") == 3) { -// new Thread(() -> { -// HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId()); -// WxMsgConfig.rechargedSuccess( -// rechargeOrder.getRechargeContent() + "充值成功", -// String.valueOf(rechargeOrder.getPayRealPrice()), -// rechargeOrder.getOrderNo(), -// rechargeOrder.getFinishTime(), -// RechargePayType.getNameByType(rechargeOrder.getPayType()), -// highUser.getOpenId()); -// }).start(); -// childOrder.setStatus(101); -// rechargeOrder.setRechargeStatus(202); -// rechargeOrder.setPayStatus(100); -// -// outRechargeOrderService.updateOrder(rechargeOrder); -// outRechargeChildOrderService.updateOrder(childOrder); -// if (rechargeOrder.getPayType() == 6) { -// apiOrderRecord(rechargeOrder); -// } -// -// } else { -// callbackResult(childOrder , rechargeOrder); -// } - - response.setCharacterEncoding("UTF-8"); - response.setContentType("text/html;charset=utf-8"); - PrintWriter writer= response.getWriter(); - writer.write("SUCCESS"); - - - } catch (Exception e) { - log.error("WechatPayController --> wechatNotify() error!", e); - } - } - - // 回调结果处理 - private void callbackResult(OutRechargeChildOrder childOrder , OutRechargeOrder rechargeOrder) throws Exception { - - // 101:充值成功 102: 充值中 103:充值失败 104 未充值 - // 订单支付状态 : 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 - if (childOrder.getStatus() == 102 && rechargeOrder.getPayStatus() == 102) { - - Date rechargeTime = rechargeOrder.getCreateTimed(); - Date currentTime = new Date(); -// 当前时间减去充值时间 - int hours = (int) ((currentTime.getTime() - rechargeTime.getTime()) / (1000 * 60 * 60)); - -// // 判断快充 并且 充值时间小于6 -// if (rechargeOrder.getRechargeType() == 1 && hours < 6) { -// outRechargeOrderService.pollRequest(rechargeOrder); -// return; -// } - // 判断慢充 并且 充值时间小于72 - if (hours < 72) { - outRechargeOrderService.pollRequest(rechargeOrder); - return; - } - - rechargeOrder.setRechargeStatus(203); - childOrder.setStatus(103); - outRechargeOrderService.updateOrder(rechargeOrder); - outRechargeChildOrderService.updateOrder(childOrder); - - outRechargeOrderService.refundOrder(rechargeOrder.getId()); - - - new Thread(() -> { - HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId()); - WxMsgConfig.rechargedFail( - rechargeOrder.getRechargeContent() + "充值失败", - String.valueOf(rechargeOrder.getPayRealPrice()), - highUser.getOpenId()); - }).start(); - - } - - - } - - @RequestMapping(value="/apiCallBack",method = RequestMethod.POST) - @ResponseBody - @ApiOperation(value = "apiCallBack") - public String test(@RequestBody String reqBodyStr) { - try { - if (StringUtils.isBlank(reqBodyStr)) { - log.error("orderToPay error!", "参数错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - - System.out.println("reqBodyStr"); - - return "SUCCESS"; - - - } catch (Exception e) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - } - - - @RequestMapping(value="/orderToPayByWx",method = RequestMethod.POST) - @ResponseBody - @ApiOperation(value = "微信订单支付发起支付") - public ResponseData orderToPayByWx(@RequestBody String reqBodyStr) { - try { - if (StringUtils.isBlank(reqBodyStr)) { - log.error("orderToPay error!", "参数错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - JSONObject jsonObject = JSONObject.parseObject(reqBodyStr); - Long orderId = jsonObject.getLong("orderId"); - Integer openIdType = jsonObject.getInteger("openIdType"); // openId类型 1:小程序 2:公众号 - String openId = jsonObject.getString("openId"); // openId - if (orderId == null || StringUtils.isBlank(openId)) { - log.error("orderToPay error!", "参数错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - - // 订单 - OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); - if (order == null) { - log.error("orderToPay error!", "未找到订单信息"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息"); - } - - // 订单状态 : 订单支付状态 : 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 - if (order.getPayStatus() != 101) { - log.error("orderToPayByWx error!", "无法支付,订单不处于待支付状态"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态"); - } - - Map map = new HashMap<>(); - map.put("orderNo", order.getOrderNo()); - map.put("payPrice", order.getPayRealPrice()); - map.put("orderScene", "RECHARGE_ORDER"); - map.put("body","充值话费"); - map.put("subject","充值话费"); - - //微信支付 - String nonce_str = MD5Util.MD5Encode(String.valueOf(ThreadLocalRandom.current().nextInt(10000)), "UTF-8"); - int total_fee = MathUtils.objectConvertBigDecimal(map.get("payPrice")).multiply(new BigDecimal("100")).intValue(); - WeChatPayReqInfo weChatPayReqInfo = new WeChatPayReqInfo(); - weChatPayReqInfo.setAppid(SysConst.getSysConfig().getWxMchAppId()); //公众号id - weChatPayReqInfo.setMch_id(SysConst.getSysConfig().getWxMchId()); //商户号 - if (openIdType != null && openIdType.equals(2)) { - weChatPayReqInfo.setSub_appid("wxa075e8509802f826"); //商户号公众号 - } else { - weChatPayReqInfo.setSub_appid(SysConst.getSysConfig().getWxSubAppId());//小程序 - } - weChatPayReqInfo.setSub_mch_id("1614670195"); - weChatPayReqInfo.setSub_openid(openId); - weChatPayReqInfo.setNonce_str(nonce_str); //随机字符串 - weChatPayReqInfo.setBody(map.get("body").toString()); //商品描述 - weChatPayReqInfo.setOut_trade_no(map.get("orderNo").toString()); //商户订单号 - weChatPayReqInfo.setTotal_fee(total_fee); //总金额 - weChatPayReqInfo.setSpbill_create_ip("139.159.177.244"); //终端ip - weChatPayReqInfo.setNotify_url(SysConst.getSysConfig().getNotifyUrl()); //通知url - weChatPayReqInfo.setTrade_type("JSAPI"); //交易类型 - weChatPayReqInfo.setAttach(map.get("orderScene").toString()); - weChatPayReqInfo.setProfit_sharing("N"); - //附加数据,区分订单类型 - Map payMap = new HashMap<>(); - - payMap.put("app_id", weChatPayReqInfo.getSub_appid()); - payMap.put("api_key",SysConst.getSysConfig().getWxApiKey()); - payMap.put("unified_order_url",SysConst.getSysConfig().getWxUnifiedOrderUrl()); - SortedMap sortedMap = wechatPayUtil.goWechatPay(weChatPayReqInfo,payMap); - return ResponseMsgUtil.success(sortedMap); - } catch (Exception e) { - log.error("orderToPay error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value="/hltUnionCardPay",method = RequestMethod.POST) - @ResponseBody - @ApiOperation(value = "工会卡支付") - public ResponseData hltUnionCardPay(@RequestBody JSONObject body,HttpServletRequest request) { - try { - // 用户 - SessionObject sessionObject = userCenter.getSessionObject(request); - HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); - - if (body == null - || body.getLong("orderId") == null - || StringUtils.isBlank(body.getString("password")) - || StringUtils.isBlank(body.getString("cardNo")) - ) { - log.error("orderToPay error!", "参数错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - - // 订单 - OutRechargeOrder order = outRechargeOrderService.findByOrderId(body.getLong("orderId")); - - if (order == null) { - log.error("hltUnionCardPay error!", "未找到订单信息"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息"); - } - - // 订单状态 : 订单支付状态 : 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 - if (order.getPayStatus() != 101) { - log.error("hltUnionCardPay error!", "无法支付,订单不处于待支付状态"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态"); - } - - // 查询用户支付密码 - HighUserPayPassword userPayPassword = highUserPayPasswordService.getDetailByUser(order.getUserId()); - - if (userPayPassword == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_SET_USER_PAY_PWD, ""); - } - if (StringUtils.isBlank(body.getString("password"))) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_ENTER_USER_PAY_PWD, ""); - } - // 校验支付密码 - if (!AESEncodeUtil.aesEncrypt(body.getString("password")).equals(userPayPassword.getPassword())) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.USER_PAY_PWD_ERROR, ""); - } - - // 查询用户与卡号的关系 - HighUserCard userCard = highUserCardService.getDetailByUserCardNo(userInfoModel.getHighUser().getId(), body.getString("cardNo")); - if (userCard == null) { - log.error("hltUnionCardPay() ERROR", "未绑定卡号"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未绑定卡号"); - } - - outRechargeOrderService.hltUnionCardPay(userCard, order); - - return ResponseMsgUtil.success(outRechargeOrderService.findByOrderId(body.getLong("orderId"))); - } catch (Exception e) { - log.error("hltUnionCardPay error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value="/orderToUnionPay",method = RequestMethod.POST) - @ResponseBody - @ApiOperation(value = "订单支付发起银联支付") - public ResponseData orderToUnionPay(@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); - Long orderId = jsonObject.getLong("orderId"); - - if (orderId == null) { - log.error("orderToPay error!", "参数错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - // 订单 - OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); - if (order == null) { - log.error("hltUnionCardPay error!", "未找到订单信息"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息"); - } - - // 订单状态 : 订单支付状态 : 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 - if (order.getPayStatus() != 101) { - log.error("hltUnionCardPay error!", "无法支付,订单不处于待支付状态"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态"); - } - - return ResponseMsgUtil.success(unionPayConfig.upPreOrder(UnionPayConfig.MER_ID2, UnionPayConfig.TERM_ID2, order.getOrderNo(), order.getPayRealPrice(), "话费充值", CommonSysConst.getSysConfig().getUnionPayTelNotifyUrl(), request)); - - } catch (Exception e) { - log.error("orderToPay error!", e); - return ResponseMsgUtil.exception(e); - } - } - - - private void apiOrderRecord(OutRechargeOrder rechargeOrder) { - Map orderMap = new HashMap<>(); - orderMap.put("orderId" , rechargeOrder.getId()); - - // 查询是否用重复订单 - ApiOrderRecord apiOrderRecord = apiOrderRecordService.queryOrderResult(orderMap); - - apiOrderRecord.setStatus(100); - apiOrderRecord.setRequestTime(new Date()); - apiOrderRecordService.updateOrderRecord(apiOrderRecord); - - } -} 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 deleted file mode 100644 index 0b85bbcf..00000000 --- a/hai-cweb/src/main/java/com/cweb/controller/pay/OrderController.java +++ /dev/null @@ -1,1219 +0,0 @@ -package com.cweb.controller.pay; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.cweb.config.SysConst; -import com.cweb.config.WxMsgConfig; -import com.hai.common.exception.ErrorCode; -import com.hai.common.exception.ErrorHelp; -import com.hai.common.exception.SysCode; -import com.hai.common.pay.WechatPayUtil; -import com.hai.common.pay.entity.OrderType; -import com.hai.common.pay.entity.WeChatPayReqInfo; -import com.hai.common.pay.util.MD5Util; -import com.hai.common.security.AESEncodeUtil; -import com.hai.common.security.Base64Util; -import com.hai.common.security.SessionObject; -import com.hai.common.security.UserCenter; -import com.hai.common.utils.*; -import com.hai.config.*; -import com.hai.entity.*; -import com.hai.enum_type.*; -import com.hai.model.*; -import com.hai.service.*; -import com.wechat.pay.contrib.apache.httpclient.WechatPayHttpClientBuilder; -import com.wechat.pay.contrib.apache.httpclient.auth.AutoUpdateCertificatesVerifier; -import com.wechat.pay.contrib.apache.httpclient.auth.PrivateKeySigner; -import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Credentials; -import com.wechat.pay.contrib.apache.httpclient.auth.WechatPay2Validator; -import com.wechat.pay.contrib.apache.httpclient.util.PemUtil; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.apache.commons.lang3.StringUtils; -import org.apache.http.HttpEntity; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.util.EntityUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import java.io.*; -import java.math.BigDecimal; -import java.security.*; -import java.security.spec.PKCS8EncodedKeySpec; -import java.util.*; -import java.util.concurrent.ThreadLocalRandom; - -/** - * - * @Title: - * @Description: 对订单的操作 - * @author: 魏真峰 - * @param: - * @return: - * @throws - */ -@Controller -@RequestMapping("/order") -@Api(value = "对订单的操作") -public class OrderController { - - private static Logger log = LoggerFactory.getLogger(OrderController.class); - - @Autowired - private UserCenter userCenter; - - @Resource - private WechatPayUtil wechatPayUtil; - - @Resource - private HighOrderService highOrderService; - - @Resource - private HighCouponService highCouponService; - - @Resource - private HighMerchantStoreService merchantStoreService; - - @Resource - private HighMerchantAccountService merchantAccountService; - - @Resource - private HighMerchantTripartitePlatformService tripartitePlatformService; - - @Resource - private HighQzOrderService highQzOrderService; - - @Resource - private HighUserPayPasswordService highUserPayPasswordService; - - @Resource - private HighUserCardService highUserCardService; - - @Resource - private HighUserService highUserService; - - @Resource - private UnionPayConfig unionPayConfig; - - @Resource - private UnionStagingPayConfig unionStagingPayConfig; - - @Resource - private SecConfigService configService; - - @Resource - private HighGasChannelConfigService gasChannelConfigService; - /** - * - * @Title: orderToPay - * @Description: 订单支付发起支付 - * @author: 魏真峰 - * @param: [pageNum, pageSize] - * @return: com.shinwoten.haj.common.model.ResponseData - * @throws - */ - @RequestMapping(value="/orderToPay",method = RequestMethod.POST) - @ResponseBody - @ApiOperation(value = "订单支付发起支付") - public ResponseData orderToPay(@RequestBody String reqBodyStr) { - try { - if (StringUtils.isBlank(reqBodyStr)) { - log.error("orderToPay error!", "参数错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - JSONObject jsonObject = JSONObject.parseObject(reqBodyStr); - Long orderId = jsonObject.getLong("orderId"); - Integer openIdType = jsonObject.getInteger("openIdType"); // openId类型 1:小程序 2:公众号 - String orderScene = jsonObject.getString("orderScene"); // 订单类型 - String openId = jsonObject.getString("openId"); // openId - if ( orderId == null || StringUtils.isBlank(orderScene) || StringUtils.isBlank(openId)) { - log.error("orderToPay error!", "参数错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_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:金币充值 3:加油站 - for (HighChildOrder childOrder : order.getHighChildOrderList()) { - if (!childOrder.getGiveawayType() && childOrder.getGoodsType() == 1) { - HighCoupon coupon = highCouponService.getCouponById(childOrder.getGoodsId()); - // 支付类型:1.微信支付 2.金币支付 - if (coupon.getPayType() != 1 && !coupon.getBuyPoints()) { - log.error("OrderController --> orderToPay() ERROR", "只支持微信支持"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, coupon.getCouponName() + ",只支持微信支付"); - } - } - - if (childOrder.getGoodsType() == 3) { - if (highOrderService.getGasTheDayOrderNum(order.getMemId()) >= 1) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已达到每日加油次数上限"); - } - // 查询加油站 - HighMerchantStoreModel store = merchantStoreService.getMerchantStoreById(childOrder.getGoodsId()); - if (store == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已达到每日加油次数上限"); - } - // 来源类型 1:平台自建 2:团油 - /* if (store.getSourceType().equals(2)) { - // 查询账号余额 - 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, "无法进行支付,请联系平台客服"); - } - } - } - }*/ - - // 来源类型 1:平台自建 2:团油 - if (store.getSourceType().equals(MerchantStoreSourceType.type3.getNumber())) { - BigDecimal account = new BigDecimal("0"); - // 查询账号余额 - HighMerchantAccount merAccount = merchantAccountService.getMerAccountDetail(store.getMerchantId()); - if (merAccount != null) { - account = merAccount.getAmounts().subtract(merchantAccountService.countMerGasOilAmount(store.getMerchantId())); - } - // 客户加油金额 大于 商户账号余额 - if(order.getTotalPrice().compareTo(account) == 1) { - log.error("OrderController --> orderToPay() ERROR", "暂时无法进行支付,请联系平台客服"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法进行支付,请联系平台客服"); - } - } - } - } - - Map map = new HashMap<>(); - map.put("orderNo", order.getOrderNo()); - map.put("payPrice", order.getPayPrice()); - map.put("orderScene", orderScene); - map.put("body","购买产品"); - map.put("subject","购买产品"); - - // 是否分账 - String profitSharing = "N"; - BigDecimal profitSharingRatio = new BigDecimal("1"); - - // 微信支付 - String nonce_str = MD5Util.MD5Encode(String.valueOf(ThreadLocalRandom.current().nextInt(10000)), "UTF-8"); - int total_fee = MathUtils.objectConvertBigDecimal(map.get("payPrice")).multiply(new BigDecimal("100")).intValue(); - WeChatPayReqInfo weChatPayReqInfo = new WeChatPayReqInfo(); - weChatPayReqInfo.setAppid(SysConst.getSysConfig().getWxMchAppId()); //公众号id - weChatPayReqInfo.setMch_id(SysConst.getSysConfig().getWxMchId()); //商户号 - if (openIdType != null && openIdType.equals(2)) { - weChatPayReqInfo.setSub_appid("wxa075e8509802f826"); //商户号公众号 - } else { - weChatPayReqInfo.setSub_appid(SysConst.getSysConfig().getWxSubAppId());//商户号 - } - - if (order.getHighChildOrderList().get(0).getGoodsType() == 1) { - //子商户号 - weChatPayReqInfo.setSub_mch_id(SysConst.getSysConfig().getWxSubMchId()); - - HighCoupon coupon = highCouponService.getCouponById(order.getHighChildOrderList().get(0).getGoodsId()); - // 支付类型:1.微信支付 2.金币支付 - if (coupon.getCouponSource() != null && coupon.getCouponSource().equals(4)) { - weChatPayReqInfo.setSub_mch_id(WxOrderConfig.MCH_ID_1634835264); - } - - } else if (order.getHighChildOrderList().get(0).getGoodsType() == 8) { - weChatPayReqInfo.setSub_mch_id(SysConst.getSysConfig().getWxGzSubMchId());//商户号 - - } else if (order.getHighChildOrderList().get(0).getGoodsType() == 3) { - // 查询油站 - HighMerchantStoreModel store = merchantStoreService.getMerchantStoreById(order.getHighChildOrderList().get(0).getGoodsId()); - if (store == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的加油站"); - } - - // 交易平台余额是否重置 - if (store.getSourceType().equals(MerchantStoreSourceType.type1.getNumber())) { - - } else if (store.getSourceType().equals(MerchantStoreSourceType.type2.getNumber())) { - BigDecimal account = new BigDecimal("0"); - // 查询账号余额 - HighMerchantAccount merAccount = merchantAccountService.getMerAccountDetail(store.getMerchantId()); - if (merAccount != null) { - account = merAccount.getAmounts().subtract(merchantAccountService.countMerGasOilAmount(store.getMerchantId())); - } - // 客户加油金额 大于 商户账号余额 - if(order.getTotalPrice().compareTo(account) == 1) { - log.error("OrderController --> orderToPay() ERROR", "暂时无法进行支付,请联系平台客服"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法进行支付,请联系平台客服"); - } - } else if (store.getSourceType().equals(MerchantStoreSourceType.type3.getNumber())) { - BigDecimal account = new BigDecimal("0"); - // 查询账号余额 - HighMerchantAccount merAccount = merchantAccountService.getMerAccountDetail(store.getMerchantId()); - if (merAccount != null) { - account = merAccount.getAmounts().subtract(merchantAccountService.countMerGasOilAmount(store.getMerchantId())); - } - // 客户加油金额 大于 商户账号余额 - if(order.getTotalPrice().compareTo(account) == 1) { - log.error("OrderController --> orderToPay() ERROR", "暂时无法进行支付,请联系平台客服"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法进行支付,请联系平台客服"); - } - } else if (store.getSourceType().equals(MerchantStoreSourceType.type4.getNumber())) { - BigDecimal account = new BigDecimal("0"); - // 查询账号余额 - HighMerchantAccount merAccount = merchantAccountService.getMerAccountDetail(store.getMerchantId()); - if (merAccount != null) { - account = merAccount.getAmounts().subtract(merchantAccountService.countMerGasOilAmount(store.getMerchantId())); - } - // 客户加油金额 大于 商户账号余额 - if(order.getTotalPrice().compareTo(account) == 1) { - log.error("OrderController --> orderToPay() ERROR", "暂时无法进行支付,请联系平台客服"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法进行支付,请联系平台客服"); - } - } - - - if (store.getSourceType().equals(MerchantStoreSourceType.type1.getNumber())) { - // 查询支付配置 - HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type1,GasChannelPayPlatformType.type1 ); - if (gasChannelConfig == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置支付参数,请稍后重试!"); - } - weChatPayReqInfo.setSub_mch_id(gasChannelConfig.getPayPlatformMerNo()); - profitSharing = gasChannelConfig.getProfitSharingStatus().equals(true)?"Y":"N"; - - if (store.getSourceType().equals(1)) { - // 预存类型 0:非预存 1:预存门店 - if (store.getPrestoreType().equals(0)) { - // 第三方平台 - HighMerchantTripartitePlatform merTripartitePlatform = tripartitePlatformService.getDetail(store.getMerchantId(), 1); - if (merTripartitePlatform != null) { - weChatPayReqInfo.setSub_mch_id(merTripartitePlatform.getPlatformMerNumber()); - // 是否分账 - profitSharing = merTripartitePlatform.getProfitSharingStatus().equals(true)?"Y":"N"; - } - } - } - - } else if (store.getSourceType().equals(MerchantStoreSourceType.type2.getNumber())) { - - // 查询支付配置 - HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type2,GasChannelPayPlatformType.type1 ); - if (gasChannelConfig == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置支付参数,请稍后重试!"); - } - weChatPayReqInfo.setSub_mch_id(gasChannelConfig.getPayPlatformMerNo()); - profitSharing = gasChannelConfig.getProfitSharingStatus().equals(true)?"Y":"N"; - - } else if (store.getSourceType().equals(MerchantStoreSourceType.type3.getNumber())) { - - // 查询支付配置 - HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type3,GasChannelPayPlatformType.type1 ); - if (gasChannelConfig == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置支付参数,请稍后重试!"); - } - weChatPayReqInfo.setSub_mch_id(gasChannelConfig.getPayPlatformMerNo()); - profitSharing = gasChannelConfig.getProfitSharingStatus().equals(true)?"Y":"N"; - - } else if (store.getSourceType().equals(MerchantStoreSourceType.type4.getNumber())) { - // 查询支付配置 - HighGasChannelConfig gasChannelConfig = gasChannelConfigService.getConfig(GasChannel.type4,GasChannelPayPlatformType.type1 ); - if (gasChannelConfig == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置支付参数,请稍后重试!"); - } - weChatPayReqInfo.setSub_mch_id(gasChannelConfig.getPayPlatformMerNo()); - profitSharing = gasChannelConfig.getProfitSharingStatus().equals(true)?"Y":"N"; - - } else { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未配置支付参数,请稍后重试!"); - } - } else { - //子商户号 - weChatPayReqInfo.setSub_mch_id(SysConst.getSysConfig().getWxSubMchId()); - } - - // weChatPayReqInfo.setOpenid(openId); - weChatPayReqInfo.setSub_openid(openId); - weChatPayReqInfo.setNonce_str(nonce_str); //随机字符串 - weChatPayReqInfo.setBody(map.get("body").toString()); //商品描述 - weChatPayReqInfo.setOut_trade_no(map.get("orderNo").toString()); //商户订单号 - weChatPayReqInfo.setTotal_fee(total_fee); //总金额 - weChatPayReqInfo.setSpbill_create_ip("122.9.135.148"); //终端ip - weChatPayReqInfo.setNotify_url(SysConst.getSysConfig().getNotifyUrl()); //通知url - weChatPayReqInfo.setTrade_type("JSAPI"); //交易类型 - weChatPayReqInfo.setAttach(map.get("orderScene").toString()); - weChatPayReqInfo.setProfit_sharing(profitSharing); - - //附加数据,区分订单类型 - Map payMap = new HashMap<>(); - - payMap.put("app_id", weChatPayReqInfo.getSub_appid()); - payMap.put("api_key",SysConst.getSysConfig().getWxApiKey()); - payMap.put("unified_order_url",SysConst.getSysConfig().getWxUnifiedOrderUrl()); - SortedMap sortedMap = wechatPayUtil.goWechatPay(weChatPayReqInfo,payMap); - - //order.setProfitSharingRatio(profitSharingRatio); - order.setProfitSharingStatus(profitSharing.equals("Y")?true:false); - order.setAccountMerchantNum(weChatPayReqInfo.getSub_mch_id()); - order.setExt1(weChatPayReqInfo.getSub_appid()); - highOrderService.updateOrderDetail(order); - return ResponseMsgUtil.success(sortedMap); - } catch (Exception e) { - log.error("orderToPay error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value="/orderToGoldPay",method = RequestMethod.POST) - @ResponseBody - @ApiOperation(value = "订单支付发起金币支付") - public ResponseData orderToGoldPay(@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); - Long orderId = jsonObject.getLong("orderId"); - String password = jsonObject.getString("password"); - - if (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, ""); - } - - 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() == 2) { - HighCoupon coupon = highCouponService.getCouponById(childOrder.getGoodsId()); - // 支付类型:1.微信支付 2.金币支付 - if (coupon.getPayType() != 2) { - log.error("OrderController --> orderToPay() ERROR", "只支持积分支付"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, coupon.getCouponName() + ",只支持积分支付"); - } - } - - if (childOrder.getGoodsType() == 3) { - if (highOrderService.getGasTheDayOrderNum(order.getMemId()) >= 1) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已达到每日加油次数上限"); - } - // 查询加油站 - HighMerchantStoreModel store = merchantStoreService.getMerchantStoreById(childOrder.getGoodsId()); - if (store == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已达到每日加油次数上限"); - } - // 来源类型 1:平台自建 2:团油 - if (store.getSourceType().equals(2)) { - // 查询账号余额 - 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, "暂时无法进行支付,请联系平台客服"); - } - } - }*/ - } - - // 来源类型 1:平台自建 2:团油 - if (store.getSourceType().equals(MerchantStoreSourceType.type3.getNumber()) - || store.getSourceType().equals(MerchantStoreSourceType.type4.getNumber())) { - BigDecimal account = new BigDecimal("0"); - // 查询账号余额 - HighMerchantAccount merAccount = merchantAccountService.getMerAccountDetail(store.getMerchantId()); - if (merAccount != null) { - account = merAccount.getAmounts().subtract(merchantAccountService.countMerGasOilAmount(store.getMerchantId())); - } - // 客户加油金额 大于 商户账号余额 - if(order.getTotalPrice().compareTo(account) == 1) { - log.error("OrderController --> orderToPay() ERROR", "暂时无法进行支付,请联系平台客服"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法进行支付,请联系平台客服"); - } - } - } - - } - - highOrderService.goldPayOrder(order.getMemId(), 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="/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, "已达到每日加油次数上限"); - } - - // 查询加油站 - HighMerchantStoreModel store = merchantStoreService.getMerchantStoreById(childOrder.getGoodsId()); - if (store == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已达到每日加油次数上限"); - } -/* // 来源类型 1:平台自建 2:团油 - if (store.getSourceType().equals(2)) { - // 查询账号余额 - 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, "无法进行支付,请联系平台客服"); - } - } - } - }*/ - // 来源类型 1:平台自建 2:团油 - if (store.getSourceType().equals(MerchantStoreSourceType.type3.getNumber())) { - BigDecimal account = new BigDecimal("0"); - // 查询账号余额 - HighMerchantAccount merAccount = merchantAccountService.getMerAccountDetail(store.getMerchantId()); - if (merAccount != null) { - account = merAccount.getAmounts().subtract(merchantAccountService.countMerGasOilAmount(store.getMerchantId())); - } - // 客户加油金额 大于 商户账号余额 - if(order.getTotalPrice().compareTo(account) == 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="/fleetOilCardPay",method = RequestMethod.POST) - @ResponseBody - @ApiOperation(value = "车队油卡支付") - public ResponseData fleetOilCardPay(@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"); -// String carLicensePlate = jsonObject.getString("carLicensePlate"); -// -// 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, "已达到每日加油次数上限"); -// } -// -// // 查询加油站 -// HighMerchantStoreModel store = merchantStoreService.getMerchantStoreById(childOrder.getGoodsId()); -// if (store == null) { -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已达到每日加油次数上限"); -// } -// // 来源类型 1:平台自建 2:团油 -// if (store.getSourceType().equals(2)) { -// // 查询账号余额 -// 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, "无法进行支付,请联系平台客服"); -// } -// } -// } -// } -// // 来源类型 1:平台自建 2:团油 -// if (store.getSourceType().equals(MerchantStoreSourceType.type3.getNumber())) { -// BigDecimal account = new BigDecimal("0"); -// // 查询账号余额 -// HighMerchantAccount merAccount = merchantAccountService.getMerAccountDetail(store.getMerchantId()); -// if (merAccount != null) { -// account = merAccount.getAmounts().subtract(merchantAccountService.countMerGasOilAmount(store.getMerchantId())); -// } -// // 客户加油金额 大于 商户账号余额 -// if(order.getTotalPrice().compareTo(account) == 1) { -// log.error("OrderController --> orderToPay() ERROR", "暂时无法进行支付,请联系平台客服"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法进行支付,请联系平台客服"); -// } -// } -// } -// } -// -// highOrderService.fleetOilCardPayOrder(userCard.getId(), order.getId(), carLicensePlate); -// -// 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 = "汇联通工会卡支付") - public ResponseData hltUnionCardPay(@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, "已达到每日加油次数上限"); - } - // 查询加油站 - HighMerchantStoreModel store = merchantStoreService.getMerchantStoreById(childOrder.getGoodsId()); - if (store == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已达到每日加油次数上限"); - } - // 来源类型 1:平台自建 2:团油 - if (store.getSourceType().equals(2)) { - // 查询账号余额 - 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, "无法进行支付,请联系平台客服"); - } - }*/ - } - } - // 来源类型 1:平台自建 2:团油 - if (store.getSourceType().equals(MerchantStoreSourceType.type3.getNumber())) { - BigDecimal account = new BigDecimal("0"); - // 查询账号余额 - HighMerchantAccount merAccount = merchantAccountService.getMerAccountDetail(store.getMerchantId()); - if (merAccount != null) { - account = merAccount.getAmounts().subtract(merchantAccountService.countMerGasOilAmount(store.getMerchantId())); - } - // 客户加油金额 大于 商户账号余额 - if(order.getTotalPrice().compareTo(account) == 1) { - log.error("OrderController --> orderToPay() ERROR", "暂时无法进行支付,请联系平台客服"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法进行支付,请联系平台客服"); - } - } - } - } - - highOrderService.hltUnionCardPay(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="/unionPay",method = RequestMethod.POST) - @ResponseBody - @ApiOperation(value = "银联支付") - public ResponseData unionPay(@RequestBody String reqBodyStr,HttpServletRequest request) { - try { - if (StringUtils.isBlank(reqBodyStr)) { - log.error("orderToPay error!", "参数错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - JSONObject jsonObject = JSONObject.parseObject(reqBodyStr); - Long orderId = jsonObject.getLong("orderId"); - if ( orderId == null) { - log.error("orderToPay error!", "参数错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_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:金币充值 3:加油站 - for (HighChildOrder childOrder : order.getHighChildOrderList()) { - if (childOrder.getGiveawayType() == false && childOrder.getGoodsType() == 1) { - HighCoupon coupon = highCouponService.getCouponById(childOrder.getGoodsId()); - // 支付类型:1.微信支付 2.金币支付 -// if (coupon.getPayType() != 1) { -// log.error("OrderController --> orderToPay() ERROR", "只支持微信支持"); -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, coupon.getCouponName() + ",只支持微信支付"); -// } - } - - if (childOrder.getGoodsType() == 3) { - if (highOrderService.getGasTheDayOrderNum(order.getMemId()) >= 1) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已达到每日加油次数上限"); - } - // 查询加油站 - HighMerchantStoreModel store = merchantStoreService.getMerchantStoreById(childOrder.getGoodsId()); - if (store == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已达到每日加油次数上限"); - } - // 来源类型 1:平台自建 2:团油 - if (store.getSourceType().equals(2)) { - // 查询账号余额 - 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, "无法进行支付,请联系平台客服"); - } - }*/ - } - } - // 来源类型 1:平台自建 2:团油 - if (store.getSourceType().equals(MerchantStoreSourceType.type3.getNumber())) { - BigDecimal account = new BigDecimal("0"); - // 查询账号余额 - HighMerchantAccount merAccount = merchantAccountService.getMerAccountDetail(store.getMerchantId()); - if (merAccount != null) { - account = merAccount.getAmounts().subtract(merchantAccountService.countMerGasOilAmount(store.getMerchantId())); - } - // 客户加油金额 大于 商户账号余额 - if(order.getTotalPrice().compareTo(account) == 1) { - log.error("OrderController --> orderToPay() ERROR", "暂时无法进行支付,请联系平台客服"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法进行支付,请联系平台客服"); - } - } - } - } - - return ResponseMsgUtil.success(unionPayConfig.upPreOrder(UnionPayConfig.MER_ID3, UnionPayConfig.TERM_ID3, order.getOrderNo(), order.getPayPrice(), "购买商品", CommonSysConst.getSysConfig().getUnionPayNotifyUrl(), request)); - } catch (Exception e) { - log.error("orderToPay error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value="/unionStagingPay",method = RequestMethod.POST) - @ResponseBody - @ApiOperation(value = "银联分期支付") - public ResponseData unionStagingPay(@RequestBody String reqBodyStr,HttpServletRequest request) { - try { - if (StringUtils.isBlank(reqBodyStr)) { - log.error("orderToPay error!", "参数错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - JSONObject jsonObject = JSONObject.parseObject(reqBodyStr); - Long orderId = jsonObject.getLong("orderId"); - if ( orderId == null) { - log.error("orderToPay error!", "参数错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_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:金币充值 3:加油站 - for (HighChildOrder childOrder : order.getHighChildOrderList()) { - if (childOrder.getGiveawayType() == false && childOrder.getGoodsType() == 1) { - // 卡券详情 - HighCoupon coupon = highCouponService.getCouponById(childOrder.getGoodsId()); - if (coupon == null) { - log.error("OrderController --> orderToPay() ERROR", "只支持微信支持"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, coupon.getCouponName() + ",只支持微信支付"); - } - } - } - - String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) - +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) - + DateUtil.format(new Date(), DateUtil.YMDHMS) - + IDGenerator.nextId(6); - - order.setPaySerialNo(orgTrace); - highOrderService.updateOrderDetail(order); - - // 分期 - JSONObject advancePay = unionStagingPayConfig.advancePay(order.getPaySerialNo(), order.getPaySerialNo(), order.getPayPrice(), CommonSysConst.getSysConfig().getUnionStagingPayNotifyUrl(), request); - if (advancePay == null) { - log.error("OrderController --> orderToPay() ERROR", ""); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "唤起分期支付失败"); - } - if (!advancePay.getString("sysRetCode").equals("000000")) { - log.error("OrderController --> orderToPay() ERROR", ""); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "唤起分期支付失败"); - } - return ResponseMsgUtil.success(advancePay); - - } catch (Exception e) { - log.error("orderToPay error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value="/qzOrderToPay",method = RequestMethod.POST) - @ResponseBody - @ApiOperation(value = "千猪订单支付发起支付") - public ResponseData qzOrderToPay(@RequestBody String reqBodyStr) { - try { - if (StringUtils.isBlank(reqBodyStr)) { - log.error("orderToPay error!", "参数错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - JSONObject jsonObject = JSONObject.parseObject(reqBodyStr); - String orderNo = jsonObject.getString("orderNo"); - String source = jsonObject.getString("source"); - String openId = jsonObject.getString("openId"); - if (StringUtils.isBlank(orderNo) || StringUtils.isBlank(source) || StringUtils.isBlank(openId)) { - log.error("orderToPay error!", "参数错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - - // 组装千猪订单 - HighOrder qzOrder = highQzOrderService.assemblyQzOrder(orderNo, source); - if (qzOrder != null) { - Map map = new HashMap<>(); - map.put("orderNo", qzOrder.getOrderNo()); - map.put("payPrice", qzOrder.getPayPrice()); - map.put("orderScene", source); - map.put("body","购买产品"); - map.put("subject","购买产品"); - - //微信支付 - String nonce_str = MD5Util.MD5Encode(String.valueOf(ThreadLocalRandom.current().nextInt(10000)), "UTF-8"); - int total_fee = MathUtils.objectConvertBigDecimal(map.get("payPrice")).multiply(new BigDecimal("100")).intValue(); - // int total_fee = 1; - WeChatPayReqInfo weChatPayReqInfo = new WeChatPayReqInfo(); - weChatPayReqInfo.setAppid(SysConst.getSysConfig().getWxMchAppId()); //公众号id - weChatPayReqInfo.setMch_id(SysConst.getSysConfig().getWxMchId()); //商户号 - weChatPayReqInfo.setSub_appid(SysConst.getSysConfig().getWxSubAppId()); //商户号 - weChatPayReqInfo.setSub_mch_id(SysConst.getSysConfig().getWxSubMchId()); //子商户号 - - // weChatPayReqInfo.setOpenid(openId); - weChatPayReqInfo.setSub_openid(openId); - weChatPayReqInfo.setNonce_str(nonce_str); //随机字符串 - weChatPayReqInfo.setBody(map.get("body").toString()); //商品描述 - weChatPayReqInfo.setOut_trade_no(map.get("orderNo").toString()); //商户订单号 - weChatPayReqInfo.setTotal_fee(total_fee); //总金额 - weChatPayReqInfo.setSpbill_create_ip("139.159.177.244"); //终端ip - weChatPayReqInfo.setNotify_url(SysConst.getSysConfig().getNotifyUrl()); //通知url - weChatPayReqInfo.setTrade_type("JSAPI"); //交易类型 - weChatPayReqInfo.setAttach(map.get("orderScene").toString()); - weChatPayReqInfo.setProfit_sharing("N"); - //附加数据,区分订单类型 - Map payMap = new HashMap<>(); - - payMap.put("app_id",SysConst.getSysConfig().getWxSubAppId()); - payMap.put("api_key",SysConst.getSysConfig().getWxApiKey()); - payMap.put("unified_order_url",SysConst.getSysConfig().getWxUnifiedOrderUrl()); - SortedMap sortedMap = wechatPayUtil.goWechatPay(weChatPayReqInfo,payMap); - return ResponseMsgUtil.success(sortedMap); - } - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的订单号"); - } catch (Exception e) { - log.error("orderToPay error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value="/orderToH5Pay",method = RequestMethod.POST) - @ResponseBody - @ApiOperation(value = "H5订单下单") - public ResponseData orderToH5Pay(@RequestBody String reqBodyStr) { - try { - /* if (StringUtils.isBlank(reqBodyStr)) { - log.error("orderToPay error!", "参数错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - JSONObject jsonObject = JSONObject.parseObject(reqBodyStr); - Long orderId = jsonObject.getLong("orderId"); - if ( orderId == null) { - log.error("orderToPay error!", "参数错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - }*/ - - //微信支付 - String nonce_str = MD5Util.MD5Encode(String.valueOf(ThreadLocalRandom.current().nextInt(10000)), "UTF-8"); - //int total_fee = MathUtils.objectConvertBigDecimal(map.get("payPrice")).multiply(new BigDecimal("100")).intValue(); - int total_fee = MathUtils.objectConvertBigDecimal(1).multiply(new BigDecimal("100")).intValue(); - WeChatPayReqInfo weChatPayReqInfo = new WeChatPayReqInfo(); - weChatPayReqInfo.setAppid(SysConst.getSysConfig().getWxMchAppId()); //公众号id - weChatPayReqInfo.setMch_id(SysConst.getSysConfig().getWxMchId()); //商户号 - weChatPayReqInfo.setSub_appid(SysConst.getSysConfig().getWxSubAppId()); //商户号 - weChatPayReqInfo.setSub_mch_id(SysConst.getSysConfig().getWxSubMchId()); //子商户号 - - weChatPayReqInfo.setNonce_str(nonce_str); //随机字符串 - weChatPayReqInfo.setBody("购买商品"); //商品描述 - weChatPayReqInfo.setOut_trade_no(String.valueOf(new Date().getTime())); //商户订单号 - weChatPayReqInfo.setTotal_fee(total_fee); //总金额 - weChatPayReqInfo.setSpbill_create_ip("139.159.177.244"); //终端ip - weChatPayReqInfo.setNotify_url(SysConst.getSysConfig().getNotifyUrl()); //通知url - weChatPayReqInfo.setTrade_type("MWEB"); //交易类型 - //weChatPayReqInfo.setAttach(map.get("orderScene").toString()); //附加数据,区分订单类型 - Map payMap = new HashMap<>(); - payMap.put("app_id",SysConst.getSysConfig().getWxSubAppId()); - payMap.put("api_key",SysConst.getSysConfig().getWxApiKey()); - payMap.put("unified_order_url",SysConst.getSysConfig().getWxUnifiedOrderUrl()); - SortedMap sortedMap = wechatPayUtil.goWechatPay(weChatPayReqInfo,payMap); - return ResponseMsgUtil.success(sortedMap); -/*1· - Map param = new HashMap<>(); - param.put("appid", SysConst.getSysConfig().getWxMchAppId()); - param.put("mchid", SysConst.getSysConfig().getWxSubMchId()); - param.put("description", "购买商品"); - param.put("out_trade_no", String.valueOf(new Date().getTime())); - param.put("notify_url", SysConst.getSysConfig().getNotifyUrl()); - - Map amountMap = new HashMap<>(); - amountMap.put("total", 1); - param.put("amount", amountMap); - - Map sceneInfoMap = new HashMap<>(); - sceneInfoMap.put("payer_client_ip", "127.0.0.1"); - - Map h5InfoMap = new HashMap<>(); - h5InfoMap.put("type", "Wap"); - sceneInfoMap.put("h5_info", h5InfoMap); - - param.put("scene_info", sceneInfoMap); - - Map header = new HashMap<>(); - String post = getToken("POST", "/v3/pay/transactions/h5", JSONObject.toJSONString(param)); - header.put("Accept","application/json"); - header.put("Authorization", "WECHATPAY2-SHA256-RSA2048 " + post); - - JSONObject object = HttpsUtils.doPost("https://api.mch.weixin.qq.com/v3/pay/transactions/h5", param, header); - return ResponseMsgUtil.success(object);*/ - } catch (Exception e) { - log.error("orderToPay error!", e); - return ResponseMsgUtil.exception(e); - } - } - - String getToken(String method, String url, String body) throws UnsupportedEncodingException, SignatureException, NoSuchAlgorithmException, InvalidKeyException, FileNotFoundException { - - long timeMillis = System.currentTimeMillis(); - String nonceStr = String.valueOf(timeMillis); - long timestamp = System.currentTimeMillis() / 1000; - String message = buildMessage(method, url, timestamp, nonceStr, body); - PrivateKey privateKey = PemUtil.loadPrivateKey(new FileInputStream("G:/hurui-project/hai-parent/hai-cweb/src/main/resources/privatekey/apiclient_key.pem")); - String signature = sign(privateKey,message.getBytes("utf-8")); - - return "mchid=\"" + SysConst.getSysConfig().getWxSubMchId() + "\"," - + "nonce_str=\"" + nonceStr + "\"," - + "timestamp=\"" + timestamp + "\"," - + "serial_no=\"" + "1B08DC2A078B0B1F77A65C97C445AAD545B5EAA6" + "\"," - + "signature=\"" + signature + "\""; - } - - String sign(PrivateKey privateKey,byte[] message) throws SignatureException, NoSuchAlgorithmException, InvalidKeyException { - Signature sign = Signature.getInstance("SHA256withRSA"); - sign.initSign(privateKey); - sign.update(message); - return Base64.getEncoder().encodeToString(sign.sign()); - } - - String buildMessage(String method, String url, long timestamp, String nonceStr, String body) { - return method + "" - + url + "" - + timestamp + "" - + nonceStr + "" - + body + ""; - } -} diff --git a/hai-cweb/src/main/java/com/cweb/controller/pay/QzOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/pay/QzOrderController.java deleted file mode 100644 index ba8b7205..00000000 --- a/hai-cweb/src/main/java/com/cweb/controller/pay/QzOrderController.java +++ /dev/null @@ -1,108 +0,0 @@ -package com.cweb.controller.pay; - -import com.alibaba.fastjson.JSONObject; -import com.hai.common.security.AESEncodeUtil; -import com.hai.config.CommonSysConst; -import com.hai.config.WxOrderConfig; -import com.hai.dao.HighGasOrderRefundMapper; -import com.hai.entity.HighChildOrder; -import com.hai.entity.HighGasOrderRefund; -import com.hai.entity.HighOrder; -import com.hai.model.OrderRefundModel; -import com.hai.service.HighOrderService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.PrintWriter; -import java.util.Date; - -@Controller -@RequestMapping(value = "/qianzhu") -@Api(value = "千猪回调") -public class QzOrderController { - - private static Logger log = LoggerFactory.getLogger(QzOrderController.class); - - @Resource - private HighOrderService highOrderService; - - - @RequestMapping(value = "/orderNotify", method = RequestMethod.POST) - @ApiOperation(value = "千猪订单回调") - public void orderNotify(@RequestBody String reqBodyStr,HttpServletRequest request, HttpServletResponse response) { - try { - log.info(reqBodyStr); - JSONObject dataObject = JSONObject.parseObject(reqBodyStr, JSONObject.class); - HighOrder order = highOrderService.getOrderByOrderNo(dataObject.getString("orderNo")); - if (order != null) { - JSONObject data = dataObject.getJSONObject("data"); - for (HighChildOrder childOrder : order.getHighChildOrderList()) { - // 4:KFC肯德基 5:电影票 - if (childOrder.getGoodsType() == 4) { - // 10:已出票 -5:已取消 -3:部分取消 -10:退款 - if (dataObject.getInteger("eventType") == -5) { - // 微信退款 - OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(order.getPaySerialNo(), data.getBigDecimal("cancelReason"), data.getBigDecimal("cancelReason")); - if(orderRefundModel.getResult_code().equals("SUCCESS")) { - childOrder.setChildOrderStatus(5); - order.setOrderStatus(5); - order.setCancelTime(new Date()); - order.setCancelRemarks(data.getString("cancelReason")); - highOrderService.updateOrderDetail(order); - } - } - - if (dataObject.getInteger("eventType") == -10) { - // 微信退款 - OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(order.getPaySerialNo(), data.getBigDecimal("refundAmount"), data.getBigDecimal("refundAmount")); - if(orderRefundModel.getResult_code().equals("SUCCESS")) { - childOrder.setChildOrderStatus(4); - order.setOrderStatus(4); - //order.setRefundTime(new Date()); - //order.setRefundPrice(data.getBigDecimal("refundAmount")); - highOrderService.updateOrderDetail(order); - } - } - } - - if (childOrder.getGoodsType() == 5) { - - // 5:已支付(默认不发) 10:已出票 -5:已取消 15:交易成功 - if (dataObject.getInteger("eventType") == -5) { - childOrder.setChildOrderStatus(5); - order.setOrderStatus(5); - order.setCancelTime(new Date()); - order.setCancelRemarks(data.getString("cancelReason")); - } - - if (dataObject.getInteger("eventType") == 15) { - childOrder.setChildOrderStatus(3); - order.setOrderStatus(3); - order.setFinishTime(new Date()); - } - } - } - - highOrderService.updateOrder(order); - - response.setCharacterEncoding("UTF-8"); - response.setContentType("text/html;charset=utf-8"); - PrintWriter writer= response.getWriter(); - writer.write("success"); - } - } catch (Exception e) { - log.error("WechatPayController --> wechatNotify() error!", e); - } - } - -} diff --git a/hai-cweb/src/main/java/com/cweb/controller/pay/ThirdOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/pay/ThirdOrderController.java deleted file mode 100644 index b80889f7..00000000 --- a/hai-cweb/src/main/java/com/cweb/controller/pay/ThirdOrderController.java +++ /dev/null @@ -1,256 +0,0 @@ -package com.cweb.controller.pay; - -import com.alibaba.fastjson.JSONObject; -import com.cweb.config.SysConst; -import com.hai.common.exception.ErrorCode; -import com.hai.common.exception.ErrorHelp; -import com.hai.common.exception.SysCode; -import com.hai.common.pay.WechatPayUtil; -import com.hai.common.pay.entity.OrderType; -import com.hai.common.pay.entity.WeChatPayReqInfo; -import com.hai.common.pay.util.MD5Util; -import com.hai.common.security.AESEncodeUtil; -import com.hai.common.security.SessionObject; -import com.hai.common.security.UserCenter; -import com.hai.common.utils.MathUtils; -import com.hai.common.utils.ResponseMsgUtil; -import com.hai.config.CommonSysConst; -import com.hai.config.QianZhuConfig; -import com.hai.config.UnionPayConfig; -import com.hai.entity.*; -import com.hai.model.HighUserModel; -import com.hai.model.ResponseData; -import com.hai.service.HighOrderService; -import com.hai.service.HighUserCardService; -import com.hai.service.HighUserPayPasswordService; -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.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import java.math.BigDecimal; -import java.util.HashMap; -import java.util.Map; -import java.util.SortedMap; -import java.util.concurrent.ThreadLocalRandom; - -@Controller -@RequestMapping(value = "/thirdOrder") -@Api(value = "第三方订单支付接口") -public class ThirdOrderController { - - private static Logger log = LoggerFactory.getLogger(TuanYouController.class); - - @Resource - private UserCenter userCenter; - - @Resource - private HighOrderService highOrderService; - - @Resource - private WechatPayUtil wechatPayUtil; - - @Resource - private HighUserCardService highUserCardService; - - @Resource - private UnionPayConfig unionPayConfig; - - @Resource - private HighUserPayPasswordService highUserPayPasswordService; - - @RequestMapping(value="/orderToPayByWx",method = RequestMethod.POST) - @ResponseBody - @ApiOperation(value = "微信订单支付发起支付") - public ResponseData orderToPayByWx(@RequestBody String reqBodyStr) { - try { - if (StringUtils.isBlank(reqBodyStr)) { - log.error("orderToPay error!", "参数错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - JSONObject jsonObject = JSONObject.parseObject(reqBodyStr); - Long orderId = jsonObject.getLong("orderId"); - Integer openIdType = jsonObject.getInteger("openIdType"); // openId类型 1:小程序 2:公众号 - String openId = jsonObject.getString("openId"); // openId - if (orderId == null || StringUtils.isBlank(openId)) { - log.error("orderToPay error!", "参数错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - - // 订单 - HighOrder order = highOrderService.getOrderById(jsonObject.getLong("orderId")); - - if (order == null) { - log.error("orderToPay error!", "未找到订单信息"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息"); - } - - // 订单状态 : 订单支付状态 : 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 - if (order.getOrderStatus() != 1) { - log.error("orderToPayByWx error!", "无法支付,订单不处于待支付状态"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态"); - } - - Map map = new HashMap<>(); - map.put("orderNo", order.getOrderNo()); - map.put("payPrice", order.getPayRealPrice()); - if (order.getHighChildOrderList().get(0).getGoodsType() == 4) { - map.put("orderScene", OrderType.KFC_ORDER.getModuleCode()); - } else if (order.getHighChildOrderList().get(0).getGoodsType() == 9) { - map.put("orderScene", OrderType.STARBUCKS_ORDER.getModuleCode()); - } else if (order.getHighChildOrderList().get(0).getGoodsType() == 10) { - map.put("orderScene", OrderType.THIRD_ORDER.getModuleCode()); - } - - // 肯德基订单 星巴克订单 - map.put("body", "购买第三方产品"); - map.put("subject","购买第三方产品"); - - //微信支付 - String nonce_str = MD5Util.MD5Encode(String.valueOf(ThreadLocalRandom.current().nextInt(10000)), "UTF-8"); - int total_fee = MathUtils.objectConvertBigDecimal(map.get("payPrice")).multiply(new BigDecimal("100")).intValue(); - WeChatPayReqInfo weChatPayReqInfo = new WeChatPayReqInfo(); - weChatPayReqInfo.setAppid(SysConst.getSysConfig().getWxMchAppId()); //公众号id - weChatPayReqInfo.setMch_id(SysConst.getSysConfig().getWxMchId()); //商户号 - if (openIdType != null && openIdType.equals(2)) { - weChatPayReqInfo.setSub_appid("wxa075e8509802f826"); //商户号公众号 - } else { - weChatPayReqInfo.setSub_appid(SysConst.getSysConfig().getWxSubAppId());//小程序 - } - weChatPayReqInfo.setSub_mch_id("1614670195"); - weChatPayReqInfo.setSub_openid(openId); - weChatPayReqInfo.setNonce_str(nonce_str); //随机字符串 - weChatPayReqInfo.setBody(map.get("body").toString()); //商品描述 - weChatPayReqInfo.setOut_trade_no(map.get("orderNo").toString()); //商户订单号 - weChatPayReqInfo.setTotal_fee(total_fee); //总金额 - weChatPayReqInfo.setSpbill_create_ip("139.159.177.244"); //终端ip - weChatPayReqInfo.setNotify_url(SysConst.getSysConfig().getNotifyUrl()); //通知url - weChatPayReqInfo.setTrade_type("JSAPI"); //交易类型 - weChatPayReqInfo.setAttach(map.get("orderScene").toString()); - weChatPayReqInfo.setProfit_sharing("N"); - //附加数据,区分订单类型 - Map payMap = new HashMap<>(); - - payMap.put("app_id", weChatPayReqInfo.getSub_appid()); - payMap.put("api_key",SysConst.getSysConfig().getWxApiKey()); - payMap.put("unified_order_url",SysConst.getSysConfig().getWxUnifiedOrderUrl()); - SortedMap sortedMap = wechatPayUtil.goWechatPay(weChatPayReqInfo,payMap); - return ResponseMsgUtil.success(sortedMap); - } catch (Exception e) { - log.error("orderToPay error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value="/hltUnionCardPay",method = RequestMethod.POST) - @ResponseBody - @ApiOperation(value = "工会卡支付") - public ResponseData hltUnionCardPay(@RequestBody JSONObject body, HttpServletRequest request) { - try { - // 用户 - SessionObject sessionObject = userCenter.getSessionObject(request); - HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); - - if (body == null - || body.getLong("orderId") == null - || StringUtils.isBlank(body.getString("password")) - || StringUtils.isBlank(body.getString("cardNo")) - ) { - log.error("orderToPay error!", "参数错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - - // 查询用户与卡号的关系 - HighUserCard userCard = highUserCardService.getDetailByUserCardNo(userInfoModel.getHighUser().getId(), body.getString("cardNo")); - if (userCard == null) { - log.error("hltUnionCardPay() ERROR", "未绑定卡号"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未绑定卡号"); - } - - // 订单 - HighOrder order = highOrderService.getOrderById(body.getLong("orderId")); - - if (order == null) { - log.error("hltUnionCardPay error!", "未找到订单信息"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息"); - } - - // 订单状态 : 订单支付状态 : 1.待支付 2.已支付 3.已完成 4.已取消 5.已退款 - if (order.getOrderStatus() != 1) { - log.error("hltUnionCardPay error!", "无法支付,订单不处于待支付状态"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态"); - } - - // 查询用户支付密码 - HighUserPayPassword userPayPassword = highUserPayPasswordService.getDetailByUser(order.getMemId()); - - if (userPayPassword == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_SET_USER_PAY_PWD, ""); - } - if (StringUtils.isBlank(body.getString("password"))) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_ENTER_USER_PAY_PWD, ""); - } - // 校验支付密码 - if (!AESEncodeUtil.aesEncrypt(body.getString("password")).equals(userPayPassword.getPassword())) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.USER_PAY_PWD_ERROR, ""); - } - - highOrderService.hltUnionCardPayByThirdProduct(userCard, order.getId()); - - return ResponseMsgUtil.success(order); - } catch (Exception e) { - log.error("hltUnionCardPay error!", e); - return ResponseMsgUtil.exception(e); - } - } - - @RequestMapping(value="/orderToUnionPay",method = RequestMethod.POST) - @ResponseBody - @ApiOperation(value = "订单支付发起银联支付") - public ResponseData orderToUnionPay(@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); - Long orderId = jsonObject.getLong("orderId"); - - if (orderId == null) { - log.error("orderToPay error!", "参数错误"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - // 订单 - HighOrder order = highOrderService.getOrderById(orderId); - if (order == null) { - log.error("hltUnionCardPay error!", "未找到订单信息"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息"); - } - - // 订单状态 : 订单支付状态 : 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 - if (order.getOrderStatus() != 1) { - log.error("hltUnionCardPay error!", "无法支付,订单不处于待支付状态"); - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态"); - } - - return ResponseMsgUtil.success(unionPayConfig.upPreOrder(UnionPayConfig.MER_ID2, UnionPayConfig.TERM_ID2, order.getOrderNo(), order.getPayRealPrice(), "购买第三方产品", CommonSysConst.getSysConfig().getUnionPayNotifyUrl(), request)); - - } catch (Exception e) { - log.error("orderToPay error!", e); - return ResponseMsgUtil.exception(e); - } - } - -} diff --git a/hai-cweb/src/main/java/com/cweb/controller/pay/TuanYouController.java b/hai-cweb/src/main/java/com/cweb/controller/pay/TuanYouController.java deleted file mode 100644 index f9d3e9ee..00000000 --- a/hai-cweb/src/main/java/com/cweb/controller/pay/TuanYouController.java +++ /dev/null @@ -1,228 +0,0 @@ -package com.cweb.controller.pay; - -import com.alibaba.fastjson.JSONObject; -import com.hai.common.exception.ErrorCode; -import com.hai.common.exception.ErrorHelp; -import com.hai.common.exception.SysCode; -import com.hai.common.security.AESEncodeUtil; -import com.hai.common.utils.DateUtil; -import com.hai.common.utils.ResponseMsgUtil; -import com.hai.config.CommonSysConst; -import com.hai.config.HuiLianTongUnionCardConfig; -import com.hai.config.UnionPayConfig; -import com.hai.config.WxOrderConfig; -import com.hai.dao.HighGasOrderRefundMapper; -import com.hai.entity.HighChildOrder; -import com.hai.entity.HighGasOrderRefund; -import com.hai.entity.HighOrder; -import com.hai.enum_type.OrderPayTypeEnum; -import com.hai.model.OrderRefundModel; -import com.hai.model.ResponseData; -import com.hai.service.HighOilCardService; -import com.hai.service.HighOrderService; -import com.hai.service.HighUserService; -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 javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.*; -import java.math.BigDecimal; -import java.security.*; -import java.text.SimpleDateFormat; -import java.util.*; - -@Controller -@RequestMapping(value = "/tuanyou") -@Api(value = "团油回调") -public class TuanYouController { - - private static Logger log = LoggerFactory.getLogger(TuanYouController.class); - - @Resource - private HighOrderService highOrderService; - - @Resource - private HighGasOrderRefundMapper highGasOrderRefundMapper; - - @Resource - private HighUserService highUserService; - - @Resource - private HighOilCardService oilCardService; - - @RequestMapping(value = "/orderPaymentNotify", method = RequestMethod.POST) - @ApiOperation(value = "订单支付回调") - public void orderPaymentNotify(HttpServletRequest request, HttpServletResponse response) { - try { - - - } catch (Exception e) { - log.error("WechatPayController --> wechatNotify() error!", e); - } - } - - - @RequestMapping(value = "/orderRefundNotify", method = RequestMethod.POST) - @ApiOperation(value = "订单退款回调") - @ResponseBody - public void orderRefundNotify(@RequestBody String reqBodyStr,HttpServletRequest request, HttpServletResponse response) { - try { - log.info(reqBodyStr); - HighGasOrderRefund highGasOrderRefund = new HighGasOrderRefund(); - highGasOrderRefund.setCreateTime(new Date()); - highGasOrderRefund.setReturnContent(reqBodyStr); - highGasOrderRefundMapper.insert(highGasOrderRefund); - - JSONObject dataObject = JSONObject.parseObject(reqBodyStr, JSONObject.class); - String dataStr = AESEncodeUtil.aesDecryptByBytes(AESEncodeUtil.base64Decode(dataObject.getString("data")), CommonSysConst.getSysConfig().getTuanYouAppSecret()); - JSONObject object = JSONObject.parseObject(dataStr); - - // 查询订单 - HighOrder order = highOrderService.getOrderByOrderNo(object.getString("thirdOrderNo")); - - // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 6.退款中 7.拒绝退款 - if (order != null) { - if (order.getOrderStatus() == 2 || order.getOrderStatus() == 3 || order.getOrderStatus() == 6 || order.getOrderStatus() == 7) { - // 退单结果 true:成功 false:失败 - if (object.getBoolean("refundResult") == true && order != null) { - - if (order.getPayType() == 2) { - OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(order.getPaySerialNo(), order.getPayRealPrice(), order.getPayRealPrice()); - if(orderRefundModel.getResult_code().equals("SUCCESS")) { - order.setOrderStatus(4); - //order.setRefundTime(new Date()); - //order.setRefundPrice(order.getPayRealPrice()); - highOrderService.updateOrderDetail(order); - } - } else if (order.getPayType() == 3){ - String remark = "订单" + order.getOrderNo() + "退款,退还积分:" + order.getPayGold(); - // 积分退款 - highUserService.goldHandle(order.getMemId(), order.getPayGold(),1, 3, order.getId() , remark); - order.setOrderStatus(4); - //order.setRefundTime(new Date()); - //order.setRefundPrice(order.getPayRealPrice()); - highOrderService.updateOrderDetail(order); - - } else if (order.getPayType() == 4) { - String refundOrderNo = String.valueOf(System.currentTimeMillis()); - JSONObject refund = HuiLianTongUnionCardConfig.refund(refundOrderNo, order.getPaySerialNo()); - if(!refund.getString("respCode").equals("0000")) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR,refund.getString("respMessage")); - } - JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(refund.getString("data")); - if (consumptionResult.getBoolean("success") != true) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "交易失败!"+consumptionResult.getString("message")); - } - order.setOrderStatus(4); - //order.setRefundTime(new Date()); - //order.setRefundPrice(order.getPayRealPrice()); - highOrderService.updateOrderDetail(order); - } else if (order.getPayType() == 5) { - - Calendar startTime = Calendar.getInstance(); - startTime.set(Calendar.HOUR_OF_DAY, 00); - startTime.set(Calendar.MINUTE, 00); - startTime.set(Calendar.SECOND, 00); - - Calendar endTime = Calendar.getInstance(); - startTime.set(Calendar.HOUR_OF_DAY, 23); - startTime.set(Calendar.MINUTE, 59); - startTime.set(Calendar.SECOND, 59); - - // 订单是否处于当日的订单 - if (DateUtil.isEffectiveDate(order.getPayTime(), startTime.getTime(), endTime.getTime())) { - // 订单撤销 - JSONObject refund = UnionPayConfig.cancel(UnionPayConfig.MER_ID3, UnionPayConfig.TERM_ID3, order.getOrderNo(), order.getPaySerialNo()); - System.out.println(refund.toJSONString()); - if (!refund.getString("resultcode").equals("00") || !refund.getString("resultcode").equals("W6")) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refund.getString("returnmsg")); - } - - order.setOrderStatus(4); - //order.setRefundTime(new Date()); - //order.setRefundPrice(order.getPayRealPrice()); - highOrderService.updateOrderDetail(order); - - } else { - // 订单退款 - JSONObject refund = UnionPayConfig.zwrefund(UnionPayConfig.MER_ID3, UnionPayConfig.TERM_ID3, order.getOrderNo(), order.getPaySerialNo(), order.getPayRealPrice().multiply(new BigDecimal("100")).longValue()); - System.out.println(refund.toJSONString()); - if (!refund.getString("resultcode").equals("00") || !refund.getString("resultcode").equals("W6")) { - JSONObject refund2 = UnionPayConfig.zwrefund(UnionPayConfig.MER_ID1, UnionPayConfig.TERM_ID1, order.getOrderNo(), order.getPaySerialNo(), order.getPayRealPrice().multiply(new BigDecimal("100")).longValue()); - if (!refund2.getString("resultcode").equals("00") || !refund.getString("resultcode").equals("W6")) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refund2.getString("returnmsg")); - } - } - - order.setOrderStatus(4); - //order.setRefundTime(new Date()); - //order.setRefundPrice(order.getPayRealPrice()); - highOrderService.updateOrderDetail(order); - - } - } else if (order.getPayType().equals(OrderPayTypeEnum.type7.getType())) { - // 油卡退款 - oilCardService.refund(order.getOrderNo()); - } - - } else if (!object.getBoolean("refundResult") == true && order != null) { - order.setOrderStatus(7); - //order.setRefusalRefundContent(object.getString("refundFailReason")); - highOrderService.updateOrderDetail(order); - } - } - } - - } catch (Exception e) { - log.error("WechatPayController --> wechatNotify() error!", e); - } finally { - response.setCharacterEncoding("UTF-8"); - response.setContentType("text/html;charset=utf-8"); - PrintWriter writer= null; - try { - writer = response.getWriter(); - } catch (IOException e) { - e.printStackTrace(); - } - writer.write("success"); - } - } - - @RequestMapping(value = "/abnormalOrderRefund", method = RequestMethod.POST) - @ApiOperation(value = "异常订单退款") - @ResponseBody - public ResponseData abnormalOrderRefund(@RequestBody JSONObject body) { - try { - if (StringUtils.isNotBlank(body.getString("orderNo"))) { - // 查询订单 - HighOrder order = highOrderService.getOrderByOrderNo(body.getString("orderNo")); - // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 6.退款中 7.拒绝退款 - if (order != null && order.getOrderStatus() == 2) { - OrderRefundModel orderRefundModel = WxOrderConfig.orderToRefund(order.getPaySerialNo(), order.getPayRealPrice(), order.getPayRealPrice()); - if(orderRefundModel.getResult_code().equals("SUCCESS")) { - for (HighChildOrder childOrder : order.getHighChildOrderList()) { - childOrder.setChildOrderStatus(4); - } - order.setOrderStatus(4); - //order.setRefundTime(new Date()); - //order.setRefundPrice(order.getPayRealPrice()); - highOrderService.updateOrder(order); - return ResponseMsgUtil.success("退款成功"); - } - } - } - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败"); - - } catch (Exception e) { - return ResponseMsgUtil.exception(e); - } - } - -} diff --git a/hai-cweb/src/main/java/com/cweb/controller/pay/UnionPayController.java b/hai-cweb/src/main/java/com/cweb/controller/pay/UnionPayController.java deleted file mode 100644 index 19fc05cb..00000000 --- a/hai-cweb/src/main/java/com/cweb/controller/pay/UnionPayController.java +++ /dev/null @@ -1,587 +0,0 @@ -package com.cweb.controller.pay; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; -import com.hai.common.exception.ErrorCode; -import com.hai.common.exception.ErrorHelp; -import com.hai.common.exception.SysCode; -import com.hai.common.utils.DateUtil; -import com.hai.common.utils.IDGenerator; -import com.hai.common.utils.ResponseMsgUtil; -import com.hai.config.*; -import com.hai.dao.HighCouponCodeOtherMapper; -import com.hai.dao.HighGasOrderPushMapper; -import com.hai.dao.HighPayRecordMapper; -import com.hai.dao.HighUserCouponMapper; -import com.hai.entity.*; -import com.hai.enum_type.MerStoreAmountSourceTypeEnum; -import com.hai.enum_type.MerStoreAmountTypeEnum; -import com.hai.enum_type.MerchantStoreSourceType; -import com.hai.enum_type.OrderPushType; -import com.hai.model.HighMerchantStoreModel; -import com.hai.model.ResponseData; -import com.hai.msg.entity.MsgTopic; -import com.hai.service.*; -import com.hai.service.pay.NotifyService; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import org.apache.commons.collections4.MapUtils; -import org.apache.commons.io.filefilter.IOFileFilter; -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.*; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.BufferedOutputStream; -import java.math.BigDecimal; -import java.net.URLDecoder; -import java.util.*; - -@Controller -@RequestMapping(value = "/unionPay") -@Api(value = "银联支付") -public class UnionPayController { - - private static Logger log = LoggerFactory.getLogger(UnionPayController.class); - - @Resource - private RedisTemplate redisTemplate; - - @Resource - private HighOrderService highOrderService; - - @Resource - private HighOrderPreService highOrderPreService; - - @Resource - private HighGasOrderPushMapper highGasOrderPushMapper; - - @Resource - private HighCouponService highCouponService; - - @Resource - private HighCouponCodeService highCouponCodeService; - - @Resource - private HighUserService highUserService; - - @Resource - private HighUserCouponMapper highUserCouponMapper; - - @Resource - private HighMerchantStoreService highMerchantStoreService; - - @Resource - private HighProfitSharingRecordService highProfitSharingRecordService; - - @Resource - private HighCouponCodeOtherMapper highCouponCodeOtherMapper; - - @Resource - private HighActivityInfoService highActivityInfoService; - - @Resource - private HighActivityUserLotteryNumService highActivityUserLotteryNumService; - - @Resource - private NotifyService notifyService; - - @Resource - private HuiLianTongConfig huiLianTongConfig; - - @Resource - private HighPayRecordMapper highPayRecordMapper; - - @Resource - private HighDiscountPackageDiscountActualService discountPackageDiscountActualService; - - @Resource - private HighDiscountPackageActualService discountPackageActualService; - - @Resource - private HighDiscountPackageService discountPackageService; - - @Resource - private HighDiscountPackageRecordService discountPackageRecordService; - - @Resource - private HighDiscountUserRelService highDiscountUserRelService; - - @Resource - private OutRechargeOrderService outRechargeOrderService; - - @Resource - private ApiMemberProductService apiMemberProductService; - - @Resource - private ShellGroupService shellGroupService; - - @Resource - private JinZhuJiaYouService jinZhuJiaYouService; - - @RequestMapping(value = "/notify", method = RequestMethod.POST) - @ApiOperation(value = "银联支付 -> 异步回调") - public void notify(@RequestBody String params,HttpServletRequest request, HttpServletResponse response) { - try { - - System.out.println(params); - log.info(params); - - if (StringUtils.isNotBlank(params)) { - // 参数解码 - String paramsStr = URLDecoder.decode(params,"utf-8"); - - // 记录请求参数 - HighPayRecord payRecord = new HighPayRecord(); - payRecord.setCreateTime(new Date()); - payRecord.setResType(2); - payRecord.setPayType(3); - payRecord.setBodyInfo(paramsStr); - highPayRecordMapper.insert(payRecord); - - // 转换成JSON格式 - JSONObject body = JSONObject.parseObject(paramsStr.substring(0, paramsStr.length() - 1)); - if (StringUtils.isNotBlank(body.getString("tradetrace"))) { - // 查询订单信息 - HighOrder order = highOrderService.getOrderByOrderNo(body.getString("tradetrace")); - if (order == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, ""); - } - - // 查询用户 - HighUser highUser = highUserService.findByUserId(order.getMemId()); - - if (order.getOrderStatus() == 1) { - order.setPaySerialNo(body.getString("wtorderid")); // 支付流水号 - //order.setPayRealPrice(body.getBigDecimal("payamt")); // 实付金额 - order.setPayRealPrice(order.getPayPrice()); // 实付金额 - order.setPayTime(new Date()); // 支付时间 - //order.setPayModel(2); // 支付模式:1 金币,2 第三方平台,3 混合 - order.setPayType(5); // 支付方式: 1:支付宝 2:微信 3:金币 4:工会卡 5:银联 6:银联分期 - order.setOrderStatus(2); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 -/* - - for (HighChildOrder highChildOrder : order.getHighChildOrderList()) { - // 商品类型 商品类型 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) { - Map push = new HashMap<>(); - push.put("couTypeCode", coupon.getCouponKey()); - push.put("distCouCount", highChildOrder.getSaleCount()); - push.put("userPhone", highUser.getPhone()); - push.put("thirdUserId", highUser.getUnionId()); - - // 推送给高速 - JSONObject returnParam = HuiLianTongConfig.costRechargeOrder(highChildOrder.getExt2()); - if (returnParam != null && returnParam.getString("respCode").equals("0000")) { - // 解密 - JSONObject jsonObject = HuiLianTongUnionCardConfig.resolveResponse(returnParam.getString("data")); - JSONArray dataArray = JSONObject.parseObject(jsonObject.getString("data"), JSONArray.class); - 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.setActiveTime(dataObject.getDate("activeTime")); - couponCodeOther.setValidStartDate(dataObject.getDate("validStartDate")); - couponCodeOther.setValidEndDate(dataObject.getDate("validEndDate")); - couponCodeOther.setStatus(20); - couponCodeOther.setCreateTime(new Date()); - highCouponCodeOtherMapper.insert(couponCodeOther); - - // 卡卷关联用户 - HighUserCoupon highUserCoupon = new HighUserCoupon(); - highUserCoupon.setOrderId(order.getId()); - highUserCoupon.setChildOrderId(highChildOrder.getId()); - 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 if (coupon.getCouponSource() == 5) { - // 给用户发码 - JSONObject sendResponse = ChongQingCNPCService.sendCNPCTicket(coupon.getCouponKey(), order.getOrderNo(), highChildOrder.getSaleCount(), order.getMemPhone()); - - // 推送记录 - JSONObject sendRequest = new JSONObject(); - sendRequest.put("requestCode", coupon.getCouponKey()); - sendRequest.put("tradeId", order.getOrderNo()); - sendRequest.put("ticketSum", highChildOrder.getSaleCount()); - sendRequest.put("phone", order.getMemPhone()); - - HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); - highGasOrderPush.setType(OrderPushType.type10.getType()); - highGasOrderPush.setOrderNo(order.getOrderNo()); - highGasOrderPush.setCreateTime(new Date()); - highGasOrderPush.setRequestContent(sendRequest.toJSONString()); - highGasOrderPush.setReturnContent(sendResponse.toJSONString()); - highGasOrderPushMapper.insert(highGasOrderPush); - - JSONObject couponDetail = sendResponse.getJSONObject("ticketDetail"); - JSONArray codeList = sendResponse.getJSONArray("codeList"); - - for (Object data : codeList) { - HighCouponCodeOther couponCodeOther = new HighCouponCodeOther(); - couponCodeOther.setType(2); - couponCodeOther.setOrderId(order.getId()); - couponCodeOther.setChildOrderId(highChildOrder.getId()); - couponCodeOther.setCouTypeCode(couponDetail.getString("requestCode")); - couponCodeOther.setCouNo(ChongQingCNPCService.decryptCouponCode(String.valueOf(data))); - couponCodeOther.setActiveTime(DateUtil.format(couponDetail.getString("effectiveTime"), "yyyy-MM-dd")); - couponCodeOther.setValidStartDate(DateUtil.format(couponDetail.getString("effectiveTime"), "yyyy-MM-dd")); - couponCodeOther.setValidEndDate(DateUtil.format(couponDetail.getString("expiredDate"), "yyyy-MM-dd")); - couponCodeOther.setStatus(20); - couponCodeOther.setCreateTime(new Date()); - highCouponCodeOtherMapper.insert(couponCodeOther); - - // 卡卷关联用户 - HighUserCoupon highUserCoupon = new HighUserCoupon(); - highUserCoupon.setOrderId(order.getId()); - highUserCoupon.setChildOrderId(highChildOrder.getId()); - highUserCoupon.setMerchantId(coupon.getMerchantId()); - highUserCoupon.setCouponId(coupon.getId()); - highUserCoupon.setUserId(order.getMemId()); - highUserCoupon.setCreateTime(new Date()); - highUserCoupon.setQrCodeImg(couponCodeOther.getCouNo()); - highUserCoupon.setUseEndTime(couponCodeOther.getValidEndDate()); - highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用 - highUserCouponMapper.insert(highUserCoupon); - } - } 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.setOrderId(order.getId()); - highUserCoupon.setChildOrderId(highChildOrder.getId()); - 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() == 2) { - highChildOrder.setChildOrdeStatus(3); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 - // 金币 1:100 - Integer goldNum = new BigDecimal(highChildOrder.getTotalPrice().toString()).multiply(new BigDecimal("100")).intValue(); - String remark = "订单" + order.getOrderNo() + "积分充值积分:" + goldNum; - highUserService.goldHandle(highChildOrder.getGoodsId(), goldNum, 1, 1, highChildOrder.getId() , remark); - } - - if (highChildOrder.getGoodsType() == 3) { - highChildOrder.setChildOrdeStatus(3); - order.setOrderStatus(3); - HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highChildOrder.getGoodsId()); - - // 来源类型 1:平台自建 2:团油 - if (store.getSourceType().equals(1)) { - - // 预存类型 0:非预存 1:预存门店 - if (store.getPrestoreType() != null && store.getPrestoreType().equals(1)) { - Map pushParam = new HashMap<>(); - pushParam.put("businessType", MerStoreAmountTypeEnum.type2.getType()); - pushParam.put("storeId", highChildOrder.getGoodsId()); - pushParam.put("price", order.getTotalPrice()); - pushParam.put("sourceType", MerStoreAmountSourceTypeEnum.type2.getType()); - pushParam.put("sourceId", order.getId()); - pushParam.put("sourceContent", "订单号:" + order.getOrderNo() + ",加油金额:¥" + order.getTotalPrice()); - pushParam.put("opUserId", order.getMemId()); - pushParam.put("opUserName", order.getMemName()); - // 扣预存款 - this.redisTemplate.boundListOps(MsgTopic.MerStoreAccount.getName()).leftPush(pushParam); - } - - } else if (store.getSourceType().equals(2)) { - // 推送团油订单 - 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")); - } - } else if (store.getSourceType().equals(MerchantStoreSourceType.type3.getNumber())) { - - // 推送加好油 - shellGroupService.gasSyncPayment(order.getOrderNo(), - store.getStoreKey(), - order.getPayTime(), - highChildOrder.getTotalPrice(), - highChildOrder.getGasOilNo(), - highChildOrder.getGasGunNo(), - order.getPayablePrice(), - order.getDeductionPrice() - ); - - } else if (store.getSourceType().equals(MerchantStoreSourceType.type4.getNumber())) { - // 推送金猪加油 - jinZhuJiaYouService.payOrder(order.getOrderNo(), highChildOrder.getGasPriceChannelPay()); - } - } - if (highChildOrder.getGoodsType() == 4 || highChildOrder.getGoodsType() == 9) { - highChildOrder.setChildOrdeStatus(2); - } - if (highChildOrder.getGoodsType() == 7) { - highChildOrder.setChildOrdeStatus(2); - HighDiscountPackageActual actual = discountPackageActualService.getDetailByChildOrderId(highChildOrder.getId()); - if (actual != null) { - List discountList = discountPackageDiscountActualService.getHighDiscountPackageDiscountActualList(actual.getId()); - for (HighDiscountPackageDiscountActual discount : discountList) { - highDiscountUserRelService.receiveDiscount(order.getMemId(), discount.getAgentDiscountCodeId()); - } - HighDiscountPackage discountPackage = discountPackageService.findDiscountPackageById(actual.getDiscountPackageId()); - HighDiscountPackageRecord record = new HighDiscountPackageRecord(); - record.setDiscountPackageId(discountPackage.getId()); - record.setDiscountPackageTitle(discountPackage.getTitle()); - record.setUsingAttribution(discountPackage.getUsingAttribution()); - record.setCompanyId(discountPackage.getCompanyId()); - record.setOrderId(order.getId().intValue()); - record.setChildOrderId(highChildOrder.getId().intValue()); - record.setRecordNo(System.currentTimeMillis()+""); - record.setSalesType(1); - record.setPrice(order.getPayPrice()); - record.setUserId(order.getMemId().intValue()); - discountPackageRecordService.insertRecord(record); - actual.setAllocationTime(new Date()); - actual.setStatus(3); // 状态: 1: 待分配 2:预分配(售卖)3:已分配 - discountPackageActualService.updateHighDiscountPackageActual(actual); - } - } - } -*/ - - HighGasOrderPush orderPush = new HighGasOrderPush(); - JSONObject returnObject = new JSONObject(); - - if (order.getHighChildOrderList().get(0).getGoodsType() == 4) { - returnObject = QianZhuConfig.payKfcOrder(order.getOrderNo()); - } else if (order.getHighChildOrderList().get(0).getGoodsType() == 9) { - returnObject = QianZhuConfig.starbucksOrdersPay(order.getOrderNo()); - } else if (order.getHighChildOrderList().get(0).getGoodsType() == 10){ - orderPush.setType(OrderPushType.type9.getType()); - ApiMemberProduct memberProduct = apiMemberProductService.findById(order.getHighChildOrderList().get(0).getGoodsId()); - returnObject = QianZhuConfig.insertV2(memberProduct.getProductId() , order.getOrderNo() , order.getRemarks()); - } - - highOrderService.updateOrder(order); - - orderPush.setOrderNo(order.getOrderNo()); - orderPush.setCreateTime(new Date()); - orderPush.setRequestContent(order.getOrderNo()); - orderPush.setReturnContent(returnObject.toJSONString()); - highGasOrderPushMapper.insert(orderPush); - - - if (order.getHighChildOrderList().get(0).getGoodsType().equals(3)) { - new Thread(() -> { - highOrderService.printGasOrder(order.getHighChildOrderList().get(0).getGoodsId(), order, false); - }).start(); - } - } - } - } - - - BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream()); - JSONObject result = new JSONObject(); - result.put("resultcode", "00"); - out.write(result.toJSONString().getBytes()); - out.flush(); - out.close(); - } catch (Exception e) { - log.error("UnionPayController --> notify() error!", e); - } - } - - - @RequestMapping(value = "/notifyTel", method = RequestMethod.POST) - @ApiOperation(value = "银联支付 -> 异步回调") - public void notifyTel(@RequestBody String params,HttpServletRequest request, HttpServletResponse response) { - try { - - System.out.println(params); - log.info(params); - - if (StringUtils.isNotBlank(params)) { - // 参数解码 - String paramsStr = URLDecoder.decode(params,"utf-8"); - - // 记录请求参数 - HighPayRecord payRecord = new HighPayRecord(); - payRecord.setCreateTime(new Date()); - payRecord.setResType(2); - payRecord.setPayType(3); - payRecord.setBodyInfo(paramsStr); - highPayRecordMapper.insert(payRecord); - - // 转换成JSON格式 - JSONObject body = JSONObject.parseObject(paramsStr.substring(0, paramsStr.length() - 1)); - if (StringUtils.isNotBlank(body.getString("tradetrace"))) { - OutRechargeOrder order = outRechargeOrderService.findByOrderNo(body.getString("tradetrace")); - if (order == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息"); - } - - order.setPaySerialNo(body.getString("wtorderid")); // 支付流水号 - order.setPayRealPrice(order.getPayRealPrice()); // 实付金额 - - order.setPayStatus(102); - order.setRechargeStatus(204); - order.setPayType(4); - order.setPayTime(new Date()); // 支付时间 - outRechargeOrderService.updateOrder(order); - outRechargeOrderService.pollRequest(order); - } - } - - BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream()); - JSONObject result = new JSONObject(); - result.put("resultcode", "00"); - out.write(result.toJSONString().getBytes()); - out.flush(); - out.close(); - } catch (Exception e) { - log.error("UnionPayController --> notify() error!", e); - } - } - - @RequestMapping(value = "/refreshStagingOrder", method = RequestMethod.POST) - @ResponseBody - @ApiOperation(value = "银联分期支付 -> 刷新分期订单") - public ResponseData refreshStagingOrder(@RequestBody JSONObject body, HttpServletRequest request, HttpServletResponse response) { - try { - - if (body == null || StringUtils.isBlank(body.getString("orderNo"))) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); - } - // 查询订单信息 - HighOrder order = highOrderService.getOrderByOrderNo(body.getString("orderNo")); - if (order == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息"); - } - // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 6.退款中 7.拒绝退款 - if (order.getOrderStatus().equals(1)) { - String orgTrace = CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(0,4) - +CommonSysConst.getSysConfig().getUnionStagingPayOrgId().substring(CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length() - 4,CommonSysConst.getSysConfig().getUnionStagingPayOrgId().length()) - + DateUtil.format(new Date(), DateUtil.YMDHMS) - + IDGenerator.nextId(6); - - JSONObject responseObject = UnionStagingPayConfig.queryStaging(orgTrace, order.getPaySerialNo(), "", order.getCreateTime(), request); - if (responseObject.getString("sysRetCode").equals("000000")) { - - } - - return ResponseMsgUtil.success(responseObject); - } - return ResponseMsgUtil.success(order); - - } catch (Exception e) { - log.error("UnionPayController --> refreshStagingOrder() error!", e); - return ResponseMsgUtil.exception(e); - } - } - -} diff --git a/hai-cweb/src/main/java/com/cweb/controller/pay/WechatPayController.java b/hai-cweb/src/main/java/com/cweb/controller/pay/WechatPayController.java deleted file mode 100644 index fd093c5b..00000000 --- a/hai-cweb/src/main/java/com/cweb/controller/pay/WechatPayController.java +++ /dev/null @@ -1,212 +0,0 @@ -package com.cweb.controller.pay; - -import com.alibaba.fastjson.JSONObject; -import com.cweb.config.SysConst; -import com.cweb.config.WxMsgConfig; -import com.hai.common.exception.ErrorCode; -import com.hai.common.exception.ErrorHelp; -import com.hai.common.exception.SysCode; -import com.hai.common.pay.WechatPayUtil; -import com.hai.common.pay.entity.WechatCallBackInfo; -import com.hai.common.pay.util.IOUtil; -import com.hai.common.pay.util.XmlUtil; -import com.hai.common.pay.util.sdk.WXPayConstants; -import com.hai.common.utils.HttpsUtils; -import com.hai.common.utils.ResponseMsgUtil; -import com.hai.common.utils.WxUtils; -import com.hai.entity.*; -import com.hai.enum_type.GoodsType; -import com.hai.enum_type.PayType; -import com.hai.model.ResponseData; -import com.hai.model.WxSharingOrderRequestModel; -import com.hai.model.WxSharingReceiversVO; -import com.hai.service.HighOrderService; -import com.hai.service.HighProfitSharingRecordService; -import com.hai.service.HighUserService; -import com.hai.service.TelApiService; -import com.hai.service.pay.NotifyService; -import com.hai.service.pay.PayRecordService; -import com.wechat.pay.contrib.apache.httpclient.util.PemUtil; -import io.swagger.annotations.Api; -import io.swagger.annotations.ApiOperation; -import net.sf.cglib.beans.BeanMap; -import org.apache.http.HttpEntity; -import org.apache.http.client.methods.CloseableHttpResponse; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.conn.ssl.SSLConnectionSocketFactory; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.client.CloseableHttpClient; -import org.apache.http.impl.client.HttpClients; -import org.apache.http.ssl.SSLContexts; -import org.apache.http.util.EntityUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; - -import javax.annotation.Resource; -import javax.net.ssl.SSLContext; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.BufferedOutputStream; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.UnsupportedEncodingException; -import java.math.BigDecimal; -import java.security.*; -import java.util.*; - -@Controller -@RequestMapping(value = "/wechatpay") -@Api(value = "微信支付") -public class WechatPayController { - - private static Logger log = LoggerFactory.getLogger(WechatPayController.class); - - private WXPayConstants.SignType signType; - - @Resource - private NotifyService notifyService; - @Resource - private PayRecordService payRecordService; - @Resource - private WechatPayUtil wechatPayUtil; - - @Resource - private HighOrderService highOrderService; - - @Resource - private HighUserService highUserService; - - @Resource - private TelApiService telApiService; - @Resource - private HighProfitSharingRecordService highProfitSharingRecordService; - - @RequestMapping(value = "/notify", method = RequestMethod.POST) - @ApiOperation(value = "微信支付 -> 异步回调") - public void wechatNotify(HttpServletRequest request, HttpServletResponse response) { - try { - log.info("微信支付 -> 异步通知:处理开始"); - - String resXml = ""; // 反馈给微信服务器 - String notifyXml = null; // 微信支付系统发送的数据(格式) - notifyXml = IOUtil.inputStreamToString(request.getInputStream(), "UTF-8"); - - log.info("微信支付系统发送的数据:" + notifyXml); - SortedMap map = XmlUtil.parseXmlToTreeMap(notifyXml, "UTF-8"); - - resXml = notifyService.wechatNotify(map); - -/* if (SignatureUtil.reCheckIsSignValidFromWeiXin(notifyXml, SysConst.getSysConfig().getWxApiKey(), "UTF-8")) { - log.info("微信支付系统发送的数据:" + notifyXml); - SortedMap map = XmlUtil.parseXmlToTreeMap(notifyXml, "UTF-8"); - - resXml = notifyService.wechatNotify(map); - } else { - log.error("微信支付 -> 异步通知:验签失败"); - log.error("apiKey:" + SysConst.getSysConfig().getWxApiKey()); - log.error("返回信息:" + notifyXml); - resXml = "" + "" - + "" + " "; - }*/ - - new Thread(() -> { - // 查询订单信息 - HighOrder order = highOrderService.getOrderByOrderNo(map.get("out_trade_no")); - 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(); - - BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream()); - out.write(resXml.getBytes()); - out.flush(); - out.close(); - log.info("微信支付 -> 异步通知:处理完成"); - } catch (Exception e) { - log.error("WechatPayController --> wechatNotify() error!", e); - } - } - - @RequestMapping(value = "/addLedgerReceiver", method = RequestMethod.POST) - @ApiOperation(value = "微信支付 -> 添加分账接收方") - public void addLedgerReceiver(@RequestParam(name = "sub_mch_id", required = true) String sub_mch_id, - HttpServletRequest request, HttpServletResponse response) { - try { - - WxSharingReceiversVO receiversVO = new WxSharingReceiversVO(); - receiversVO.setAccount("1603942866"); - receiversVO.setType("MERCHANT_ID"); - receiversVO.setName("重庆惠昕石化有限责任公司"); - receiversVO.setRelation_type("SERVICE_PROVIDER"); - - Map map = new HashMap<>(); - - map.put("mch_id" , "1289663601"); - map.put("sub_mch_id" , sub_mch_id); - map.put("appid" , "wxa075e8509802f826"); - map.put("nonce_str" , WxUtils.makeNonStr()); - map.put("sign_type" , "HMAC-SHA256"); - map.put("receiver" , JSONObject.toJSONString(receiversVO)); - - String sign = WxUtils.generateSignature(map, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256); - - map.put("sign" , sign); - - String url = "https://api.mch.weixin.qq.com/pay/profitsharingaddreceiver"; - String xm = WxUtils.mapToXml(map); - String rest = String.valueOf(HttpsUtils.postData(url, xm)); - - System.out.println(rest); - log.info("微信支付 -> 添加分账接收方:处理开始"); - } catch (Exception e) { - log.error("WechatPayController --> wechatNotify() error!", e); - } - } - - - String getToken(String method, String url, String body) throws UnsupportedEncodingException, SignatureException, NoSuchAlgorithmException, InvalidKeyException, FileNotFoundException { - - long timeMillis = System.currentTimeMillis(); - String nonceStr = String.valueOf(timeMillis); - long timestamp = System.currentTimeMillis() / 1000; - String message = buildMessage(method, url, timestamp, nonceStr, body); - PrivateKey privateKey = PemUtil.loadPrivateKey(new FileInputStream("G:/hurui-project/hai-parent/hai-cweb/src/main/resources/privatekey/apiclient_key.pem")); - String signature = sign(privateKey,message.getBytes("utf-8")); - - return "mchid=\"" + SysConst.getSysConfig().getWxSubMchId() + "\"," - + "nonce_str=\"" + nonceStr + "\"," - + "timestamp=\"" + timestamp + "\"," - + "serial_no=\"" + "1B08DC2A078B0B1F77A65C97C445AAD545B5EAA6" + "\"," - + "signature=\"" + signature + "\""; - } - - String sign(PrivateKey privateKey,byte[] message) throws SignatureException, NoSuchAlgorithmException, InvalidKeyException { - Signature sign = Signature.getInstance("SHA256withRSA"); - sign.initSign(privateKey); - sign.update(message); - return Base64.getEncoder().encodeToString(sign.sign()); - } - - String buildMessage(String method, String url, long timestamp, String nonceStr, String body) { - return method + "" - + url + "" - + timestamp + "" - + nonceStr + "" - + body + ""; - } - -} diff --git a/hai-order/src/main/java/com/web/controller/OrderPayController.java b/hai-order/src/main/java/com/web/controller/OrderPayController.java index 16d9be04..ae40a5c8 100644 --- a/hai-order/src/main/java/com/web/controller/OrderPayController.java +++ b/hai-order/src/main/java/com/web/controller/OrderPayController.java @@ -303,7 +303,7 @@ public class OrderPayController { return ResponseMsgUtil.success(orderPayService.oilCardPay(order, userCard)); } else if (userCard.getType().equals(UserCardType.type3.getType())) { - return ResponseMsgUtil.success(orderPayService.oilCardFleetPay(order, userCard)); + return ResponseMsgUtil.success(orderPayService.oilCardFleetPay(order, userCard, body.getString("carLicensePlate"))); } else { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的卡号类型"); diff --git a/hai-order/src/main/java/com/web/controller/business/OrderThirdPartyController.java b/hai-order/src/main/java/com/web/controller/business/OrderThirdPartyController.java index b048a71a..e5d093fd 100644 --- a/hai-order/src/main/java/com/web/controller/business/OrderThirdPartyController.java +++ b/hai-order/src/main/java/com/web/controller/business/OrderThirdPartyController.java @@ -10,7 +10,6 @@ import com.hai.common.security.UserCenter; import com.hai.common.utils.ResponseMsgUtil; import com.hai.entity.HighGasOrder; import com.hai.entity.HighOrder; -import com.hai.enum_type.OrderPayTypeEnum; import com.hai.enum_type.OrderStatusEnum; import com.hai.enum_type.UserObjectTypeEnum; import com.hai.model.ResponseData; @@ -19,6 +18,7 @@ import com.hai.order.model.ExportGasOrderModel; import com.hai.order.model.OrderThirdPartyModel; import com.hai.order.service.OrderService; import com.hai.order.type.OrderOilStatus; +import com.hai.order.type.OrderPayType; import com.web.config.SysConst; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -185,7 +185,7 @@ public class OrderThirdPartyController { model.setDeductionProductPrice(thirdPartyModel.getDeductionProductPrice()); model.setPayablePrice(thirdPartyModel.getPayablePrice()); model.setPayPrice(thirdPartyModel.getPayPrice()); - model.setPayType(OrderPayTypeEnum.getNameByType(thirdPartyModel.getPayType())); + model.setPayType(OrderPayType.getDataByType(thirdPartyModel.getPayType()).getName()); model.setOrderStatus(OrderStatusEnum.getNameByType(thirdPartyModel.getOrderStatus())); model.setCreateTime(thirdPartyModel.getCreateTime()); model.setPayTime(thirdPartyModel.getPayTime()); diff --git a/hai-service/src/main/java/com/hai/dao/HighGasOrderMapper.java b/hai-service/src/main/java/com/hai/dao/HighGasOrderMapper.java index 260da886..5eed6b48 100644 --- a/hai-service/src/main/java/com/hai/dao/HighGasOrderMapper.java +++ b/hai-service/src/main/java/com/hai/dao/HighGasOrderMapper.java @@ -48,25 +48,26 @@ public interface HighGasOrderMapper extends HighGasOrderMapperExt { "total_deduction_price, deduction_coupon_price, ", "deduction_product_price, payable_price, ", "pay_gold, pay_price, ", - "gas_refuel_price, gas_oil_no, ", - "gas_gun_no, gas_oil_type, ", - "gas_price_platform, gas_price_gun, ", - "gas_price_vip, gas_price_official, ", - "gas_price_cost, gas_price_cost_total, ", - "gas_price_channel_pay, gas_oil_liters, ", - "gas_discount, gas_oil_subsidy, ", - "gas_liters_preferences, gas_price_preferences, ", - "gas_class_group_id, gas_class_group_name, ", - "gas_class_group_task_id, gas_staff_id, ", - "gas_staff_name, gas_salesman_id, ", - "gas_salesman_name, gas_agent_id, ", - "gas_agent_name, gas_org_id, ", - "gas_org_name, pay_type, ", - "`status`, create_time, ", - "cancel_time, pay_time, ", - "refund_time, refund_remarks, ", - "ext_1, ext_2, ext_3, ", - "ext_4, ext_5, ext_6)", + "gas_refuel_price, gas_car_license_plate, ", + "gas_oil_no, gas_gun_no, ", + "gas_oil_type, gas_price_platform, ", + "gas_price_gun, gas_price_vip, ", + "gas_price_official, gas_price_cost, ", + "gas_price_cost_total, gas_price_channel_pay, ", + "gas_oil_liters, gas_discount, ", + "gas_oil_subsidy, gas_liters_preferences, ", + "gas_price_preferences, gas_class_group_id, ", + "gas_class_group_name, gas_class_group_task_id, ", + "gas_staff_id, gas_staff_name, ", + "gas_salesman_id, gas_salesman_name, ", + "gas_agent_id, gas_agent_name, ", + "gas_org_id, gas_org_name, ", + "pay_type, `status`, ", + "create_time, cancel_time, ", + "pay_time, refund_time, ", + "refund_remarks, ext_1, ", + "ext_2, ext_3, ext_4, ", + "ext_5, ext_6)", "values (#{orderNo,jdbcType=VARCHAR}, #{childOrderNo,jdbcType=VARCHAR}, ", "#{channelType,jdbcType=INTEGER}, #{channelOrderNo,jdbcType=VARCHAR}, ", "#{memId,jdbcType=BIGINT}, #{memPhone,jdbcType=VARCHAR}, ", @@ -76,25 +77,26 @@ public interface HighGasOrderMapper extends HighGasOrderMapperExt { "#{totalDeductionPrice,jdbcType=DECIMAL}, #{deductionCouponPrice,jdbcType=DECIMAL}, ", "#{deductionProductPrice,jdbcType=DECIMAL}, #{payablePrice,jdbcType=DECIMAL}, ", "#{payGold,jdbcType=INTEGER}, #{payPrice,jdbcType=DECIMAL}, ", - "#{gasRefuelPrice,jdbcType=DECIMAL}, #{gasOilNo,jdbcType=VARCHAR}, ", - "#{gasGunNo,jdbcType=VARCHAR}, #{gasOilType,jdbcType=INTEGER}, ", - "#{gasPricePlatform,jdbcType=DECIMAL}, #{gasPriceGun,jdbcType=DECIMAL}, ", - "#{gasPriceVip,jdbcType=DECIMAL}, #{gasPriceOfficial,jdbcType=DECIMAL}, ", - "#{gasPriceCost,jdbcType=DECIMAL}, #{gasPriceCostTotal,jdbcType=DECIMAL}, ", - "#{gasPriceChannelPay,jdbcType=DECIMAL}, #{gasOilLiters,jdbcType=DECIMAL}, ", - "#{gasDiscount,jdbcType=DECIMAL}, #{gasOilSubsidy,jdbcType=DECIMAL}, ", - "#{gasLitersPreferences,jdbcType=DECIMAL}, #{gasPricePreferences,jdbcType=DECIMAL}, ", - "#{gasClassGroupId,jdbcType=BIGINT}, #{gasClassGroupName,jdbcType=VARCHAR}, ", - "#{gasClassGroupTaskId,jdbcType=BIGINT}, #{gasStaffId,jdbcType=BIGINT}, ", - "#{gasStaffName,jdbcType=VARCHAR}, #{gasSalesmanId,jdbcType=BIGINT}, ", - "#{gasSalesmanName,jdbcType=VARCHAR}, #{gasAgentId,jdbcType=BIGINT}, ", - "#{gasAgentName,jdbcType=VARCHAR}, #{gasOrgId,jdbcType=BIGINT}, ", - "#{gasOrgName,jdbcType=VARCHAR}, #{payType,jdbcType=INTEGER}, ", - "#{status,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ", - "#{cancelTime,jdbcType=TIMESTAMP}, #{payTime,jdbcType=TIMESTAMP}, ", - "#{refundTime,jdbcType=TIMESTAMP}, #{refundRemarks,jdbcType=VARCHAR}, ", - "#{ext1,jdbcType=VARCHAR}, #{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR}, ", - "#{ext4,jdbcType=VARCHAR}, #{ext5,jdbcType=VARCHAR}, #{ext6,jdbcType=VARCHAR})" + "#{gasRefuelPrice,jdbcType=DECIMAL}, #{gasCarLicensePlate,jdbcType=VARCHAR}, ", + "#{gasOilNo,jdbcType=VARCHAR}, #{gasGunNo,jdbcType=VARCHAR}, ", + "#{gasOilType,jdbcType=INTEGER}, #{gasPricePlatform,jdbcType=DECIMAL}, ", + "#{gasPriceGun,jdbcType=DECIMAL}, #{gasPriceVip,jdbcType=DECIMAL}, ", + "#{gasPriceOfficial,jdbcType=DECIMAL}, #{gasPriceCost,jdbcType=DECIMAL}, ", + "#{gasPriceCostTotal,jdbcType=DECIMAL}, #{gasPriceChannelPay,jdbcType=DECIMAL}, ", + "#{gasOilLiters,jdbcType=DECIMAL}, #{gasDiscount,jdbcType=DECIMAL}, ", + "#{gasOilSubsidy,jdbcType=DECIMAL}, #{gasLitersPreferences,jdbcType=DECIMAL}, ", + "#{gasPricePreferences,jdbcType=DECIMAL}, #{gasClassGroupId,jdbcType=BIGINT}, ", + "#{gasClassGroupName,jdbcType=VARCHAR}, #{gasClassGroupTaskId,jdbcType=BIGINT}, ", + "#{gasStaffId,jdbcType=BIGINT}, #{gasStaffName,jdbcType=VARCHAR}, ", + "#{gasSalesmanId,jdbcType=BIGINT}, #{gasSalesmanName,jdbcType=VARCHAR}, ", + "#{gasAgentId,jdbcType=BIGINT}, #{gasAgentName,jdbcType=VARCHAR}, ", + "#{gasOrgId,jdbcType=BIGINT}, #{gasOrgName,jdbcType=VARCHAR}, ", + "#{payType,jdbcType=INTEGER}, #{status,jdbcType=INTEGER}, ", + "#{createTime,jdbcType=TIMESTAMP}, #{cancelTime,jdbcType=TIMESTAMP}, ", + "#{payTime,jdbcType=TIMESTAMP}, #{refundTime,jdbcType=TIMESTAMP}, ", + "#{refundRemarks,jdbcType=VARCHAR}, #{ext1,jdbcType=VARCHAR}, ", + "#{ext2,jdbcType=VARCHAR}, #{ext3,jdbcType=VARCHAR}, #{ext4,jdbcType=VARCHAR}, ", + "#{ext5,jdbcType=VARCHAR}, #{ext6,jdbcType=VARCHAR})" }) @Options(useGeneratedKeys=true,keyProperty="id") int insert(HighGasOrder record); @@ -126,6 +128,7 @@ public interface HighGasOrderMapper extends HighGasOrderMapperExt { @Result(column="pay_gold", property="payGold", jdbcType=JdbcType.INTEGER), @Result(column="pay_price", property="payPrice", jdbcType=JdbcType.DECIMAL), @Result(column="gas_refuel_price", property="gasRefuelPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="gas_car_license_plate", property="gasCarLicensePlate", jdbcType=JdbcType.VARCHAR), @Result(column="gas_oil_no", property="gasOilNo", jdbcType=JdbcType.VARCHAR), @Result(column="gas_gun_no", property="gasGunNo", jdbcType=JdbcType.VARCHAR), @Result(column="gas_oil_type", property="gasOilType", jdbcType=JdbcType.INTEGER), @@ -173,14 +176,14 @@ public interface HighGasOrderMapper extends HighGasOrderMapperExt { "id, order_no, child_order_no, channel_type, channel_order_no, mem_id, mem_phone, ", "company_id, company_name, mer_id, mer_name, store_id, store_name, store_address, ", "total_deduction_price, deduction_coupon_price, deduction_product_price, payable_price, ", - "pay_gold, pay_price, gas_refuel_price, gas_oil_no, gas_gun_no, gas_oil_type, ", - "gas_price_platform, gas_price_gun, gas_price_vip, gas_price_official, gas_price_cost, ", - "gas_price_cost_total, gas_price_channel_pay, gas_oil_liters, gas_discount, gas_oil_subsidy, ", - "gas_liters_preferences, gas_price_preferences, gas_class_group_id, gas_class_group_name, ", - "gas_class_group_task_id, gas_staff_id, gas_staff_name, gas_salesman_id, gas_salesman_name, ", - "gas_agent_id, gas_agent_name, gas_org_id, gas_org_name, pay_type, `status`, ", - "create_time, cancel_time, pay_time, refund_time, refund_remarks, ext_1, ext_2, ", - "ext_3, ext_4, ext_5, ext_6", + "pay_gold, pay_price, gas_refuel_price, gas_car_license_plate, gas_oil_no, gas_gun_no, ", + "gas_oil_type, gas_price_platform, gas_price_gun, gas_price_vip, gas_price_official, ", + "gas_price_cost, gas_price_cost_total, gas_price_channel_pay, gas_oil_liters, ", + "gas_discount, gas_oil_subsidy, gas_liters_preferences, gas_price_preferences, ", + "gas_class_group_id, gas_class_group_name, gas_class_group_task_id, gas_staff_id, ", + "gas_staff_name, gas_salesman_id, gas_salesman_name, gas_agent_id, gas_agent_name, ", + "gas_org_id, gas_org_name, pay_type, `status`, create_time, cancel_time, pay_time, ", + "refund_time, refund_remarks, ext_1, ext_2, ext_3, ext_4, ext_5, ext_6", "from high_gas_order", "where id = #{id,jdbcType=BIGINT}" }) @@ -206,6 +209,7 @@ public interface HighGasOrderMapper extends HighGasOrderMapperExt { @Result(column="pay_gold", property="payGold", jdbcType=JdbcType.INTEGER), @Result(column="pay_price", property="payPrice", jdbcType=JdbcType.DECIMAL), @Result(column="gas_refuel_price", property="gasRefuelPrice", jdbcType=JdbcType.DECIMAL), + @Result(column="gas_car_license_plate", property="gasCarLicensePlate", jdbcType=JdbcType.VARCHAR), @Result(column="gas_oil_no", property="gasOilNo", jdbcType=JdbcType.VARCHAR), @Result(column="gas_gun_no", property="gasGunNo", jdbcType=JdbcType.VARCHAR), @Result(column="gas_oil_type", property="gasOilType", jdbcType=JdbcType.INTEGER), @@ -279,6 +283,7 @@ public interface HighGasOrderMapper extends HighGasOrderMapperExt { "pay_gold = #{payGold,jdbcType=INTEGER},", "pay_price = #{payPrice,jdbcType=DECIMAL},", "gas_refuel_price = #{gasRefuelPrice,jdbcType=DECIMAL},", + "gas_car_license_plate = #{gasCarLicensePlate,jdbcType=VARCHAR},", "gas_oil_no = #{gasOilNo,jdbcType=VARCHAR},", "gas_gun_no = #{gasGunNo,jdbcType=VARCHAR},", "gas_oil_type = #{gasOilType,jdbcType=INTEGER},", diff --git a/hai-service/src/main/java/com/hai/dao/HighGasOrderSqlProvider.java b/hai-service/src/main/java/com/hai/dao/HighGasOrderSqlProvider.java index df512d08..b73cf340 100644 --- a/hai-service/src/main/java/com/hai/dao/HighGasOrderSqlProvider.java +++ b/hai-service/src/main/java/com/hai/dao/HighGasOrderSqlProvider.java @@ -108,6 +108,10 @@ public class HighGasOrderSqlProvider { sql.VALUES("gas_refuel_price", "#{gasRefuelPrice,jdbcType=DECIMAL}"); } + if (record.getGasCarLicensePlate() != null) { + sql.VALUES("gas_car_license_plate", "#{gasCarLicensePlate,jdbcType=VARCHAR}"); + } + if (record.getGasOilNo() != null) { sql.VALUES("gas_oil_no", "#{gasOilNo,jdbcType=VARCHAR}"); } @@ -294,6 +298,7 @@ public class HighGasOrderSqlProvider { sql.SELECT("pay_gold"); sql.SELECT("pay_price"); sql.SELECT("gas_refuel_price"); + sql.SELECT("gas_car_license_plate"); sql.SELECT("gas_oil_no"); sql.SELECT("gas_gun_no"); sql.SELECT("gas_oil_type"); @@ -434,6 +439,10 @@ public class HighGasOrderSqlProvider { sql.SET("gas_refuel_price = #{record.gasRefuelPrice,jdbcType=DECIMAL}"); } + if (record.getGasCarLicensePlate() != null) { + sql.SET("gas_car_license_plate = #{record.gasCarLicensePlate,jdbcType=VARCHAR}"); + } + if (record.getGasOilNo() != null) { sql.SET("gas_oil_no = #{record.gasOilNo,jdbcType=VARCHAR}"); } @@ -619,6 +628,7 @@ public class HighGasOrderSqlProvider { sql.SET("pay_gold = #{record.payGold,jdbcType=INTEGER}"); sql.SET("pay_price = #{record.payPrice,jdbcType=DECIMAL}"); sql.SET("gas_refuel_price = #{record.gasRefuelPrice,jdbcType=DECIMAL}"); + sql.SET("gas_car_license_plate = #{record.gasCarLicensePlate,jdbcType=VARCHAR}"); sql.SET("gas_oil_no = #{record.gasOilNo,jdbcType=VARCHAR}"); sql.SET("gas_gun_no = #{record.gasGunNo,jdbcType=VARCHAR}"); sql.SET("gas_oil_type = #{record.gasOilType,jdbcType=INTEGER}"); @@ -748,6 +758,10 @@ public class HighGasOrderSqlProvider { sql.SET("gas_refuel_price = #{gasRefuelPrice,jdbcType=DECIMAL}"); } + if (record.getGasCarLicensePlate() != null) { + sql.SET("gas_car_license_plate = #{gasCarLicensePlate,jdbcType=VARCHAR}"); + } + if (record.getGasOilNo() != null) { sql.SET("gas_oil_no = #{gasOilNo,jdbcType=VARCHAR}"); } diff --git a/hai-service/src/main/java/com/hai/entity/HighGasOrder.java b/hai-service/src/main/java/com/hai/entity/HighGasOrder.java index 83664020..32440332 100644 --- a/hai-service/src/main/java/com/hai/entity/HighGasOrder.java +++ b/hai-service/src/main/java/com/hai/entity/HighGasOrder.java @@ -119,6 +119,11 @@ public class HighGasOrder implements Serializable { */ private BigDecimal gasRefuelPrice; + /** + * 【加油站】车牌 + */ + private String gasCarLicensePlate; + /** * 【加油站】油号 */ @@ -472,6 +477,14 @@ public class HighGasOrder implements Serializable { this.gasRefuelPrice = gasRefuelPrice; } + public String getGasCarLicensePlate() { + return gasCarLicensePlate; + } + + public void setGasCarLicensePlate(String gasCarLicensePlate) { + this.gasCarLicensePlate = gasCarLicensePlate; + } + public String getGasOilNo() { return gasOilNo; } @@ -817,6 +830,7 @@ public class HighGasOrder implements Serializable { && (this.getPayGold() == null ? other.getPayGold() == null : this.getPayGold().equals(other.getPayGold())) && (this.getPayPrice() == null ? other.getPayPrice() == null : this.getPayPrice().equals(other.getPayPrice())) && (this.getGasRefuelPrice() == null ? other.getGasRefuelPrice() == null : this.getGasRefuelPrice().equals(other.getGasRefuelPrice())) + && (this.getGasCarLicensePlate() == null ? other.getGasCarLicensePlate() == null : this.getGasCarLicensePlate().equals(other.getGasCarLicensePlate())) && (this.getGasOilNo() == null ? other.getGasOilNo() == null : this.getGasOilNo().equals(other.getGasOilNo())) && (this.getGasGunNo() == null ? other.getGasGunNo() == null : this.getGasGunNo().equals(other.getGasGunNo())) && (this.getGasOilType() == null ? other.getGasOilType() == null : this.getGasOilType().equals(other.getGasOilType())) @@ -883,6 +897,7 @@ public class HighGasOrder implements Serializable { result = prime * result + ((getPayGold() == null) ? 0 : getPayGold().hashCode()); result = prime * result + ((getPayPrice() == null) ? 0 : getPayPrice().hashCode()); result = prime * result + ((getGasRefuelPrice() == null) ? 0 : getGasRefuelPrice().hashCode()); + result = prime * result + ((getGasCarLicensePlate() == null) ? 0 : getGasCarLicensePlate().hashCode()); result = prime * result + ((getGasOilNo() == null) ? 0 : getGasOilNo().hashCode()); result = prime * result + ((getGasGunNo() == null) ? 0 : getGasGunNo().hashCode()); result = prime * result + ((getGasOilType() == null) ? 0 : getGasOilType().hashCode()); @@ -952,6 +967,7 @@ public class HighGasOrder implements Serializable { sb.append(", payGold=").append(payGold); sb.append(", payPrice=").append(payPrice); sb.append(", gasRefuelPrice=").append(gasRefuelPrice); + sb.append(", gasCarLicensePlate=").append(gasCarLicensePlate); sb.append(", gasOilNo=").append(gasOilNo); sb.append(", gasGunNo=").append(gasGunNo); sb.append(", gasOilType=").append(gasOilType); diff --git a/hai-service/src/main/java/com/hai/entity/HighGasOrderExample.java b/hai-service/src/main/java/com/hai/entity/HighGasOrderExample.java index bdf025fe..bd0c88af 100644 --- a/hai-service/src/main/java/com/hai/entity/HighGasOrderExample.java +++ b/hai-service/src/main/java/com/hai/entity/HighGasOrderExample.java @@ -1466,6 +1466,76 @@ public class HighGasOrderExample { return (Criteria) this; } + public Criteria andGasCarLicensePlateIsNull() { + addCriterion("gas_car_license_plate is null"); + return (Criteria) this; + } + + public Criteria andGasCarLicensePlateIsNotNull() { + addCriterion("gas_car_license_plate is not null"); + return (Criteria) this; + } + + public Criteria andGasCarLicensePlateEqualTo(String value) { + addCriterion("gas_car_license_plate =", value, "gasCarLicensePlate"); + return (Criteria) this; + } + + public Criteria andGasCarLicensePlateNotEqualTo(String value) { + addCriterion("gas_car_license_plate <>", value, "gasCarLicensePlate"); + return (Criteria) this; + } + + public Criteria andGasCarLicensePlateGreaterThan(String value) { + addCriterion("gas_car_license_plate >", value, "gasCarLicensePlate"); + return (Criteria) this; + } + + public Criteria andGasCarLicensePlateGreaterThanOrEqualTo(String value) { + addCriterion("gas_car_license_plate >=", value, "gasCarLicensePlate"); + return (Criteria) this; + } + + public Criteria andGasCarLicensePlateLessThan(String value) { + addCriterion("gas_car_license_plate <", value, "gasCarLicensePlate"); + return (Criteria) this; + } + + public Criteria andGasCarLicensePlateLessThanOrEqualTo(String value) { + addCriterion("gas_car_license_plate <=", value, "gasCarLicensePlate"); + return (Criteria) this; + } + + public Criteria andGasCarLicensePlateLike(String value) { + addCriterion("gas_car_license_plate like", value, "gasCarLicensePlate"); + return (Criteria) this; + } + + public Criteria andGasCarLicensePlateNotLike(String value) { + addCriterion("gas_car_license_plate not like", value, "gasCarLicensePlate"); + return (Criteria) this; + } + + public Criteria andGasCarLicensePlateIn(List values) { + addCriterion("gas_car_license_plate in", values, "gasCarLicensePlate"); + return (Criteria) this; + } + + public Criteria andGasCarLicensePlateNotIn(List values) { + addCriterion("gas_car_license_plate not in", values, "gasCarLicensePlate"); + return (Criteria) this; + } + + public Criteria andGasCarLicensePlateBetween(String value1, String value2) { + addCriterion("gas_car_license_plate between", value1, value2, "gasCarLicensePlate"); + return (Criteria) this; + } + + public Criteria andGasCarLicensePlateNotBetween(String value1, String value2) { + addCriterion("gas_car_license_plate not between", value1, value2, "gasCarLicensePlate"); + return (Criteria) this; + } + public Criteria andGasOilNoIsNull() { addCriterion("gas_oil_no is null"); return (Criteria) this; 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 deleted file mode 100644 index 85a1b8b6..00000000 --- a/hai-service/src/main/java/com/hai/enum_type/OrderPayTypeEnum.java +++ /dev/null @@ -1,50 +0,0 @@ -package com.hai.enum_type; - -import java.util.Objects; - -/** - * 支付方式 - * @author hurui - */ -public enum OrderPayTypeEnum { - type1(1 , "支付宝"), - type2(2 , "微信"), - type3(3 , "金币"), - type4(4 , "汇联通工会卡"), - type5(5 , "银联"), - type6(6 , "银联分期"), - type7(7 , "嗨森逛油卡"), - type8(8 , "API商户"), - ; - - private Integer type; - private String name; - - OrderPayTypeEnum(int type , String name) { - this.type = type; - this.name = name; - } - - public static String getNameByType(Integer type) { - for (OrderPayTypeEnum ele : values()) { - if(Objects.equals(type,ele.getType())) return ele.getName(); - } - return null; - } - - 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/order/service/OrderPayService.java b/hai-service/src/main/java/com/hai/order/service/OrderPayService.java index 2ef4effb..ef3447fb 100644 --- a/hai-service/src/main/java/com/hai/order/service/OrderPayService.java +++ b/hai-service/src/main/java/com/hai/order/service/OrderPayService.java @@ -33,6 +33,6 @@ public interface OrderPayService { * @param userCard 用户卡号 * @return */ - HighOrder oilCardFleetPay(HighOrder order, HighUserCard userCard); + HighOrder oilCardFleetPay(HighOrder order, HighUserCard userCard, String carLicensePlate); } diff --git a/hai-service/src/main/java/com/hai/order/service/impl/OrderPayServiceImpl.java b/hai-service/src/main/java/com/hai/order/service/impl/OrderPayServiceImpl.java index 0e30be99..0bd39867 100644 --- a/hai-service/src/main/java/com/hai/order/service/impl/OrderPayServiceImpl.java +++ b/hai-service/src/main/java/com/hai/order/service/impl/OrderPayServiceImpl.java @@ -13,8 +13,10 @@ import com.hai.order.service.OrderService; import com.hai.order.type.OrderPayType; import com.hai.order.type.OrderProductType; import com.hai.service.HighFleetOilCardService; +import com.hai.service.HighGasOrderService; import com.hai.service.HighOilCardService; import com.hai.service.HighUserCardService; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -44,6 +46,9 @@ public class OrderPayServiceImpl implements OrderPayService { @Resource private OrderService orderService; + @Resource + private HighGasOrderService gasOrderService; + @Override public HighOrder hltCardPay(HighOrder order, HighUserCard userCard) throws Exception { String goodsDesc = ""; @@ -114,7 +119,17 @@ public class OrderPayServiceImpl implements OrderPayService { } @Override - public HighOrder oilCardFleetPay(HighOrder order, HighUserCard userCard) { + public HighOrder oilCardFleetPay(HighOrder order, HighUserCard userCard, String carLicensePlate) { + if (StringUtils.isNotBlank(carLicensePlate)) { + // 加油订单 + HighGasOrder gasOrder = gasOrderService.getDetailByOrderNo(order.getOrderNo()); + if (gasOrder != null) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到加油订单"); + } + gasOrder.setGasCarLicensePlate(carLicensePlate); + gasOrderService.updateGasOrder(gasOrder); + } + // 油卡扣款 Map consumeMap = new HashMap<>(); consumeMap.put("sourceType", OilCardRecordSourceTypeEnum.type2.getType()); 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 e3c6abea..df787daa 100644 --- a/hai-service/src/main/java/com/hai/service/HighOrderService.java +++ b/hai-service/src/main/java/com/hai/service/HighOrderService.java @@ -33,38 +33,6 @@ public interface HighOrderService { */ void updateChildOrder(HighChildOrder highChildOrder); - /** - * @Author 胡锐 - * @Description 金币支付订单 - * @Date 2021/3/27 11:20 - **/ - 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 用户与卡号关系 - * @param orderId 订单id - * @param carLicensePlate 车牌 - * @throws Exception - */ - void fleetOilCardPayOrder(Long userCardId, Long orderId, String carLicensePlate) throws Exception; - - /** - * 汇联通工会卡支付 - * @param userCardId - * @param orderId - * @throws Exception - */ - void hltUnionCardPay(Long userCardId, Long orderId) throws Exception; - /** * @Author 胡锐 * @Description 修改订单 diff --git a/hai-service/src/main/java/com/hai/service/impl/ApiOpenServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/ApiOpenServiceImpl.java index 47891d75..360aea94 100644 --- a/hai-service/src/main/java/com/hai/service/impl/ApiOpenServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/ApiOpenServiceImpl.java @@ -17,8 +17,6 @@ import com.hai.dao.HighOrderMapper; import com.hai.dao.OutRechargeOrderMapper; import com.hai.entity.*; -import com.hai.enum_type.OrderPayModelEnum; -import com.hai.enum_type.OrderPayTypeEnum; import com.hai.service.*; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Isolation; diff --git a/hai-service/src/main/java/com/hai/service/impl/HighFleetOilCardServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/HighFleetOilCardServiceImpl.java index 00c09973..f62ef26e 100644 --- a/hai-service/src/main/java/com/hai/service/impl/HighFleetOilCardServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/HighFleetOilCardServiceImpl.java @@ -12,6 +12,7 @@ import com.hai.enum_type.*; import com.hai.model.OilCardOrderModel; import com.hai.model.UserInfoModel; import com.hai.order.service.OrderService; +import com.hai.order.type.OrderPayType; import com.hai.service.*; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -279,8 +280,8 @@ public class HighFleetOilCardServiceImpl implements HighFleetOilCardService { ) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单当前状态无法退款"); } - if (!order.getPayType().equals(OrderPayTypeEnum.type7.getType())) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "支付方式,不是油卡"); + if (!order.getPayType().equals(OrderPayType.PAY_TYPE8.getNumber())) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "支付方式,不是车队油卡"); } if (StringUtils.isBlank(order.getMemCardNo())) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的油卡卡号"); 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 3f390b04..a4ae57e8 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 @@ -12,6 +12,7 @@ import com.hai.entity.*; import com.hai.enum_type.*; import com.hai.model.OilCardOrderModel; import com.hai.model.UserInfoModel; +import com.hai.order.type.OrderPayType; import com.hai.service.*; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; @@ -201,8 +202,8 @@ public class HighOilCardServiceImpl implements HighOilCardService { if (order == null) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的的订单"); } - if (!order.getPayType().equals(OrderPayTypeEnum.type7.getType())) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "支付方式,不是油卡"); + if (!order.getPayType().equals(OrderPayType.PAY_TYPE7.getNumber())) { + throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "支付方式,不是个人油卡"); } if (StringUtils.isBlank(order.getMemCardNo())) { throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知的油卡卡号"); 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 f1e403c2..4b0d2df3 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 @@ -19,6 +19,7 @@ import com.hai.entity.*; import com.hai.enum_type.*; import com.hai.model.*; import com.hai.msg.entity.MsgTopic; +import com.hai.order.type.OrderPayType; import com.hai.service.*; import com.hai.service.pay.impl.GoodsOrderServiceImpl; import org.apache.commons.collections4.MapUtils; @@ -364,1291 +365,6 @@ public class HighOrderServiceImpl implements HighOrderService { highChildOrderMapper.updateByPrimaryKey(highChildOrder); } - @Override - @Transactional(propagation = Propagation.REQUIRES_NEW) - public void goldPayOrder(Long userId, Long orderId) throws Exception { - HighOrder highOrder = getOrderById(orderId); - if (highOrder == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, ""); - } - - // 查询用户 - HighUser highUser = highUserService.findByUserId(highOrder.getMemId()); - - // 金币 1:100 - Integer goldNum = new BigDecimal(highOrder.getPayPrice().toString()).multiply(new BigDecimal("100")).intValue(); - - String remark = "订单" + highOrder.getOrderNo() + "下单,使用积分:" + goldNum; - highUserService.goldHandle(userId, goldNum, 2, 2, highOrder.getId() , remark); - - highOrder.setPayTime(new Date()); // 支付时间 - //highOrder.setPayModel(1); // 支付模式:1 金币,2 第三方平台,3 混合 - highOrder.setPayType(3); // 支付方式: 1:支付宝 2:微信 3:金币 - highOrder.setPayGold(goldNum); - highOrder.setPayRealPrice(highOrder.getPayPrice()); - highOrder.setOrderStatus(2); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 - - for (HighChildOrder highChildOrder : highOrder.getHighChildOrderList()) { - highChildOrder.setChildOrderStatus(2); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 - - // 商品类型 商品类型 1:卡卷 2:金币充值 - if (highChildOrder.getGoodsType() == 1) { - // 查询卡券 - HighCoupon coupon = highCouponService.getCouponDetail(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(highOrder.getId()); - orderPre.setOrderNo(highOrder.getOrderNo()); - orderPre.setChildOrderId(highChildOrder.getId()); - orderPre.setPayRealPrice(highOrder.getPayPrice()); - orderPre.setGoodsType(1); - orderPre.setGoodsName(coupon.getCouponName()); - orderPre.setGoodsId(coupon.getId()); - orderPre.setPreUserId(highOrder.getMemId()); - orderPre.setPreUserName(highOrder.getMemName()); - orderPre.setPreUserPhone(highOrder.getMemPhone()); - orderPre.setPreUserRemark(highOrder.getRemarks()); - orderPre.setStatus(1); - highOrderPreService.insertOrderPre(orderPre); - } - // 贵州中石化 - if (coupon.getCouponSource() == 4) { - Map push = new HashMap<>(); - push.put("couTypeCode", coupon.getCouponKey()); - push.put("distCouCount", highChildOrder.getSaleCount()); - push.put("userPhone", highUser.getPhone()); - push.put("thirdUserId", highUser.getUnionId()); - - // 推送给高速 - JSONObject returnParam = HuiLianTongConfig.costRechargeOrder(highChildOrder.getExt2()); - System.out.println(returnParam); - // 推送记录 - HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); - highGasOrderPush.setType(OrderPushType.type6.getType()); - highGasOrderPush.setOrderNo(highOrder.getOrderNo()); - highGasOrderPush.setCreateTime(new Date()); - highGasOrderPush.setCode(returnParam.getString("respCode")); - highGasOrderPush.setRequestContent(JSONObject.toJSONString(push)); - highGasOrderPush.setReturnContent(returnParam.toJSONString()); - highGasOrderPushMapper.insert(highGasOrderPush); - - if (returnParam != null && returnParam.getString("respCode").equals("0000")) { - // 解密 - JSONObject jsonObject = HuiLianTongUnionCardConfig.resolveResponse(returnParam.getString("data")); - JSONArray dataArray = JSONObject.parseObject(jsonObject.getString("data"), JSONArray.class); - for (Object data : dataArray) { - JSONObject dataObject = (JSONObject) data; - HighCouponCodeOther couponCodeOther = new HighCouponCodeOther(); - couponCodeOther.setType(1); - couponCodeOther.setOrderId(highOrder.getId()); - couponCodeOther.setChildOrderId(highChildOrder.getId()); - couponCodeOther.setCouTypeCode(dataObject.getString("couTypeCode")); - couponCodeOther.setCouNo(dataObject.getString("couNo")); - couponCodeOther.setActiveTime(dataObject.getDate("activeTime")); - couponCodeOther.setValidStartDate(dataObject.getDate("validStartDate")); - couponCodeOther.setValidEndDate(dataObject.getDate("validEndDate")); - couponCodeOther.setStatus(20); - couponCodeOther.setCreateTime(new Date()); - highCouponCodeOtherMapper.insert(couponCodeOther); - - // 卡卷关联用户 - HighUserCoupon highUserCoupon = new HighUserCoupon(); - highUserCoupon.setOrderId(orderId); - highUserCoupon.setChildOrderId(highChildOrder.getId()); - highUserCoupon.setMerchantId(coupon.getMerchantId()); - highUserCoupon.setCouponId(coupon.getId()); - highUserCoupon.setUserId(highOrder.getMemId()); - highUserCoupon.setCreateTime(new Date()); - highUserCoupon.setQrCodeImg(dataObject.getString("couNo")); - highUserCoupon.setUseEndTime(dataObject.getDate("validEndDate")); - highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用 - highUserCouponMapper.insert(highUserCoupon); - } - } - - // 重庆中石油 - } else if (coupon.getCouponSource() == 5) { - - // 给用户发码 - JSONObject response = ChongQingCNPCService.sendCNPCTicket(coupon.getCouponKey(), highOrder.getOrderNo(), highChildOrder.getSaleCount(), highOrder.getMemPhone()); - - // 推送记录 - JSONObject request = new JSONObject(); - request.put("requestCode", coupon.getCouponKey()); - request.put("tradeId", highOrder.getOrderNo()); - request.put("ticketSum", highChildOrder.getSaleCount()); - request.put("phone", highOrder.getMemPhone()); - - HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); - highGasOrderPush.setType(OrderPushType.type10.getType()); - highGasOrderPush.setOrderNo(highOrder.getOrderNo()); - highGasOrderPush.setCreateTime(new Date()); - highGasOrderPush.setRequestContent(request.toJSONString()); - highGasOrderPush.setReturnContent(response.toJSONString()); - highGasOrderPushMapper.insert(highGasOrderPush); - - JSONObject couponDetail = response.getJSONObject("ticketDetail"); - JSONArray codeList = response.getJSONArray("codeList"); - - for (Object data : codeList) { - HighCouponCodeOther couponCodeOther = new HighCouponCodeOther(); - couponCodeOther.setType(2); - couponCodeOther.setOrderId(highOrder.getId()); - couponCodeOther.setChildOrderId(highChildOrder.getId()); - couponCodeOther.setCouTypeCode(couponDetail.getString("requestCode")); - couponCodeOther.setCouNo(ChongQingCNPCService.decryptCouponCode(String.valueOf(data))); - couponCodeOther.setActiveTime(DateUtil.format(couponDetail.getString("effectiveTime"), "yyyy-MM-dd")); - couponCodeOther.setValidStartDate(DateUtil.format(couponDetail.getString("effectiveTime"), "yyyy-MM-dd")); - couponCodeOther.setValidEndDate(DateUtil.format(couponDetail.getString("expiredDate"), "yyyy-MM-dd")); - couponCodeOther.setStatus(20); - couponCodeOther.setCreateTime(new Date()); - highCouponCodeOtherMapper.insert(couponCodeOther); - - // 卡卷关联用户 - HighUserCoupon highUserCoupon = new HighUserCoupon(); - highUserCoupon.setMerchantId(coupon.getMerchantId()); - highUserCoupon.setCouponId(coupon.getId()); - highUserCoupon.setOrderId(orderId); - highUserCoupon.setChildOrderId(highChildOrder.getId()); - highUserCoupon.setUserId(highOrder.getMemId()); - highUserCoupon.setCreateTime(new Date()); - highUserCoupon.setQrCodeImg(couponCodeOther.getCouNo()); - highUserCoupon.setUseEndTime(couponCodeOther.getValidEndDate()); - highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用 - highUserCouponMapper.insert(highUserCoupon); - } - - } 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.setOrderId(orderId); - highUserCoupon.setChildOrderId(highChildOrder.getId()); - highUserCoupon.setMerchantId(code.getMerchantId()); - highUserCoupon.setCouponId(code.getCouponId()); - highUserCoupon.setUserId(highOrder.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"), highOrder.getMemId(), 1); - } - } - - if (highChildOrder.getGoodsType() == 3) { - highChildOrder.setChildOrderStatus(3); - highOrder.setOrderStatus(3); - HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highChildOrder.getGoodsId()); - -/* // 来源类型 1:平台自建 2:团油 - if (store.getSourceType().equals(MerchantStoreSourceType.type1.getNumber())) { - - // 预存类型 0:非预存 1:预存门店 - if (store.getPrestoreType() != null && store.getPrestoreType().equals(1)) { - Map pushParam = new HashMap<>(); - pushParam.put("businessType", MerStoreAmountTypeEnum.type2.getType()); - pushParam.put("storeId", highChildOrder.getGoodsId()); - pushParam.put("price", highOrder.getTotalPrice()); - pushParam.put("sourceType", MerStoreAmountSourceTypeEnum.type2.getType()); - pushParam.put("sourceId", highOrder.getId()); - pushParam.put("sourceContent", "订单号:" + highOrder.getOrderNo() + ",加油金额:¥" + highOrder.getTotalPrice()); - pushParam.put("opUserId", highOrder.getMemId()); - pushParam.put("opUserName", highOrder.getMemName()); - // 扣预存款 - this.redisTemplate.boundListOps(MsgTopic.MerStoreAccount.getName()).leftPush(pushParam); - } - } else if (store.getSourceType().equals(MerchantStoreSourceType.type2.getNumber())) { - // 推送团油订单 - 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", highOrder.getMemPhone()); - paramMap.put("thirdSerialNo", highOrder.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(highOrder.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")); - } - } else if (store.getSourceType().equals(MerchantStoreSourceType.type3.getNumber())) { - - // 推送加好油 - shellGroupService.gasSyncPayment(highOrder.getOrderNo(), - store.getStoreKey(), - highOrder.getPayTime(), - highChildOrder.getTotalPrice(), - highChildOrder.getGasOilNo(), - highChildOrder.getGasGunNo(), - highOrder.getPayablePrice(), - highOrder.getDeductionPrice() - ); - - } else if (store.getSourceType().equals(MerchantStoreSourceType.type4.getNumber())) { - // 推送金猪加油 - jinZhuJiaYouService.payOrder(highOrder.getOrderNo(), highChildOrder.getGasPriceChannelPay()); - }*/ - } - - if (highChildOrder.getGoodsType() == 7) { - HighDiscountPackageActual actual = discountPackageActualService.getDetailByChildOrderId(highChildOrder.getId()); - if (actual != null) { - List discountList = discountPackageDiscountActualService.getHighDiscountPackageDiscountActualList(actual.getId()); - for (HighDiscountPackageDiscountActual discount : discountList) { - highDiscountUserRelService.receiveDiscount(highOrder.getMemId(), discount.getAgentDiscountCodeId()); - } - HighDiscountPackage discountPackage = discountPackageService.findDiscountPackageById(actual.getDiscountPackageId()); - HighDiscountPackageRecord record = new HighDiscountPackageRecord(); - record.setDiscountPackageId(discountPackage.getId()); - record.setDiscountPackageTitle(discountPackage.getTitle()); - record.setUsingAttribution(discountPackage.getUsingAttribution()); - record.setCompanyId(discountPackage.getCompanyId()); - record.setOrderId(highOrder.getId().intValue()); - record.setChildOrderId(highChildOrder.getId().intValue()); - record.setRecordNo(System.currentTimeMillis() + ""); - record.setSalesType(1); - record.setPrice(highOrder.getPayPrice()); - record.setUserId(highOrder.getMemId().intValue()); - discountPackageRecordService.insertRecord(record); - actual.setAllocationTime(new Date()); - actual.setStatus(3); // 状态: 1: 待分配 2:预分配(售卖)3:已分配 - discountPackageActualService.updateHighDiscountPackageActual(actual); - } - } - } - - updateOrder(highOrder); - - new Thread(() -> { - if (highOrder.getHighChildOrderList().get(0).getGoodsType().equals(3)) { - printGasOrder(highOrder.getHighChildOrderList().get(0).getGoodsId(), highOrder, false); - - Map pushMsg = new HashMap<>(); - pushMsg.put("userId", highOrder.getHighChildOrderList().get(0).getGoodsId()); - - Map msgContent = new HashMap<>(); - msgContent.put("order", highOrderService.getGasOrderDetail(highOrder.getOrderNo())); - msgContent.put("voice", baiduVoiceService.text2audio(highOrder.getHighChildOrderList().get(0).getGoodsName() + ",收款:" + highOrder.getTotalPrice() + "元")); - pushMsg.put("message", JSONObject.toJSONString(msgContent)); - HttpsUtils.doPost("http://127.0.0.1:9901/msg/websocket/websocket", pushMsg, new HashMap<>()); - } - }).start(); - } - - @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.setChildOrderStatus(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) { - Map push = new HashMap<>(); - push.put("couTypeCode", coupon.getCouponKey()); - push.put("distCouCount", highChildOrder.getSaleCount()); - push.put("userPhone", highUser.getPhone()); - push.put("thirdUserId", highUser.getUnionId()); - - // 推送给高速 - JSONObject returnParam = HuiLianTongConfig.costRechargeOrder(highChildOrder.getExt2()); - if (returnParam != null && returnParam.getString("respCode").equals("0000")) { - // 解密 - JSONObject jsonObject = HuiLianTongUnionCardConfig.resolveResponse(returnParam.getString("data")); - JSONArray dataArray = JSONObject.parseObject(jsonObject.getString("data"), JSONArray.class); - 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.setActiveTime(dataObject.getDate("activeTime")); - couponCodeOther.setValidStartDate(dataObject.getDate("validStartDate")); - couponCodeOther.setValidEndDate(dataObject.getDate("validEndDate")); - couponCodeOther.setStatus(20); - couponCodeOther.setCreateTime(new Date()); - highCouponCodeOtherMapper.insert(couponCodeOther); - - // 卡卷关联用户 - HighUserCoupon highUserCoupon = new HighUserCoupon(); - highUserCoupon.setOrderId(order.getId()); - highUserCoupon.setChildOrderId(highChildOrder.getId()); - 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 if (coupon.getCouponSource() == 5) { - // 给用户发码 - JSONObject response = ChongQingCNPCService.sendCNPCTicket(coupon.getCouponKey(), order.getOrderNo(), highChildOrder.getSaleCount(), order.getMemPhone()); - - // 推送记录 - JSONObject request = new JSONObject(); - request.put("requestCode", coupon.getCouponKey()); - request.put("tradeId", order.getOrderNo()); - request.put("ticketSum", highChildOrder.getSaleCount()); - request.put("phone", order.getMemPhone()); - - HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); - highGasOrderPush.setType(OrderPushType.type10.getType()); - highGasOrderPush.setOrderNo(order.getOrderNo()); - highGasOrderPush.setCreateTime(new Date()); - highGasOrderPush.setRequestContent(request.toJSONString()); - highGasOrderPush.setReturnContent(response.toJSONString()); - highGasOrderPushMapper.insert(highGasOrderPush); - - JSONObject couponDetail = response.getJSONObject("ticketDetail"); - JSONArray codeList = response.getJSONArray("codeList"); - - for (Object data : codeList) { - HighCouponCodeOther couponCodeOther = new HighCouponCodeOther(); - couponCodeOther.setType(2); - couponCodeOther.setOrderId(order.getId()); - couponCodeOther.setChildOrderId(highChildOrder.getId()); - couponCodeOther.setCouTypeCode(couponDetail.getString("requestCode")); - couponCodeOther.setCouNo(ChongQingCNPCService.decryptCouponCode(String.valueOf(data))); - couponCodeOther.setActiveTime(DateUtil.format(couponDetail.getString("effectiveTime"), "yyyy-MM-dd")); - couponCodeOther.setValidStartDate(DateUtil.format(couponDetail.getString("effectiveTime"), "yyyy-MM-dd")); - couponCodeOther.setValidEndDate(DateUtil.format(couponDetail.getString("expiredDate"), "yyyy-MM-dd")); - couponCodeOther.setStatus(20); - couponCodeOther.setCreateTime(new Date()); - highCouponCodeOtherMapper.insert(couponCodeOther); - - // 卡卷关联用户 - HighUserCoupon highUserCoupon = new HighUserCoupon(); - highUserCoupon.setOrderId(order.getId()); - highUserCoupon.setChildOrderId(highChildOrder.getId()); - highUserCoupon.setMerchantId(coupon.getMerchantId()); - highUserCoupon.setCouponId(coupon.getId()); - highUserCoupon.setUserId(order.getMemId()); - highUserCoupon.setCreateTime(new Date()); - highUserCoupon.setQrCodeImg(couponCodeOther.getCouNo()); - highUserCoupon.setUseEndTime(couponCodeOther.getValidEndDate()); - highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用 - highUserCouponMapper.insert(highUserCoupon); - } - } 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.setOrderId(order.getId()); - highUserCoupon.setChildOrderId(highChildOrder.getId()); - 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.setChildOrderStatus(3); - order.setOrderStatus(3); - HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highChildOrder.getGoodsId()); - - // 来源类型 1:平台自建 2:团油 - if (store.getSourceType().equals(1)) { - - // 预存类型 0:非预存 1:预存门店 - if (store.getPrestoreType() != null && store.getPrestoreType().equals(1)) { - Map pushParam = new HashMap<>(); - pushParam.put("businessType", MerStoreAmountTypeEnum.type2.getType()); - pushParam.put("storeId", highChildOrder.getGoodsId()); - pushParam.put("price", order.getTotalPrice()); - pushParam.put("sourceType", MerStoreAmountSourceTypeEnum.type2.getType()); - pushParam.put("sourceId", order.getId()); - pushParam.put("sourceContent", "订单号:" + order.getOrderNo() + ",加油金额:¥" + order.getTotalPrice()); - pushParam.put("opUserId", order.getMemId()); - pushParam.put("opUserName", order.getMemName()); - // 扣预存款 - this.redisTemplate.boundListOps(MsgTopic.MerStoreAccount.getName()).leftPush(pushParam); - } - - } else if (store.getSourceType().equals(2)) { - // 推送团油订单 - 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")); - } - } else if (store.getSourceType().equals(MerchantStoreSourceType.type3.getNumber())) { - - // 推送加好油 - shellGroupService.gasSyncPayment(order.getOrderNo(), - store.getStoreKey(), - order.getPayTime(), - highChildOrder.getTotalPrice(), - highChildOrder.getGasOilNo(), - highChildOrder.getGasGunNo(), - order.getPayablePrice(), - order.getDeductionPrice() - ); - } else if (store.getSourceType().equals(MerchantStoreSourceType.type4.getNumber())) { - // 推送金猪加油 - jinZhuJiaYouService.payOrder(order.getOrderNo(), highChildOrder.getGasPriceChannelPay()); - } - }*/ - - } - - updateOrder(order); - - new Thread(() -> { - if (order.getHighChildOrderList().get(0).getGoodsType().equals(3)) { - - printGasOrder(order.getHighChildOrderList().get(0).getGoodsId(), order, false); - - Map pushMsg = new HashMap<>(); - pushMsg.put("userId", order.getHighChildOrderList().get(0).getGoodsId()); - - Map msgContent = new HashMap<>(); - msgContent.put("order", highOrderService.getGasOrderDetail(order.getOrderNo())); - msgContent.put("voice", baiduVoiceService.text2audio(order.getHighChildOrderList().get(0).getGoodsName() + ",收款:" + order.getTotalPrice() + "元")); - pushMsg.put("message", JSONObject.toJSONString(msgContent)); - HttpsUtils.doPost("http://127.0.0.1:9901/msg/websocket/websocket", pushMsg, new HashMap<>()); - } - }).start(); - } - - @Override - @Transactional(propagation = Propagation.REQUIRES_NEW) - public void fleetOilCardPayOrder(Long userCardId, Long orderId, String carLicensePlate) throws Exception { -// HighUserCard userCard = highUserCardService.getDetailById(userCardId); -// if (userCard == null) { -// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到用户绑定的卡号信息"); -// } -// if (!userCard.getType().equals(UserCardType.type3.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()); -// fleetOilCardService.consume(userCard.getCardNo(), order.getMemPhone(), 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) { -// Map push = new HashMap<>(); -// push.put("couTypeCode", coupon.getCouponKey()); -// push.put("distCouCount", highChildOrder.getSaleCount()); -// push.put("userPhone", highUser.getPhone()); -// push.put("thirdUserId", highUser.getUnionId()); -// -// // 推送给高速 -// JSONObject returnParam = HuiLianTongConfig.costRechargeOrder(highChildOrder.getExt2()); -// if (returnParam != null && returnParam.getString("respCode").equals("0000")) { -// // 解密 -// JSONObject jsonObject = HuiLianTongUnionCardConfig.resolveResponse(returnParam.getString("data")); -// JSONArray dataArray = JSONObject.parseObject(jsonObject.getString("data"), JSONArray.class); -// 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.setActiveTime(dataObject.getDate("activeTime")); -// couponCodeOther.setValidStartDate(dataObject.getDate("validStartDate")); -// couponCodeOther.setValidEndDate(dataObject.getDate("validEndDate")); -// couponCodeOther.setStatus(20); -// couponCodeOther.setCreateTime(new Date()); -// 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.setGasCarLicensePlate(carLicensePlate); -// highChildOrder.setChildOrdeStatus(3); -// order.setOrderStatus(3); -// HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highChildOrder.getGoodsId()); -// -// // 来源类型 1:平台自建 2:团油 -// if (store.getSourceType().equals(1)) { -// -// // 预存类型 0:非预存 1:预存门店 -// if (store.getPrestoreType() != null && store.getPrestoreType().equals(1)) { -// Map pushParam = new HashMap<>(); -// pushParam.put("businessType", MerStoreAmountTypeEnum.type2.getType()); -// pushParam.put("storeId", highChildOrder.getGoodsId()); -// pushParam.put("price", order.getTotalPrice()); -// pushParam.put("sourceType", MerStoreAmountSourceTypeEnum.type2.getType()); -// pushParam.put("sourceId", order.getId()); -// pushParam.put("sourceContent", "订单号:" + order.getOrderNo() + ",加油金额:¥" + order.getTotalPrice()); -// pushParam.put("opUserId", order.getMemId()); -// pushParam.put("opUserName", order.getMemName()); -// // 扣预存款 -// this.redisTemplate.boundListOps(MsgTopic.MerStoreAccount.getName()).leftPush(pushParam); -// } -// -// } else if (store.getSourceType().equals(2)) { -// // 推送团油订单 -// 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")); -// } -// } else if (store.getSourceType().equals(MerchantStoreSourceType.type3.getNumber())) { -// -// // 推送加好油 -// shellGroupService.gasSyncPayment(order.getOrderNo(), -// store.getStoreKey(), -// order.getPayTime(), -// highChildOrder.getTotalPrice(), -// highChildOrder.getGasOilNo(), -// highChildOrder.getGasGunNo(), -// order.getPayablePrice(), -// order.getDeductionPrice() -// ); -// } else if (store.getSourceType().equals(MerchantStoreSourceType.type4.getNumber())) { -// // 推送金猪加油 -// jinZhuJiaYouService.payOrder(order.getOrderNo(), highChildOrder.getGasPriceChannelPay()); -// } -// } -// -// } -// -// updateOrder(order); -// -// new Thread(() -> { -// if (order.getHighChildOrderList().get(0).getGoodsType().equals(3)) { -// -// printGasOrder(order.getHighChildOrderList().get(0).getGoodsId(), order, false); -// -// Map pushMsg = new HashMap<>(); -// pushMsg.put("userId", order.getHighChildOrderList().get(0).getGoodsId()); -// -// Map msgContent = new HashMap<>(); -// msgContent.put("order", highOrderService.getGasOrderDetail(order.getOrderNo())); -// msgContent.put("voice", baiduVoiceService.text2audio(order.getHighChildOrderList().get(0).getGoodsName() + ",收款:" + order.getTotalPrice() + "元")); -// pushMsg.put("message", JSONObject.toJSONString(msgContent)); -// HttpsUtils.doPost("http://127.0.0.1:9901/msg/websocket/websocket", pushMsg, new HashMap<>()); -// } -// }).start(); - } - - @Override - @Transactional(propagation = Propagation.REQUIRES_NEW) - public void hltUnionCardPay(Long userCardId, Long orderId) throws Exception { - HighUserCard userCard = highUserCardService.getDetailById(userCardId); - if (userCard == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到用户绑定的卡号信息"); - } - // 查询订单信息 - HighOrder order = getOrderById(orderId); - if (order == null) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, ""); - } - String goodsDesc = ""; - String tranDesc = ""; - String instCode = "11101527"; - String businessType = "hisen_consume"; - - if (order.getHighChildOrderList().get(0).getGoodsType() == 1) { - instCode = "11101526"; - businessType = "sinopec_oil_code"; - goodsDesc = "购买加油券"; - tranDesc = order.getHighChildOrderList().get(0).getGoodsName(); - - } else if (order.getHighChildOrderList().get(0).getGoodsType() == 2) { - goodsDesc = "积分充值" + order.getPayPrice() + "元"; - tranDesc = "嗨森逛积分充值" + order.getPayPrice() + "元"; - - } else if (order.getHighChildOrderList().get(0).getGoodsType() == 3) { - // 查询团油账号余额 - JSONObject accountInfo2JD = TuanYouConfig.queryCompanyAccountInfo2JD(); - JSONArray result = accountInfo2JD.getJSONArray("result"); - for (Object accountObject : result) { - JSONObject account = (JSONObject) accountObject; -/* // 1:汽油:2:柴油;3:天然气 - if (account.getInteger("energyType").equals(order.getHighChildOrderList().get(0).getGasOilType())) { - // 支付金额 大于 团油账号余额 - if (order.getPayPrice().compareTo(account.getBigDecimal("accountBalance")) == 1) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法进行支付,请联系平台客服"); - } - }*/ - } - goodsDesc = "加油站加" + order.getPayPrice() + "元油"; - tranDesc = "【" + order.getHighChildOrderList().get(0).getGoodsName() + "】加油" + order.getPayPrice() + "元"; - - } else if (order.getHighChildOrderList().get(0).getGoodsType() == 7) { - goodsDesc = "购买优惠券包"; - tranDesc = "购买" + order.getHighChildOrderList().get(0).getGoodsName() + "优惠券包"; - - } else { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法支付,请使用其他支付方式"); - } - - // 工会卡支付 - JSONObject consumption = HuiLianTongUnionCardConfig.consumption(order.getOrderNo(), userCard.getCardNo(), order.getPayPrice(), businessType, instCode, goodsDesc, tranDesc); - System.out.println("工会卡支付响应参数" + consumption.toJSONString()); - - Map dataMap = new HashMap<>(); - dataMap.put("orderNo", order.getOrderNo()); - dataMap.put("cardType", "ghk"); - dataMap.put("cardNo", userCard.getCardNo()); - dataMap.put("checkPassword", "N"); - dataMap.put("tranAmount", order.getPayPrice()); - dataMap.put("tranChannel", "HiSen"); - dataMap.put("businessType", businessType); - dataMap.put("instCode", instCode); - dataMap.put("goodsDesc", goodsDesc); - dataMap.put("tranDesc", tranDesc); - HighGasOrderPush payPush = new HighGasOrderPush(); - payPush.setType(OrderPushType.type5.getType()); - payPush.setOrderNo(userCard.getCardNo()); - payPush.setCreateTime(new Date()); - payPush.setCode(consumption.getString("respCode")); - payPush.setRequestContent(JSON.toJSONString(dataMap)); - payPush.setReturnContent(consumption.toJSONString()); - highGasOrderPushMapper.insert(payPush); - - if (!consumption.getString("respCode").equals("0000")) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumption.getString("respMessage")); - } - JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(consumption.getString("data")); - if (consumptionResult.getBoolean("success") != true) { - throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumptionResult.getString("message")); - } - - // 查询用户 - HighUser highUser = highUserService.findByUserId(order.getMemId()); - - order.setMemCardId(userCard.getId()); - order.setMemCardNo(userCard.getCardNo()); - order.setMemCardType(userCard.getType()); - order.setPaySerialNo(consumptionResult.getString("orderId")); // 支付流水号 - order.setPayRealPrice(order.getPayPrice()); // 实付金额 - order.setPayTime(new Date()); // 支付时间 - //order.setPayModel(2); // 支付模式:1 金币,2 第三方平台,3 混合 - order.setPayType(4); // 支付方式: 1:支付宝 2:微信 3:金币 4:汇联通支工会卡 - order.setOrderStatus(2); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 - - for (HighChildOrder highChildOrder : order.getHighChildOrderList()) { - // 商品类型 商品类型 1:卡卷 2:金币充值 - if (highChildOrder.getGoodsType() == 1) { - highChildOrder.setChildOrderStatus(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) { - Map push = new HashMap<>(); - push.put("couTypeCode", coupon.getCouponKey()); - push.put("distCouCount", highChildOrder.getSaleCount()); - push.put("userPhone", highUser.getPhone()); - push.put("thirdUserId", highUser.getUnionId()); - - // 推送给高速 - JSONObject returnParam = HuiLianTongConfig.costRechargeOrder(highChildOrder.getExt2()); - if (returnParam != null && returnParam.getString("respCode").equals("0000")) { - // 解密 - JSONObject jsonObject = HuiLianTongUnionCardConfig.resolveResponse(returnParam.getString("data")); - JSONArray dataArray = JSONObject.parseObject(jsonObject.getString("data"), JSONArray.class); - 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.setActiveTime(dataObject.getDate("activeTime")); - couponCodeOther.setValidStartDate(dataObject.getDate("validStartDate")); - couponCodeOther.setValidEndDate(dataObject.getDate("validEndDate")); - couponCodeOther.setStatus(20); - couponCodeOther.setCreateTime(new Date()); - highCouponCodeOtherMapper.insert(couponCodeOther); - - // 卡卷关联用户 - HighUserCoupon highUserCoupon = new HighUserCoupon(); - highUserCoupon.setOrderId(order.getId()); - highUserCoupon.setChildOrderId(highChildOrder.getId()); - 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 if (coupon.getCouponSource() == 5) { - // 给用户发码 - JSONObject response = ChongQingCNPCService.sendCNPCTicket(coupon.getCouponKey(), order.getOrderNo(), highChildOrder.getSaleCount(), order.getMemPhone()); - - // 推送记录 - JSONObject request = new JSONObject(); - request.put("requestCode", coupon.getCouponKey()); - request.put("tradeId", order.getOrderNo()); - request.put("ticketSum", highChildOrder.getSaleCount()); - request.put("phone", order.getMemPhone()); - - HighGasOrderPush highGasOrderPush = new HighGasOrderPush(); - highGasOrderPush.setType(OrderPushType.type10.getType()); - highGasOrderPush.setOrderNo(order.getOrderNo()); - highGasOrderPush.setCreateTime(new Date()); - highGasOrderPush.setRequestContent(request.toJSONString()); - highGasOrderPush.setReturnContent(response.toJSONString()); - highGasOrderPushMapper.insert(highGasOrderPush); - - JSONObject couponDetail = response.getJSONObject("ticketDetail"); - JSONArray codeList = response.getJSONArray("codeList"); - - for (Object data : codeList) { - HighCouponCodeOther couponCodeOther = new HighCouponCodeOther(); - couponCodeOther.setType(2); - couponCodeOther.setOrderId(order.getId()); - couponCodeOther.setChildOrderId(highChildOrder.getId()); - couponCodeOther.setCouTypeCode(couponDetail.getString("requestCode")); - couponCodeOther.setCouNo(ChongQingCNPCService.decryptCouponCode(String.valueOf(data))); - couponCodeOther.setActiveTime(DateUtil.format(couponDetail.getString("effectiveTime"), "yyyy-MM-dd")); - couponCodeOther.setValidStartDate(DateUtil.format(couponDetail.getString("effectiveTime"), "yyyy-MM-dd")); - couponCodeOther.setValidEndDate(DateUtil.format(couponDetail.getString("expiredDate"), "yyyy-MM-dd")); - couponCodeOther.setStatus(20); - couponCodeOther.setCreateTime(new Date()); - highCouponCodeOtherMapper.insert(couponCodeOther); - - // 卡卷关联用户 - HighUserCoupon highUserCoupon = new HighUserCoupon(); - highUserCoupon.setOrderId(order.getId()); - highUserCoupon.setChildOrderId(highChildOrder.getId()); - highUserCoupon.setMerchantId(coupon.getMerchantId()); - highUserCoupon.setCouponId(coupon.getId()); - highUserCoupon.setUserId(order.getMemId()); - highUserCoupon.setCreateTime(new Date()); - highUserCoupon.setQrCodeImg(couponCodeOther.getCouNo()); - highUserCoupon.setUseEndTime(couponCodeOther.getValidEndDate()); - highUserCoupon.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用 - highUserCouponMapper.insert(highUserCoupon); - } - } 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.setOrderId(order.getId()); - highUserCoupon.setChildOrderId(highChildOrder.getId()); - 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() == 2) { - highChildOrder.setChildOrderStatus(3); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消 - // 金币 1:100 - Integer goldNum = new BigDecimal(highChildOrder.getTotalPrice().toString()).multiply(new BigDecimal("100")).intValue(); - String remark = "订单" + order.getOrderNo() + "积分充值积分:" + goldNum; - highUserService.goldHandle(highChildOrder.getGoodsId(), goldNum, 1, 1, highChildOrder.getId() , remark); - } - - /* if (highChildOrder.getGoodsType() == 3) { - highChildOrder.setChildOrderStatus(3); - order.setOrderStatus(3); - HighMerchantStoreModel store = highMerchantStoreService.getMerchantStoreById(highChildOrder.getGoodsId()); - - // 来源类型 1:平台自建 2:团油 - if (store.getSourceType().equals(1)) { - - // 预存类型 0:非预存 1:预存门店 - if (store.getPrestoreType() != null && store.getPrestoreType().equals(1)) { - Map pushParam = new HashMap<>(); - pushParam.put("businessType", MerStoreAmountTypeEnum.type2.getType()); - pushParam.put("storeId", highChildOrder.getGoodsId()); - pushParam.put("price", order.getTotalPrice()); - pushParam.put("sourceType", MerStoreAmountSourceTypeEnum.type2.getType()); - pushParam.put("sourceId", order.getId()); - pushParam.put("sourceContent", "订单号:" + order.getOrderNo() + ",加油金额:¥" + order.getTotalPrice()); - pushParam.put("opUserId", order.getMemId()); - pushParam.put("opUserName", order.getMemName()); - // 扣预存款 - this.redisTemplate.boundListOps(MsgTopic.MerStoreAccount.getName()).leftPush(pushParam); - } - } else if (store.getSourceType().equals(2)) { - // 推送团油订单 - 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")); - } - } else if (store.getSourceType().equals(MerchantStoreSourceType.type3.getNumber())) { - - // 推送加好油 - shellGroupService.gasSyncPayment(order.getOrderNo(), - store.getStoreKey(), - order.getPayTime(), - highChildOrder.getTotalPrice(), - highChildOrder.getGasOilNo(), - highChildOrder.getGasGunNo(), - order.getPayablePrice(), - order.getDeductionPrice() - ); - } else if (store.getSourceType().equals(MerchantStoreSourceType.type4.getNumber())) { - // 推送金猪加油 - jinZhuJiaYouService.payOrder(order.getOrderNo(), highChildOrder.getGasPriceChannelPay()); - } - }*/ - - if (highChildOrder.getGoodsType() == 7) { - HighDiscountPackageActual actual = discountPackageActualService.getDetailByChildOrderId(highChildOrder.getId()); - if (actual != null) { - List discountList = discountPackageDiscountActualService.getHighDiscountPackageDiscountActualList(actual.getId()); - for (HighDiscountPackageDiscountActual discount : discountList) { - highDiscountUserRelService.receiveDiscount(order.getMemId(), discount.getAgentDiscountCodeId()); - } - HighDiscountPackage discountPackage = discountPackageService.findDiscountPackageById(actual.getDiscountPackageId()); - HighDiscountPackageRecord record = new HighDiscountPackageRecord(); - record.setDiscountPackageId(discountPackage.getId()); - record.setDiscountPackageTitle(discountPackage.getTitle()); - record.setUsingAttribution(discountPackage.getUsingAttribution()); - record.setCompanyId(discountPackage.getCompanyId()); - record.setOrderId(order.getId().intValue()); - record.setChildOrderId(highChildOrder.getId().intValue()); - record.setRecordNo(System.currentTimeMillis() + ""); - record.setSalesType(1); - record.setPrice(order.getPayPrice()); - record.setUserId(order.getMemId().intValue()); - discountPackageRecordService.insertRecord(record); - actual.setAllocationTime(new Date()); - actual.setStatus(3); // 状态: 1: 待分配 2:预分配(售卖)3:已分配 - discountPackageActualService.updateHighDiscountPackageActual(actual); - } - } - } - - updateOrder(order); - - new Thread(() -> { - if (order.getHighChildOrderList().get(0).getGoodsType().equals(3)) { - printGasOrder(order.getHighChildOrderList().get(0).getGoodsId(), order, false); - - Map pushMsg = new HashMap<>(); - pushMsg.put("userId", order.getHighChildOrderList().get(0).getGoodsId()); - - Map msgContent = new HashMap<>(); - msgContent.put("order", highOrderService.getGasOrderDetail(order.getOrderNo())); - msgContent.put("voice", baiduVoiceService.text2audio(order.getHighChildOrderList().get(0).getGoodsName() + ",收款:" + order.getTotalPrice() + "元")); - pushMsg.put("message", JSONObject.toJSONString(msgContent)); - HttpsUtils.doPost("http://127.0.0.1:9901/msg/websocket/websocket", pushMsg, new HashMap<>()); - } - }).start(); - } - @Override @Transactional(propagation = Propagation.REQUIRES_NEW) public void updateOrder(HighOrder highOrder) { 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 3281ccb2..4350f3a5 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 @@ -146,7 +146,7 @@ public class HighUserCardServiceImpl implements HighUserCardService { @Override public Boolean isBindHtlCard(Long userId) { HighUserCardExample example = new HighUserCardExample(); - example.createCriteria().andUserIdEqualTo(userId).andStatusNotEqualTo(0); + example.createCriteria().andUserIdEqualTo(userId).andTypeEqualTo(UserCardType.type1.getType()).andStatusNotEqualTo(0); List list = highUserCardMapper.selectByExample(example); if (list.size() > 0) { return true; @@ -157,7 +157,7 @@ public class HighUserCardServiceImpl implements HighUserCardService { @Override public HighUserCard getUserHtlCardNo(Long userId) { HighUserCardExample example = new HighUserCardExample(); - example.createCriteria().andUserIdEqualTo(userId).andStatusNotEqualTo(0); + example.createCriteria().andUserIdEqualTo(userId).andTypeEqualTo(UserCardType.type1.getType()).andStatusNotEqualTo(0); List list = highUserCardMapper.selectByExample(example); if(list.size() > 0) { return list.get(0); 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 6604de3a..0617f0a8 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 @@ -187,7 +187,7 @@ public class HighUserServiceImpl implements HighUserService { user.setHltCardNo(highUserCardService.getUserHtlCardNo(userId)); // 查询油卡 - List oilCardList = highUserCardService.getListByUser(userId, 2); + List oilCardList = highUserCardService.getListByUser(userId, UserCardType.type2.getType()); if (oilCardList.size() > 0) { user.setIsSetOilCard(true); // 查询油卡