|
|
|
@ -383,300 +383,6 @@ public class HighOrderServiceImpl implements HighOrderService { |
|
|
|
|
highOrderMapper.updateByPrimaryKey(highOrder); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void orderBusinessTransaction(HighOrder order) throws Exception { |
|
|
|
|
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<String, Object> push = new HashMap<>(); |
|
|
|
|
push.put("couTypeCode", coupon.getCouponKey()); |
|
|
|
|
push.put("distCouCount", highChildOrder.getSaleCount()); |
|
|
|
|
push.put("userPhone", order.getMemPhone()); |
|
|
|
|
// push.put("thirdUserId", order.getMerchId());
|
|
|
|
|
|
|
|
|
|
// 推送给高速
|
|
|
|
|
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<String, Object> 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 , highChildOrder.getChildOrderNo()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* 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<String, Object> 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); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 打印小票
|
|
|
|
|
printGasOrder(highChildOrder.getGoodsId(), order, false); |
|
|
|
|
|
|
|
|
|
} else if (store.getSourceType().equals(2)) { |
|
|
|
|
// 推送团油订单
|
|
|
|
|
Map<String, Object> 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())) { |
|
|
|
|
// 推送金猪加油
|
|
|
|
|
JSONObject jzOrderObject = jinZhuJiaYouService.payOrder(order.getOrderNo(), highChildOrder.getGasPriceChannelPay()); |
|
|
|
|
if (jzOrderObject == null |
|
|
|
|
|| !jzOrderObject.getString("type").equals("OK") |
|
|
|
|
|| !jzOrderObject.getInteger("status").equals(200)) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, jzOrderObject.getString("title")); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
*/ |
|
|
|
|
if (highChildOrder.getGoodsType() == 7) { |
|
|
|
|
HighDiscountPackageActual actual = discountPackageActualService.getDetailByChildOrderNo(highChildOrder.getOrderNo()); |
|
|
|
|
if (actual != null) { |
|
|
|
|
List<HighDiscountPackageDiscountActual> 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); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Integer getUndoneChildOrder(Long orderId) { |
|
|
|
|
HighOrder order = getOrderById(orderId); |
|
|
|
@ -830,50 +536,6 @@ public class HighOrderServiceImpl implements HighOrderService { |
|
|
|
|
return list; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<HighOrder> getOrderListNotChild(Map<String, Object> map) { |
|
|
|
|
HighOrderExample example = new HighOrderExample(); |
|
|
|
|
HighOrderExample.Criteria criteria = example.createCriteria(); |
|
|
|
|
|
|
|
|
|
if (MapUtils.getLong(map, "memId") != null) { |
|
|
|
|
criteria.andMemIdEqualTo(MapUtils.getLong(map, "memId")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(MapUtils.getString(map, "status"))) { |
|
|
|
|
String[] statuses = MapUtils.getString(map, "status").split(","); |
|
|
|
|
List<Integer> list = new ArrayList<>(); |
|
|
|
|
for (String status : statuses) { |
|
|
|
|
list.add(Integer.parseInt(status)); |
|
|
|
|
} |
|
|
|
|
criteria.andOrderStatusIn(list); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (MapUtils.getString(map, "orderNo") != null) { |
|
|
|
|
criteria.andOrderNoEqualTo(MapUtils.getString(map, "orderNo")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (MapUtils.getString(map, "phone") != null) { |
|
|
|
|
criteria.andMemPhoneEqualTo(MapUtils.getString(map, "phone")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (MapUtils.getInteger(map, "productType") != null) { |
|
|
|
|
criteria.andProductTypeEqualTo(MapUtils.getInteger(map, "productType")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(MapUtils.getString(map, "createTimeS")) && StringUtils.isNotBlank(MapUtils.getString(map, "createTimeE"))) { |
|
|
|
|
criteria.andCreateTimeBetween( |
|
|
|
|
DateUtil.format(MapUtils.getString(map, "createTimeS"), "yyyy-MM-dd HH:mm:ss"), |
|
|
|
|
DateUtil.format(MapUtils.getString(map, "createTimeE"), "yyyy-MM-dd HH:mm:ss")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(MapUtils.getString(map, "refundTimeS")) && StringUtils.isNotBlank(MapUtils.getString(map, "refundTimeE"))) { |
|
|
|
|
criteria.andRefundTimeBetween( |
|
|
|
|
DateUtil.format(MapUtils.getString(map, "refundTimeS"), "yyyy-MM-dd HH:mm:ss"), |
|
|
|
|
DateUtil.format(MapUtils.getString(map, "refundTimeE"), "yyyy-MM-dd HH:mm:ss")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return highOrderMapper.selectByExample(example); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@ -1006,11 +668,6 @@ public class HighOrderServiceImpl implements HighOrderService { |
|
|
|
|
return highOrderMapper.getOrderListByIdCode(map); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<HighOrder> getCloseOrder() { |
|
|
|
|
return highOrderMapperExt.getCloseOrder(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public HighOrder getConsumeOrderByDiscountCode(Long discountCodeId) { |
|
|
|
|
|
|
|
|
@ -1052,65 +709,6 @@ public class HighOrderServiceImpl implements HighOrderService { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(propagation = Propagation.REQUIRES_NEW) |
|
|
|
|
public void cancelOrder(Long orderId) { |
|
|
|
|
HighOrder order = getOrderById(orderId); |
|
|
|
|
if (order != null) { |
|
|
|
|
if (order.getOrderStatus() != 1) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, ""); |
|
|
|
|
} |
|
|
|
|
order.setOrderStatus(5); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
|
|
|
|
|
order.setCancelTime(new Date()); |
|
|
|
|
|
|
|
|
|
for (HighChildOrder highChildOrder : order.getHighChildOrderList()) { |
|
|
|
|
// 商品类型 1:卡卷 2:金币充值
|
|
|
|
|
if (highChildOrder.getGoodsType() == 1) { |
|
|
|
|
// 查询卡卷详情
|
|
|
|
|
HighCouponCode couponCode = highCouponCodeService.getCouponCodeByOrderId(highChildOrder.getId()); |
|
|
|
|
if (couponCode != null) { |
|
|
|
|
couponCode.setChildOrderId(null); |
|
|
|
|
couponCode.setStatus(1); // 状态:1.待销售 2.未使用 3.已使用 99.预支付
|
|
|
|
|
highCouponCodeService.updateCouponCode(couponCode); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (highChildOrder.getGoodsType() == 7) { |
|
|
|
|
HighDiscountPackageActual actual = discountPackageActualService.getDetailByChildOrderNo(highChildOrder.getOrderNo()); |
|
|
|
|
if (actual != null) { |
|
|
|
|
actual.setChildOrderId(null); |
|
|
|
|
actual.setUserId(null); |
|
|
|
|
actual.setStatus(1); |
|
|
|
|
discountPackageActualService.updateHighDiscountPackageActual(actual); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
highChildOrder.setChildOrderStatus(5); // 子订单状态:1 待支付 2 已支付 3.已完成 4. 已退款 5.已取消
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (order.getMemDiscountId() != null) { |
|
|
|
|
HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId()); |
|
|
|
|
if (rel != null) { |
|
|
|
|
rel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
|
|
|
|
|
rel.setUseTime(null); |
|
|
|
|
highDiscountUserRelService.updateDiscountUserRel(rel); |
|
|
|
|
|
|
|
|
|
HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(rel.getDiscountAgentCodeId()); |
|
|
|
|
code.setStatus(2); |
|
|
|
|
highDiscountAgentCodeService.updateCode(code); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (order.getPayGold() != null) { |
|
|
|
|
// 积分返回
|
|
|
|
|
String remark = "订单" + order.getOrderNo() + "取消,退还积分:" + order.getPayGold(); |
|
|
|
|
highUserService.goldHandle(order.getMemId(), order.getPayGold(), 1, 3, order.getId() , remark , order.getOrderNo()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
updateOrder(order); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Long countOrderByUserId(Long memId, Integer status) { |
|
|
|
|
|
|
|
|
@ -1140,37 +738,11 @@ public class HighOrderServiceImpl implements HighOrderService { |
|
|
|
|
return highDiscountUserRelMapper.selectByExample(example).size(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<HighOrder> getAlreadyPaidMobileOrder() { |
|
|
|
|
return highOrderMapperExt.selectAlreadyPaidMobileOrder(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<HighOrder> getAlreadyPaidKfcOrder() { |
|
|
|
|
return highOrderMapperExt.selectAlreadyPaidKfcOrder(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<HighOrder> getAlreadyPaidCinemaOrder() { |
|
|
|
|
return highOrderMapperExt.selectAlreadyPaidCinemaOrder(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<HighOrder> getTest() { |
|
|
|
|
return highOrderMapperExt.selectTest(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<Map<String, Object>> getFinishGasOrder() { |
|
|
|
|
return highOrderMapper.selectFinishGasOrder(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public HighChildOrder getChildOrderByPresentation(Long orderId) { |
|
|
|
|
HighChildOrderExample example = new HighChildOrderExample(); |
|
|
|
|
example.createCriteria().andOrderIdEqualTo(orderId).andGiveawayTypeEqualTo(false); |
|
|
|
|
return highChildOrderMapper.selectByExample(example).get(0); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<HighOrderModel> selectDiscountPackageOrderList(Map<String, Object> map) throws Exception { |
|
|
|
@ -1267,10 +839,6 @@ public class HighOrderServiceImpl implements HighOrderService { |
|
|
|
|
return highOrderMapper.getDateCountByRecharge(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public int getGasTheDayOrderNum(Long userId) { |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public TyOrderCountModel TyOrderStatistics(Map<String, Object> map) throws Exception { |
|
|
|
@ -1888,341 +1456,9 @@ public class HighOrderServiceImpl implements HighOrderService { |
|
|
|
|
return highOrder; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(propagation = Propagation.REQUIRES_NEW) |
|
|
|
|
public void hltUnionCardPayByThirdProduct(HighUserCard userCard, Long orderId) throws Exception { |
|
|
|
|
String goodsDesc = ""; |
|
|
|
|
String tranDesc = ""; |
|
|
|
|
String instCode = "11101527"; |
|
|
|
|
String businessType = "hisen_consume"; |
|
|
|
|
|
|
|
|
|
// 查询订单信息
|
|
|
|
|
HighOrder order = getOrderById(orderId); |
|
|
|
|
if (order == null) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, ""); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (order.getHighChildOrderList().get(0).getGoodsType() == 4) { |
|
|
|
|
goodsDesc = "购买肯德基产品"; |
|
|
|
|
tranDesc = goodsDesc + order.getPayRealPrice() + "元"; |
|
|
|
|
} else if (order.getHighChildOrderList().get(0).getGoodsType() == 9) { |
|
|
|
|
goodsDesc = "购买星巴克产品"; |
|
|
|
|
tranDesc = goodsDesc + order.getPayRealPrice() + "元"; |
|
|
|
|
} else if (order.getHighChildOrderList().get(0).getGoodsType() == 10) { |
|
|
|
|
goodsDesc = "购买会员充值产品"; |
|
|
|
|
tranDesc = goodsDesc + order.getPayRealPrice() + "元"; |
|
|
|
|
} else { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法支付,请使用其他支付方式"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 工会卡支付
|
|
|
|
|
JSONObject consumption = HuiLianTongUnionCardConfig.consumption(order.getOrderNo(), userCard.getCardNo(), order.getPayRealPrice(), businessType, instCode, goodsDesc, tranDesc); |
|
|
|
|
System.out.println("工会卡支付响应参数" + consumption.toJSONString()); |
|
|
|
|
|
|
|
|
|
Map<String, Object> 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.getPayRealPrice()); |
|
|
|
|
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(order.getOrderNo()); |
|
|
|
|
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")) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumptionResult.getString("message")); |
|
|
|
|
} |
|
|
|
|
order.setPaySerialNo(consumptionResult.getString("orderId")); // 支付流水号
|
|
|
|
|
order.setOrderStatus(2); |
|
|
|
|
order.setMemCardNo(userCard.getCardNo()); |
|
|
|
|
order.setPayType(4); |
|
|
|
|
|
|
|
|
|
order.setPayTime(new Date()); // 支付时间
|
|
|
|
|
updateOrder(order); |
|
|
|
|
|
|
|
|
|
HighGasOrderPush orderPush = new HighGasOrderPush(); |
|
|
|
|
JSONObject returnObject; |
|
|
|
|
|
|
|
|
|
for (HighChildOrder childOrder : order.getHighChildOrderList()) { |
|
|
|
|
childOrder.setChildOrderStatus(2); |
|
|
|
|
} |
|
|
|
|
if (order.getHighChildOrderList().get(0).getGoodsType() == 4) { |
|
|
|
|
orderPush.setType(OrderPushType.type4.getType()); |
|
|
|
|
returnObject = QianZhuConfig.payKfcOrder(order.getOrderNo()); |
|
|
|
|
} else if (order.getHighChildOrderList().get(0).getGoodsType() == 9) { |
|
|
|
|
orderPush.setType(OrderPushType.type8.getType()); |
|
|
|
|
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()); |
|
|
|
|
} else { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂时无法支付,请使用其他支付方式"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
orderPush.setOrderNo(order.getOrderNo()); |
|
|
|
|
orderPush.setCreateTime(new Date()); |
|
|
|
|
orderPush.setRequestContent(JSON.toJSONString(dataMap)); |
|
|
|
|
orderPush.setReturnContent(returnObject.toJSONString()); |
|
|
|
|
highGasOrderPushMapper.insert(orderPush); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<HighOrder> getThirdOrder() { |
|
|
|
|
return highOrderMapper.getThirdOrder(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void thirdOrderToRefund(Long orderId) throws Exception { |
|
|
|
|
|
|
|
|
|
HighOrder order = highOrderService.getOrderById(orderId); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
|
|
|
|
|
if (order.getOrderStatus() != 2) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 微信退款
|
|
|
|
|
if (order.getPayType() == 2) { |
|
|
|
|
Map<String, String> param = new HashMap<>(); |
|
|
|
|
param.put("appid", "wx637bd6f7314daa46"); |
|
|
|
|
param.put("mch_id", "1289663601"); |
|
|
|
|
param.put("sub_mch_id", "1614670195"); |
|
|
|
|
param.put("nonce_str", WxUtils.makeNonStr()); |
|
|
|
|
param.put("transaction_id", order.getPaySerialNo()); |
|
|
|
|
param.put("out_refund_no", "HFR" + new Date().getTime()); |
|
|
|
|
param.put("total_fee", String.valueOf(order.getPayRealPrice().multiply(new BigDecimal("100")).intValue())); |
|
|
|
|
param.put("refund_fee", String.valueOf(order.getPayRealPrice().multiply(new BigDecimal("100")).intValue())); |
|
|
|
|
param.put("sign_type", "HMAC-SHA256"); |
|
|
|
|
|
|
|
|
|
String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5", WXPayConstants.SignType.HMACSHA256); |
|
|
|
|
param.put("sign", signStr); |
|
|
|
|
|
|
|
|
|
String resultXmL = doRefundRequest(param.get("mch_id"), WxUtils.mapToXml(param)); |
|
|
|
|
OrderRefundModel orderRefundModel = XmlUtil.getObjectFromXML(resultXmL, OrderRefundModel.class); |
|
|
|
|
if (orderRefundModel.getResult_code().equals("SUCCESS")) { |
|
|
|
|
//order.setRefundTime(new Date());
|
|
|
|
|
// order.setRefundNo(orderRefundModel.getOut_refund_no());
|
|
|
|
|
// order.setRefundPrice(new BigDecimal(orderRefundModel.getRefund_fee()).divide(new BigDecimal("100")));
|
|
|
|
|
order.setOrderStatus(4); |
|
|
|
|
//order.setRefundTime(new Date());
|
|
|
|
|
for (HighChildOrder childOrder : order.getHighChildOrderList()) { |
|
|
|
|
childOrder.setChildOrderStatus(4); |
|
|
|
|
} |
|
|
|
|
updateOrder(order); |
|
|
|
|
} else { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!错误代码:" + orderRefundModel.getErr_code() + ",错误描述" + orderRefundModel.getErr_code_des()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 工会卡退款
|
|
|
|
|
if (order.getPayType() == 4) { |
|
|
|
|
JSONObject jsonObject = HuiLianTongUnionCardConfig.refund("HFR" + new Date().getTime(), order.getOrderNo()); |
|
|
|
|
|
|
|
|
|
if (jsonObject == null) { |
|
|
|
|
jsonObject = HuiLianTongUnionCardConfig.refund("HFR" + new Date().getTime(), order.getOrderNo()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
JSONObject dataObject = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data")); |
|
|
|
|
|
|
|
|
|
if (dataObject.getBoolean("success") || Objects.equals(dataObject.getString("message"), "原交易已撤销,不可再次操作")) { |
|
|
|
|
// order.setRefundTime(new Date());
|
|
|
|
|
// order.setRefundNo("HFR" + new Date().getTime());
|
|
|
|
|
// order.setRefundPrice(order.getPayRealPrice());
|
|
|
|
|
order.setOrderStatus(4); |
|
|
|
|
// order.setRefundTime(new Date());
|
|
|
|
|
for (HighChildOrder childOrder : order.getHighChildOrderList()) { |
|
|
|
|
childOrder.setChildOrderStatus(4); |
|
|
|
|
} |
|
|
|
|
updateOrder(order); |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, dataObject.getString("message")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 商户预充值 帐户退款
|
|
|
|
|
if (order.getPayType() == 7) { |
|
|
|
|
|
|
|
|
|
Map<String , Object> map = new HashMap<>(); |
|
|
|
|
map.put("orderNo" , order.getOrderNo()); |
|
|
|
|
map.put("amountType" , 1); |
|
|
|
|
map.put("sourceType" , 2); |
|
|
|
|
|
|
|
|
|
/* if ( apiAmountRecordService.getApiAmountRecordByList(map).size() == 1) { |
|
|
|
|
|
|
|
|
|
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(order.getMerchId()); |
|
|
|
|
// 插入金额记录
|
|
|
|
|
// 变更前金额
|
|
|
|
|
BigDecimal beforeAmount = apiMerchants.getAmounts(); |
|
|
|
|
// 计算金额
|
|
|
|
|
apiMerchants.setAmounts(apiMerchants.getAmounts().add(order.getPayPrice())); |
|
|
|
|
// 变更后金额
|
|
|
|
|
BigDecimal afterAmount = apiMerchants.getAmounts(); |
|
|
|
|
|
|
|
|
|
apiMerchantsService.updateApiMerchants(apiMerchants); |
|
|
|
|
|
|
|
|
|
ApiAmountRecord apiAmountRecord = new ApiAmountRecord(); |
|
|
|
|
|
|
|
|
|
apiAmountRecord.setCreateTime(new Date()); |
|
|
|
|
apiAmountRecord.setUpdateTime(new Date()); |
|
|
|
|
apiAmountRecord.setMchId(order.getMerchId()); |
|
|
|
|
|
|
|
|
|
apiAmountRecord.setStatus(100); |
|
|
|
|
apiAmountRecord.setAmount(order.getPayPrice()); |
|
|
|
|
apiAmountRecord.setAfterAmount(afterAmount); |
|
|
|
|
apiAmountRecord.setBeforeAmount(beforeAmount); |
|
|
|
|
apiAmountRecord.setAmountType(1); |
|
|
|
|
apiAmountRecord.setSourceType(2); |
|
|
|
|
apiAmountRecord.setSourceOrderNo(order.getOrderNo()); |
|
|
|
|
apiAmountRecord.setSourceId(order.getId()); |
|
|
|
|
apiAmountRecord.setSourceContent(apiMerchants.getMerchantName() + "|订单退款" + order.getPayPrice()); |
|
|
|
|
|
|
|
|
|
apiAmountRecordService.insertAmountRecord(apiAmountRecord); |
|
|
|
|
|
|
|
|
|
Map<String, Object> orderMap = new HashMap<>(); |
|
|
|
|
orderMap.put("orderId" , order.getId()); |
|
|
|
|
|
|
|
|
|
// 查询是否用重复订单
|
|
|
|
|
ApiOrderRecord apiOrderRecord = apiOrderRecordService.queryOrderResult(orderMap); |
|
|
|
|
|
|
|
|
|
apiOrderRecord.setStatus(100); |
|
|
|
|
apiOrderRecord.setRequestTime(new Date()); |
|
|
|
|
apiOrderRecordService.updateOrderRecord(apiOrderRecord); |
|
|
|
|
}*/ |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 银联退款
|
|
|
|
|
if (order.getPayType() == 5) { |
|
|
|
|
// 订单退款
|
|
|
|
|
JSONObject refund = UnionPayConfig.zwrefund(UnionPayConfig.MER_ID2, UnionPayConfig.TERM_ID2, order.getOrderNo(), order.getPaySerialNo(), order.getPayRealPrice().multiply(new BigDecimal("100")).longValue()); |
|
|
|
|
if (!refund.getString("resultcode").equals("W6")) { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refund.getString("returnmsg")); |
|
|
|
|
} |
|
|
|
|
//order.setRefundTime(new Date());
|
|
|
|
|
//order.setRefundNo(refund.getString("oriwtorderid"));
|
|
|
|
|
//order.setRefundPrice(order.getPayRealPrice());
|
|
|
|
|
order.setOrderStatus(4); |
|
|
|
|
// order.setRefundTime(new Date());
|
|
|
|
|
for (HighChildOrder childOrder : order.getHighChildOrderList()) { |
|
|
|
|
childOrder.setChildOrderStatus(4); |
|
|
|
|
} |
|
|
|
|
updateOrder(order); |
|
|
|
|
} |
|
|
|
|
// 退还积分
|
|
|
|
|
if (order.getPayGold() != null) { |
|
|
|
|
String remark = "订单" + order.getOrderNo() + "退款,退还积分:" + order.getPayGold(); |
|
|
|
|
highUserService.goldHandle(order.getMemId(), order.getPayGold(), 1, 3, order.getId() , remark , order.getOrderNo()); |
|
|
|
|
if (order.getPayRealPrice().compareTo(new BigDecimal(0)) == 0) { |
|
|
|
|
order.setOrderStatus(4); |
|
|
|
|
//order.setRefundTime(new Date());
|
|
|
|
|
for (HighChildOrder childOrder : order.getHighChildOrderList()) { |
|
|
|
|
childOrder.setChildOrderStatus(4); |
|
|
|
|
} |
|
|
|
|
updateOrder(order); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (order.getMemDiscountId() != null) { |
|
|
|
|
HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId()); |
|
|
|
|
if (rel != null) { |
|
|
|
|
rel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
|
|
|
|
|
rel.setUseTime(null); |
|
|
|
|
highDiscountUserRelService.updateDiscountUserRel(rel); |
|
|
|
|
|
|
|
|
|
HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(rel.getDiscountAgentCodeId()); |
|
|
|
|
code.setStatus(2); |
|
|
|
|
highDiscountAgentCodeService.updateCode(code); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String doRefundRequest(String mchId, String data) throws Exception { |
|
|
|
|
|
|
|
|
|
//小程序退款需要调用双向证书的认证
|
|
|
|
|
CloseableHttpClient httpClient = goodsOrderService.readCertificate(mchId); |
|
|
|
|
try { |
|
|
|
|
HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/refund"); // 设置响应头信息
|
|
|
|
|
httpost.addHeader("Connection", "keep-alive"); |
|
|
|
|
httpost.addHeader("Accept", "*/*"); |
|
|
|
|
httpost.addHeader("Content-Type", "text/xml"); |
|
|
|
|
httpost.addHeader("Host", "api.mch.weixin.qq.com"); |
|
|
|
|
httpost.addHeader("X-Requested-With", "XMLHttpRequest"); |
|
|
|
|
httpost.addHeader("Cache-Control", "max-age=0"); |
|
|
|
|
httpost.addHeader("User-Agent", "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0) "); |
|
|
|
|
httpost.setEntity(new StringEntity(data, "UTF-8")); |
|
|
|
|
CloseableHttpResponse response = httpClient.execute(httpost); |
|
|
|
|
try { |
|
|
|
|
HttpEntity entity = response.getEntity(); |
|
|
|
|
String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8"); |
|
|
|
|
EntityUtils.consume(entity); |
|
|
|
|
return jsonStr; |
|
|
|
|
} finally { |
|
|
|
|
response.close(); |
|
|
|
|
} |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
throw new RuntimeException(e); |
|
|
|
|
} finally { |
|
|
|
|
httpClient.close(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
@Transactional(propagation = Propagation.REQUIRES_NEW) |
|
|
|
|
public void thirdCancelOrder(Long orderId) { |
|
|
|
|
HighOrder order = getOrderById(orderId); |
|
|
|
|
if (order != null && order.getOrderStatus() == 1) { |
|
|
|
|
order.setOrderStatus(5); |
|
|
|
|
order.setCancelTime(new Date()); |
|
|
|
|
|
|
|
|
|
for (HighChildOrder childOrder : order.getHighChildOrderList()) { |
|
|
|
|
childOrder.setChildOrderStatus(5); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (order.getMemDiscountId() != null) { |
|
|
|
|
HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId()); |
|
|
|
|
if (rel != null) { |
|
|
|
|
rel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
|
|
|
|
|
rel.setUseTime(null); |
|
|
|
|
highDiscountUserRelService.updateDiscountUserRel(rel); |
|
|
|
|
|
|
|
|
|
HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(rel.getDiscountAgentCodeId()); |
|
|
|
|
code.setStatus(2); |
|
|
|
|
highDiscountAgentCodeService.updateCode(code); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (order.getPayGold() != null) { |
|
|
|
|
// 积分返回
|
|
|
|
|
String remark = "订单" + order.getOrderNo() + "取消,退还积分:" + order.getPayGold(); |
|
|
|
|
highUserService.goldHandle(order.getMemId(), order.getPayGold(), 1, 3, order.getId() , remark , order.getOrderNo()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
updateOrder(order); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Long whetherCheck(Long memId, Integer status) { |
|
|
|
|
|
|
|
|
@ -2234,23 +1470,6 @@ public class HighOrderServiceImpl implements HighOrderService { |
|
|
|
|
return highOrderMapper.countByExample(example); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void orderCheck(Long orderId) { |
|
|
|
|
HighOrder highOrder = highOrderMapper.selectByPrimaryKey(orderId); |
|
|
|
|
|
|
|
|
|
highOrder.setWhetherCheck(true); |
|
|
|
|
|
|
|
|
|
if (highOrder.getOrderStatus() == 3) { |
|
|
|
|
highOrderMapper.updateByPrimaryKey(highOrder); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<SelfOilStationModel> getSelfOilStationOrderList(String goodsId) { |
|
|
|
|
return highOrderMapper.getSelfOilStationOrderList(goodsId); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<HighOrder> integralRebateOrder() { |
|
|
|
|
HighOrderExample example = new HighOrderExample(); |
|
|
|
@ -2259,64 +1478,6 @@ public class HighOrderServiceImpl implements HighOrderService { |
|
|
|
|
return highOrderMapper.selectByExample(example); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// todo 废弃代码
|
|
|
|
|
@Override |
|
|
|
|
public JSONObject orderSource(Integer goodsType, Long goodsId , String orderNo , Long companyId , Integer productId) { |
|
|
|
|
|
|
|
|
|
JSONObject object = new JSONObject(); |
|
|
|
|
|
|
|
|
|
if (goodsType == 1) { |
|
|
|
|
HighCoupon coupon = highCouponService.getCouponById(goodsId); |
|
|
|
|
|
|
|
|
|
object.put("type" , 1); |
|
|
|
|
object.put("productId", 1); |
|
|
|
|
object.put("companyId", coupon.getCompanyId()); |
|
|
|
|
object.put("remark" , "卡券订单:"+ coupon.getCouponName() + "-" + orderNo + "积分返利:"); |
|
|
|
|
object.put("name" , "购买卡券产品:"+ coupon.getCouponName()); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
if (goodsType == 3) { |
|
|
|
|
HighMerchantStore merchantStore = highMerchantStoreService.getMerchantStoreById(goodsId); |
|
|
|
|
object.put("type" , 2); |
|
|
|
|
object.put("productId", 1); |
|
|
|
|
object.put("companyId", merchantStore.getCompanyId()); |
|
|
|
|
object.put("remark" , "在线加油订单" + orderNo + "积分返利:"); |
|
|
|
|
object.put("name" , "购买在线加油产品"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (goodsType == 4) { |
|
|
|
|
object.put("type" , 4); |
|
|
|
|
object.put("productId", 2); |
|
|
|
|
object.put("companyId", companyId); |
|
|
|
|
object.put("remark" , "肯德基订单" + orderNo + "积分返利:"); |
|
|
|
|
object.put("name" , "购买肯德基产品"); |
|
|
|
|
} |
|
|
|
|
if (goodsType == 9) { |
|
|
|
|
object.put("type" , 4); |
|
|
|
|
object.put("productId", 1); |
|
|
|
|
object.put("companyId", companyId); |
|
|
|
|
object.put("remark" , "星巴克订单" + orderNo + "积分返利:"); |
|
|
|
|
object.put("name" , "购买星巴克产品"); |
|
|
|
|
} |
|
|
|
|
if (goodsType == 10) { |
|
|
|
|
object.put("type" , 4); |
|
|
|
|
object.put("productId", 3); |
|
|
|
|
object.put("companyId", companyId); |
|
|
|
|
object.put("remark" , "会员充值订单" + orderNo + "积分返利:"); |
|
|
|
|
object.put("name" , "购买会员充值产品"); |
|
|
|
|
} |
|
|
|
|
if (goodsType == 20) { |
|
|
|
|
object.put("type" , 3); |
|
|
|
|
object.put("productId", productId); |
|
|
|
|
object.put("companyId", companyId); |
|
|
|
|
object.put("remark" , "话费充值订单" + orderNo + "积分返利:"); |
|
|
|
|
object.put("name" , "购买话费充值产品"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// object.put("logoImg" , OrderLogoEnum.getNameByImgUrl(goodsType));
|
|
|
|
|
return object; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<HighOrder> promoteOrderList(String identificationCode) throws Exception { |
|
|
|
|
|
|
|
|
@ -2335,36 +1496,5 @@ public class HighOrderServiceImpl implements HighOrderService { |
|
|
|
|
return list; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<HighOrder> orderListByAgentId(Map<String, Object> map) throws Exception { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void phoneBillOrderMigration(HighOrder highOrder) { |
|
|
|
|
highOrderMapper.insert(highOrder); |
|
|
|
|
HighChildOrder highChildOrder = new HighChildOrder(); |
|
|
|
|
|
|
|
|
|
highChildOrder.setOrderNo(highOrder.getOrderNo()); |
|
|
|
|
highChildOrder.setChildOrderNo(OrderUtil.generateChildOrderNo()); |
|
|
|
|
highChildOrder.setChildOrderStatus(highOrder.getOrderStatus()); |
|
|
|
|
highChildOrder.setTotalPrice(highOrder.getTotalPrice()); |
|
|
|
|
highChildOrder.setGoodsPrice(highOrder.getTotalPrice()); |
|
|
|
|
highChildOrder.setGoodsActualPrice(highOrder.getPayPrice()); |
|
|
|
|
highChildOrder.setGoodsName(highOrder.getTitle()); |
|
|
|
|
highChildOrder.setGoodsType(6); |
|
|
|
|
highChildOrder.setSaleCount(1); |
|
|
|
|
highChildOrder.setGiveawayType(false); |
|
|
|
|
highChildOrder.setMemId(highOrder.getMemId()); |
|
|
|
|
highChildOrder.setTotalDeductionPrice(highOrder.getTotalDeductionPrice()); |
|
|
|
|
highChildOrder.setGoodsSpecName("话费充值"); |
|
|
|
|
highChildOrder.setCreateTime(highOrder.getCreateTime()); |
|
|
|
|
highChildOrder.setOrderId(highOrder.getId()); |
|
|
|
|
highChildOrder.setCancelTime(highOrder.getCancelTime()); |
|
|
|
|
highChildOrder.setFinishTime(highOrder.getFinishTime()); |
|
|
|
|
highChildOrder.setRefundTime(highOrder.getRefundTime()); |
|
|
|
|
highChildOrder.setPayTime(highOrder.getPayTime()); |
|
|
|
|
highChildOrderMapper.insert(highChildOrder); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|