优化话费定时任务代码

dev-discount
袁野 2 years ago
parent 55d1949115
commit 249e59b74b
  1. 4
      hai-bweb/src/main/java/com/bweb/controller/CommonController.java
  2. 2
      hai-bweb/src/main/java/com/bweb/controller/HighTestController.java
  3. 4
      hai-bweb/src/main/resources/dev/config.properties
  4. 39
      hai-cweb/src/main/java/com/cweb/controller/CommonController.java
  5. 32
      hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java
  6. 2
      hai-order/src/main/java/com/web/controller/business/OrderMobileRechargeController.java
  7. 56
      hai-schedule/src/main/java/com/hai/schedule/HighRechargeOrderSchedule.java
  8. 22
      hai-schedule/src/main/resources/prod/application.yml
  9. 2
      hai-service/src/main/java/com/hai/config/MessageConfig.java
  10. 85
      hai-service/src/main/java/com/hai/config/RechargeConfig.java
  11. 86
      hai-service/src/main/java/com/hai/order/model/ExportOrderMobileModel.java
  12. 4
      hai-service/src/main/java/com/hai/order/service/impl/OrderPaySuccessServiceImpl.java
  13. 2
      hai-service/src/main/java/com/hai/order/type/RechargePlatformType.java
  14. 7
      hai-service/src/main/java/com/hai/service/HighOrderService.java
  15. 61
      hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java
  16. 43
      hai-service/src/main/java/com/hai/service/impl/HighOrderServiceImpl.java
  17. 12
      hai-service/src/main/java/com/hai/service/impl/OutRechargeChildOrderServiceImpl.java
  18. 686
      hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java
  19. 98
      hai-service/src/main/java/com/hai/service/pay/impl/RechargeOrderServiceImpl.java
  20. 34
      v1/src/main/java/com/v1/controller/WxMsgController.java
  21. 68
      v1/src/main/java/com/v1/controller/orderController.java

@ -374,10 +374,8 @@ public class CommonController {
@RequestParam(name = "lat", required = true) String lat @RequestParam(name = "lat", required = true) String lat
) { ) {
try { try {
System.out.println("请求经度==================" + lng);
System.out.println("请求纬度==================" + lat);
JSONObject object = commonService.findByLatAndLng(lng , lat); JSONObject object = commonService.findByLatAndLng(lng , lat);
System.out.println("请求经纬度========" + object);
return ResponseMsgUtil.success(object); return ResponseMsgUtil.success(object);
} catch (Exception e) { } catch (Exception e) {

File diff suppressed because one or more lines are too long

@ -1,5 +1,5 @@
fileUrl=/home/project/hsg/filesystem #fileUrl=/home/project/hsg/filesystem
#fileUrl=/Volumes/work/code/filesystem/ fileUrl=/Volumes/work/code/filesystem/
cmsPath=/home/project/hsg/filesystem/cmsPath cmsPath=/home/project/hsg/filesystem/cmsPath
agentQrCode=/home/project/hsg/filesystem/agentQrCode agentQrCode=/home/project/hsg/filesystem/agentQrCode
agentQrCodeWxUrl=https://hsgcs.dctpay.com/wx/?action=ic&id= agentQrCodeWxUrl=https://hsgcs.dctpay.com/wx/?action=ic&id=

@ -251,45 +251,6 @@ public class CommonController {
} }
} }
@RequestMapping(value = "/getScanCodePageHtmlSign", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "获取扫码页面签名")
public ResponseData getScanCodePageHtmlSign(@RequestBody JSONObject body) {
try {
if (body == null || StringUtils.isBlank(body.getString("url"))) {
log.error("getH5UserInfo error!", "参数校验失败" );
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
Map<String, Object> params = new HashMap<>();
params.put("appid", SysConst.getSysConfig().getWxH5AppId());
params.put("secret", SysConst.getSysConfig().getWxH5AppSecret());
params.put("grant_type", "client_credential");
params.clear();
params.put("access_token", weChatQrcodeUtils.getWxToken());
params.put("type", "jsapi");
JSONObject jsapiTicketObject = HttpsUtils.doGet("https://api.weixin.qq.com/cgi-bin/ticket/getticket", params);
if (jsapiTicketObject == null) {
log.error("getH5UserInfo error!", "获取微信jsapi_ticket失败" );
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "获取微信jsapi_ticket失败");
}
params = new HashMap<>();
params.put("noncestr", WxUtils.makeNonStr());
params.put("jsapi_ticket", jsapiTicketObject.getString("ticket"));
params.put("timestamp", System.currentTimeMillis() / 1000);
params.put("url", body.getString("url"));
String signatureStr = WxUtils.generateSignature(params);
System.out.println(signatureStr);
params.put("signature", SHA1.gen(signatureStr));
return ResponseMsgUtil.success(params);
} catch (Exception e) {
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/findByLatAndLng", method = RequestMethod.GET) @RequestMapping(value = "/findByLatAndLng", method = RequestMethod.GET)
@ResponseBody @ResponseBody

@ -41,38 +41,6 @@ public class OutRechargeOrderController {
@Resource @Resource
private OutRechargePriceService outRechargePriceService; private OutRechargePriceService outRechargePriceService;
@RequestMapping(value = "/addOrder", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "增加订单")
public ResponseData addOrder(@RequestBody JSONObject object, HttpServletRequest request) {
try {
// 用户
SessionObject sessionObject = userCenter.getSessionObject(request);
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
if (StringUtils.isBlank(object.getString("rechargeContent")) ||
object.getLong("goodsId") == null
) {
log.error("addOrder error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
object.put("mchId", request.getHeader("mchId"));
object.put("userId", userInfoModel.getHighUser().getId());
return ResponseMsgUtil.success(outRechargeOrderService.insertOrder(object));
} catch (Exception e) {
log.error("HighOrderController -> addOrder() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/getOrderById", method = RequestMethod.GET) @RequestMapping(value = "/getOrderById", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "根据id查询订单详情") @ApiOperation(value = "根据id查询订单详情")

@ -195,7 +195,7 @@ public class OrderMobileRechargeController {
dataList.add(model); dataList.add(model);
} }
String fileUrl = SysConst.getSysConfig().getFileUrl() + "temp orary/"; String fileUrl = SysConst.getSysConfig().getFileUrl() + "temporary/";
String pathName = System.currentTimeMillis()+".xlsx"; String pathName = System.currentTimeMillis()+".xlsx";
File file = new File(fileUrl); File file = new File(fileUrl);
if (!file.exists()) { if (!file.exists()) {

@ -1,5 +1,6 @@
package com.hai.schedule; package com.hai.schedule;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hai.common.utils.DateUtil; import com.hai.common.utils.DateUtil;
@ -12,6 +13,7 @@ import com.hai.entity.OutRechargeOrder;
import com.hai.order.service.OrderService; import com.hai.order.service.OrderService;
import com.hai.service.OutRechargeChildOrderService; import com.hai.service.OutRechargeChildOrderService;
import com.hai.service.OutRechargeOrderService; import com.hai.service.OutRechargeOrderService;
import com.hai.service.impl.OutRechargeOrderServiceImpl;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
@ -34,7 +36,7 @@ import java.util.Map;
@Configuration @Configuration
public class HighRechargeOrderSchedule { public class HighRechargeOrderSchedule {
Logger log = LoggerFactory.getLogger(HighRechargeOrderSchedule.class); private static final Logger log = LoggerFactory.getLogger(OutRechargeOrderServiceImpl.class);
@Resource @Resource
private OutRechargeOrderService outRechargeOrderService; private OutRechargeOrderService outRechargeOrderService;
@ -53,64 +55,24 @@ public class HighRechargeOrderSchedule {
* @Date 14:18 2022/5/31 * @Date 14:18 2022/5/31
* @Param [] * @Param []
*/ */
@Scheduled(cron = "0 0/7 * * * ?") //每7分钟执行一次 @Scheduled(cron = "0 0/1 * * * ?") //每5分钟执行一次
public void initRechargeOrder() { public void initRechargeOrder() {
log.info("处理话费订单定时任务开始");
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("payStatus", String.valueOf(102)); map.put("payStatus", String.valueOf(102));
map.put("rechargeStatus", String.valueOf(205)); map.put("rechargeStatus", String.valueOf(201));
List<OutRechargeOrder> orderList = outRechargeOrderService.getListRechargeOrder(map); List<OutRechargeOrder> orderList = outRechargeOrderService.getListRechargeOrder(map);
log.info("处理话费订单条数:" + orderList.size());
if (orderList.size() > 0) { if (orderList.size() > 0) {
for (OutRechargeOrder order : orderList) { for (OutRechargeOrder order : orderList) {
try { try {
outRechargeOrderService.prepaidRechargeHandle(order);
// 定义小时数
Date rechargeTime = order.getCreateTimed();
Date currentTime = new Date();
int hours = (int) ((currentTime.getTime() - rechargeTime.getTime()) / (1000 * 60 * 60));
// 查询当前订单是否超时 如果超过72小时则处理退款
if (hours < 72) {
outRechargeOrderService.pollRequest(order);
} else {
// 话费订单处理
outRechargeOrderService.rechargeOrderHandle(order.getOrderNo());
}
} catch (Exception e) { } catch (Exception e) {
log.error("HighCouponSchedule --> expiredCoupon() error!", e); log.info("话费定时任务订单业务出现异常", e);
} }
} }
} }
System.out.println("话费定时任务 -> 结束任务");
} }
@Scheduled(cron = "0 0/5 * * * ?") //每7分钟执行一次
public void phoneErrorOrder() {
List<HighOrder> highOrders = orderService.phoneErrorOrder();
for (HighOrder order: highOrders) {
try {
// 定义话费充值业务订单模型 or 充值记录订单模型
OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(order.getOrderNo());
OutRechargeChildOrder childOrder = outRechargeOrder.getOutRechargeChildOrders().get(0);
// -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功
Integer status = outRechargeOrderService.getRechargeOrderLegality(outRechargeOrder , childOrder);
if (status == 2 || status == -1) {
childOrder.setStatus(103);
childOrder.setUpdateTime(new Date());
rechargeChildOrderService.updateOrder(childOrder);
outRechargeOrder.setRechargeStatus(205);
outRechargeOrderService.updateOrder(outRechargeOrder);
} else if (status == 1) {
outRechargeOrderService.completeOrder(childOrder.getOrderNo());
}
} catch (Exception e) {
log.error("HighCouponSchedule --> expiredCoupon() error!", e);
}
}
System.out.println("话费定时任务 -> 结束任务");
}
} }

@ -79,6 +79,28 @@ mybatis:
type-aliases-package: type-aliases-package:
org.springboot.sample.entity org.springboot.sample.entity
jetcache:
statIntervalMinutes: 15
areaInCacheName: false
local:
default:
type: linkedhashmap
keyConvertor: fastjson
remote:
default:
type: redis
host: 127.0.0.1
port: 36379
password: HF123456.Redis
keyConvertor: fastjson
broadcastChannel: projectA
valueEncoder: java
valueDecoder: java
poolConfig:
minIdle: 5
maxIdle: 20
maxTotal: 50
pagehelper: pagehelper:
helperDialect: mysql helperDialect: mysql
reasonable: true reasonable: true

@ -199,8 +199,6 @@ public class MessageConfig {
public static Map<String, Object> buildRequestBody(String msisdn, String smsTemplateId, public static Map<String, Object> buildRequestBody(String msisdn, String smsTemplateId,
Map<String, String> paramValues, String accout, String passward) { Map<String, String> paramValues, String accout, String passward) {
if (null == msisdn || null == smsTemplateId || null == accout || null == passward) { if (null == msisdn || null == smsTemplateId || null == accout || null == passward) {
System.out.println(
"buildRequestBody(): mobiles, templateId or templateParas or account or password is null.");
return null; return null;
} }

@ -7,11 +7,15 @@ import com.hai.common.utils.DateUtil;
import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.HttpsUtils;
import com.hai.common.utils.WxUtils; import com.hai.common.utils.WxUtils;
import com.hai.entity.OutRechargeChildOrder;
import com.hai.entity.OutRechargeOrder;
import com.hai.service.OutRechargeChildOrderService;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.*; import java.util.*;
/** /**
@ -26,6 +30,7 @@ public class RechargeConfig {
private static Logger log = LoggerFactory.getLogger(RechargeConfig.class); private static Logger log = LoggerFactory.getLogger(RechargeConfig.class);
/** /**
* @Author Sum1Dream * @Author Sum1Dream
* @name getProductsList.java * @name getProductsList.java
@ -62,13 +67,12 @@ public class RechargeConfig {
paramMap.put("userid" , CommonSysConst.getSysConfig().getLyMemberId()); paramMap.put("userid" , CommonSysConst.getSysConfig().getLyMemberId());
paramMap.put("sign", WxUtils.generateSignatureLy(paramMap , CommonSysConst.getSysConfig().getLyApiKey() , WXPayConstants.SignType.MD5)); paramMap.put("sign", WxUtils.generateSignatureLy(paramMap , CommonSysConst.getSysConfig().getLyApiKey() , WXPayConstants.SignType.MD5));
log.info("============请求任务Start============="); log.info("发起龙阅订单充值=");
log.info("龙阅订单充值-请求参数: " + JSON.toJSONString(paramMap)); log.info("龙阅订单充值-请求参数: " + JSON.toJSONString(paramMap));
JSONObject jsonObject = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLyPostUrl()+ "index/recharge", paramMap); JSONObject jsonObject = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLyPostUrl()+ "index/recharge", paramMap);
log.info("龙阅订单充值-响应参数: " + jsonObject.toJSONString()); log.info("龙阅订单充值-响应参数: " + jsonObject.toJSONString());
log.info("============请求任务End==============");
return jsonObject; return jsonObject;
} }
@ -90,13 +94,12 @@ public class RechargeConfig {
paramMap.put("out_trade_nums" , object.getString("out_trade_nums")); paramMap.put("out_trade_nums" , object.getString("out_trade_nums"));
paramMap.put("sign", WxUtils.generateSignatureLy(paramMap , CommonSysConst.getSysConfig().getLyApiKey() , WXPayConstants.SignType.MD5)); paramMap.put("sign", WxUtils.generateSignatureLy(paramMap , CommonSysConst.getSysConfig().getLyApiKey() , WXPayConstants.SignType.MD5));
log.info("============请求任务Start============="); log.info("发起龙阅订单查询=");
log.info("龙阅订单查询-请求参数: " + JSON.toJSONString(paramMap)); log.info("龙阅订单查询-请求参数: " + JSON.toJSONString(paramMap));
JSONObject jsonObject = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLyPostUrl()+ "index/check", paramMap); JSONObject jsonObject = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLyPostUrl()+ "index/check", paramMap);
log.info("龙阅订单查询-响应参数: " + jsonObject.toJSONString()); log.info("龙阅订单查询-响应参数: " + jsonObject.toJSONString());
log.info("============请求任务End==============");
return jsonObject; return jsonObject;
} }
@ -123,42 +126,16 @@ public class RechargeConfig {
String signStr = WxUtils.generateSignatureAppSecret(map, CommonSysConst.getSysConfig().getJjAppSecret() , WXPayConstants.SignType.MD5); String signStr = WxUtils.generateSignatureAppSecret(map, CommonSysConst.getSysConfig().getJjAppSecret() , WXPayConstants.SignType.MD5);
map.put("sign" , signStr); map.put("sign" , signStr);
log.info("============请求任务Start============="); log.info("发起尖椒充值");
log.info("尖椒订单充值-请求参数: " + JSON.toJSONString(map)); log.info("尖椒订单充值-请求参数: " + JSON.toJSONString(map));
JSONObject jsonObject = HttpsUtils.doPost(CommonSysConst.getSysConfig().getJjUrl() + "createOrder" , map); JSONObject jsonObject = HttpsUtils.doPost(CommonSysConst.getSysConfig().getJjUrl() + "createOrder" , map);
log.info("尖椒订单充值-响应参数: " + jsonObject.toJSONString()); log.info("尖椒订单充值-响应参数: " + jsonObject.toJSONString());
log.info("============请求任务End==============");
return jsonObject; return jsonObject;
} }
/**
* @Author Sum1Dream
* @name checkOrderByJj.java
* @Description // 尖椒查询订单详情
* @Date 09:57 2022/5/25
* @Param [com.alibaba.fastjson.JSONObject]
* @return com.alibaba.fastjson.JSONObject
*/
public static JSONObject checkOrderByJj(JSONObject object) throws Exception {
String timestamp = String.valueOf(System.currentTimeMillis());
Map<String , Object> map = new HashMap<>();
map.put("out_order_id" , object.getString("out_order_id"));
map.put("app_key" , CommonSysConst.getSysConfig().getJjAppKey());
map.put("timestamp" , timestamp.substring(0,timestamp.length()-3));
map.put("notify_url" , CommonSysConst.getSysConfig().getLyNotifyUrl());
String signStr = WxUtils.generateSignatureAppSecret(map, CommonSysConst.getSysConfig().getJjAppSecret() , WXPayConstants.SignType.MD5);
map.put("sign" , signStr);
return HttpsUtils.doPost(CommonSysConst.getSysConfig().getJjUrl() + "queryOrder" , map);
}
/** /**
* @Author Sum1Dream * @Author Sum1Dream
@ -179,37 +156,16 @@ public class RechargeConfig {
paramMap.put("appid" , CommonSysConst.getSysConfig().getCyApiKey()); paramMap.put("appid" , CommonSysConst.getSysConfig().getCyApiKey());
paramMap.put("sign", WxUtils.generateSignatureCy(paramMap , CommonSysConst.getSysConfig().getCyAppSecret() , WXPayConstants.SignType.MD5)); paramMap.put("sign", WxUtils.generateSignatureCy(paramMap , CommonSysConst.getSysConfig().getCyAppSecret() , WXPayConstants.SignType.MD5));
log.info("============请求任务Start============="); log.info("发起城宇话费下单=");
log.info("城宇话费下单-请求参数: " + JSON.toJSONString(paramMap)); log.info("城宇话费下单-请求参数: " + JSON.toJSONString(paramMap));
JSONObject jsonObject = HttpsUtils.doPostByCy(CommonSysConst.getSysConfig().getCyPostUrl()+ "/api/interface/recharge", paramMap); JSONObject jsonObject = HttpsUtils.doPostByCy(CommonSysConst.getSysConfig().getCyPostUrl()+ "/api/interface/recharge", paramMap);
log.info("城宇话费下单-响应参数: " + jsonObject.toJSONString()); log.info("城宇话费下单-响应参数: " + jsonObject.toJSONString());
log.info("============请求任务End==============");
return jsonObject; return jsonObject;
} }
/**
* @Author Sum1Dream
* @name rechargeOrderByCy.java
* @Description // 城宇话费查询订单详情
* @Date 10:22 2022/7/14
* @Param [com.alibaba.fastjson.JSONObject]
* @return com.alibaba.fastjson.JSONObject
*/
public static JSONObject queryRechargeByCy(JSONObject object) throws Exception {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("orderId" , object.getString("orderNo"));
paramMap.put("timestamp" , DateUtil.date2String(new Date() , DateUtil.Y_M_D_HMS));
paramMap.put("appid" , CommonSysConst.getSysConfig().getCyApiKey());
paramMap.put("sign", WxUtils.generateSignatureCy(paramMap , CommonSysConst.getSysConfig().getCyAppSecret() , WXPayConstants.SignType.MD5));
return HttpsUtils.doPostByCy(CommonSysConst.getSysConfig().getCyPostUrl()+ "/api/interface/queryRecharge", paramMap);
}
/** /**
* @Author Sum1Dream * @Author Sum1Dream
@ -230,14 +186,13 @@ public class RechargeConfig {
paramMap.put("notify" , CommonSysConst.getSysConfig().getHgNotifyUrl()); paramMap.put("notify" , CommonSysConst.getSysConfig().getHgNotifyUrl());
paramMap.put("sign", WxUtils.generateSignatureHg(paramMap , CommonSysConst.getSysConfig().getHgApiKey() , WXPayConstants.SignType.MD5)); paramMap.put("sign", WxUtils.generateSignatureHg(paramMap , CommonSysConst.getSysConfig().getHgApiKey() , WXPayConstants.SignType.MD5));
log.info("============请求任务Start============="); log.info("发起畅停话费查询订单=");
log.info("畅停话费查询订单-请求参数: " + JSON.toJSONString(paramMap)); log.info("畅停话费查询订单-请求参数: " + JSON.toJSONString(paramMap));
System.out.println("畅停话费查询订单-请求参数: " + JSON.toJSONString(paramMap)); System.out.println("畅停话费查询订单-请求参数: " + JSON.toJSONString(paramMap));
JSONObject repsObject = HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getHgPostUrl()+ "external/api/telPay", paramSort(paramMap), new HashMap<>()); JSONObject repsObject = HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getHgPostUrl()+ "external/api/telPay", paramSort(paramMap), new HashMap<>());
log.info("畅停话费查询订单-响应参数: " + repsObject.toJSONString()); log.info("畅停话费查询订单-响应参数: " + repsObject.toJSONString());
log.info("============请求任务End==============");
return repsObject; return repsObject;
} }
@ -256,29 +211,12 @@ public class RechargeConfig {
paramMap.put("orderid" , object.getString("orderid")); paramMap.put("orderid" , object.getString("orderid"));
paramMap.put("sign", WxUtils.generateSignatureHg(paramMap , CommonSysConst.getSysConfig().getHgApiKey() , WXPayConstants.SignType.MD5)); paramMap.put("sign", WxUtils.generateSignatureHg(paramMap , CommonSysConst.getSysConfig().getHgApiKey() , WXPayConstants.SignType.MD5));
log.info("============请求任务Start============="); log.info("发起畅停话费查询订单=");
log.info("畅停话费查询订单-请求参数: " + JSON.toJSONString(paramMap)); log.info("畅停话费查询订单-请求参数: " + JSON.toJSONString(paramMap));
JSONObject jsonObject = HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getHgPostUrl()+ "external/api/searchOrder", paramSort(paramMap) , new HashMap<>()); JSONObject jsonObject = HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getHgPostUrl()+ "external/api/searchOrder", paramSort(paramMap) , new HashMap<>());
log.info("畅停话费查询订单-响应参数: " + jsonObject.toJSONString()); log.info("畅停话费查询订单-响应参数: " + jsonObject.toJSONString());
log.info("============请求任务End==============");
return jsonObject;
}
public static JSONObject searchProduct() throws Exception {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("mchid" , CommonSysConst.getSysConfig().getHgMemberId());
paramMap.put("sign", WxUtils.generateSignatureHg(paramMap , CommonSysConst.getSysConfig().getHgApiKey() , WXPayConstants.SignType.MD5));
log.info("============请求任务Start=============");
log.info("畅停话费查询订单-请求参数: " + JSON.toJSONString(paramMap));
JSONObject jsonObject = HttpsUtils.doPostForm(CommonSysConst.getSysConfig().getHgPostUrl()+ "/external/api/searchProduct", paramSort(paramMap) , new HashMap<>());
log.info("畅停话费查询订单-响应参数: " + jsonObject.toJSONString());
log.info("============请求任务End==============");
return jsonObject; return jsonObject;
} }
@ -298,4 +236,5 @@ public class RechargeConfig {
} }
} }

@ -0,0 +1,86 @@
package com.hai.order.model;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
/**
* 订单退款模型
* @className: ExportGasOrderModel
* @author: 袁野
* @date: 2022/10/28
**/
@Data
public class ExportOrderMobileModel {
@ColumnWidth(25)
@ExcelProperty("标题")
private String title;
@ColumnWidth(15)
@ExcelProperty("客户电话")
private String memPhone;
@ColumnWidth(25)
@ExcelProperty("交易单号")
private String orderNo;
@ColumnWidth(25)
@ExcelProperty("充值订单号")
private String rechargeOrderNo;
@ColumnWidth(25)
@ExcelProperty("充值子订单号")
private String childOrderNo;
@ColumnWidth(15)
@ExcelProperty("充值平台")
private String rechargePlatform;
@ColumnWidth(13)
@ExcelProperty(value = "支付方式")
private String payType;
@ColumnWidth(22)
@ExcelProperty(value = "卡号")
private String memCardNo;
@ColumnWidth(13)
@ExcelProperty(value = "应付金额")
private BigDecimal payablePrice;
@ColumnWidth(13)
@ExcelProperty(value = "实付金额")
private BigDecimal payPrice;
@ColumnWidth(15)
@ExcelProperty("订单状态")
private String orderStatus;
@ColumnWidth(15)
@ExcelProperty("创建时间")
private Date createTime;
@ColumnWidth(15)
@ExcelProperty("支付时间")
private Date payTime;
@ColumnWidth(15)
@ExcelProperty("完成时间")
private Date finishTime;
@ColumnWidth(15)
@ExcelProperty("退款时间")
private Date refundTime;
@ColumnWidth(15)
@ExcelProperty("备注")
private String remark;
}

@ -489,10 +489,10 @@ public class OrderPaySuccessServiceImpl implements OrderPaySuccessService {
OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(order.getOrderNo()); OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(order.getOrderNo());
if (outRechargeOrder.getPayStatus() == null) { if (outRechargeOrder.getPayStatus() == null) {
if (order.getProductType().equals(9)) { if (order.getProductType().equals(9)) {
outRechargeOrderService.editOutRechargeOrder(order); outRechargeOrderService.editOutRechargeOrder(order , outRechargeOrder);
} }
} }
outRechargeOrderService.pollRequest(outRechargeOrder); outRechargeOrderService.getPrepaidRechargeApi(outRechargeOrder);
} }
} }

@ -9,10 +9,12 @@ import java.util.Objects;
* @date: 2022/8/24 * @date: 2022/8/24
**/ **/
public enum RechargePlatformType { public enum RechargePlatformType {
STATUS0(0, "未知"),
STATUS1(1, "尖椒"), STATUS1(1, "尖椒"),
STATUS2(2, "龙阅"), STATUS2(2, "龙阅"),
STATUS3(3, "城宇"), STATUS3(3, "城宇"),
STATUS4(4, "畅停"), STATUS4(4, "畅停"),
STATUS100(100, "手动"),
; ;
private Integer number; private Integer number;

@ -133,6 +133,13 @@ public interface HighOrderService {
**/ **/
List<HighOrder> getOrderList(Map<String,Object> map); List<HighOrder> getOrderList(Map<String,Object> map);
/**
* @Author 胡锐
* @Description 查询订单列表
* @Date 2021/3/26 23:06
**/
List<HighOrder> getOrderListNotChild(Map<String,Object> map);
/** /**
* 查询订单列表 * 查询订单列表
* @param map * @param map

@ -24,10 +24,6 @@ public interface OutRechargeOrderService {
**/ **/
List<OutRechargeOrder> getListRechargeOrder(Map<String , Object> map); List<OutRechargeOrder> getListRechargeOrder(Map<String , Object> map);
List<OutRechargeOrder> selectList();
/** /**
* @Author Sum1Dream * @Author Sum1Dream
* @Description // 根据订单ID查询订单 * @Description // 根据订单ID查询订单
@ -46,14 +42,15 @@ public interface OutRechargeOrderService {
**/ **/
OutRechargeOrder findByOrderNo(String orderNo); OutRechargeOrder findByOrderNo(String orderNo);
/*** todo 当前接口已经废弃 /**
* @Author Sum1Dream * @Author Sum1Dream
* @Description // 新增订单 * @Description // 根据订单号查询订单
* @Date 15:25 2021/6/11 * @Date 15:20 2021/6/11
* @Param [outRechargeOrder] * @Param [orderNo]
* @return void * @return com.hai.entity.OutRechargeOrder
**/ **/
OutRechargeOrder insertOrder(JSONObject object) throws Exception; OutRechargeOrder findByOrderNoNotChild(String orderNo);
/*** /***
* @Author Sum1Dream * @Author Sum1Dream
@ -136,17 +133,29 @@ public interface OutRechargeOrderService {
* @Param [orderId] * @Param [orderId]
* @Return void * @Return void
*/ */
void refundOrder(Long orderId , OutRechargeChildOrder childOrder) throws Exception; void refundOrder(Long orderId) throws Exception;
/** /**
* @Author Sum1Dream * @Author Sum1Dream
* @name pollRequest.java * @Name getPrepaidRechargeApi
* @Description // 充值轮询 * @Description // 请求上游话费充值接口
* @Date 16:32 2022/5/25 * @Date 14:25 2023/3/28
* @Param [com.hai.entity.OutRechargeOrder] * @Param [rechargeOrder]
* @return void * @Return void
*/ */
void pollRequest(OutRechargeOrder outRechargeOrder) throws Exception; void getPrepaidRechargeApi(OutRechargeOrder outRechargeOrder) throws Exception;
/**
* @Author Sum1Dream
* @Name prepaidRechargeHandle
* @Description // 处理订单应用
* @Date 18:44 2023/3/28
* @Param [outRechargeOrder]
* @Return void
*/
void prepaidRechargeHandle(OutRechargeOrder outRechargeOrder) throws Exception;
/** /**
* @Author Sum1Dream * @Author Sum1Dream
@ -178,17 +187,7 @@ public interface OutRechargeOrderService {
* @Param [order, outRechargeOrder] * @Param [order, outRechargeOrder]
* @Return void * @Return void
*/ */
void editOutRechargeOrder(HighOrder order); void editOutRechargeOrder(HighOrder order , OutRechargeOrder outRechargeOrder);
/**
* @Author Sum1Dream
* @Name refundLegality
* @Description // 话费订单处理
* @Date 14:45 2023/2/15
* @Param [outRechargeOrder, childOrder]
* @Return void
*/
void rechargeOrderHandle(String orderNo) throws Exception;
/** /**
* @Author Sum1Dream * @Author Sum1Dream
@ -198,6 +197,6 @@ public interface OutRechargeOrderService {
* @Param [object] * @Param [object]
* @Return void * @Return void
*/ */
Integer getRechargeOrderLegality(OutRechargeOrder outRechargeOrder , OutRechargeChildOrder childOrder) throws Exception; Integer getRechargeOrderLegality(OutRechargeChildOrder childOrder) throws Exception;
} }

@ -829,6 +829,49 @@ public class HighOrderServiceImpl implements HighOrderService {
return list; 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"));
}
// example.setOrderByClause("create_time desc");
return highOrderMapper.selectByExample(example);
}
@Override @Override
public List<HighOrderModel> getGoodsOrderModelList(Map<String, Object> map) throws Exception { public List<HighOrderModel> getGoodsOrderModelList(Map<String, Object> map) throws Exception {

@ -31,8 +31,14 @@ public class OutRechargeChildOrderServiceImpl implements OutRechargeChildOrderSe
if (MapUtils.getLong(map , "parent_order_id") != null) { if (MapUtils.getLong(map , "parent_order_id") != null) {
criteria.andParentOrderIdEqualTo(MapUtils.getLong(map , "parent_order_id")); criteria.andParentOrderIdEqualTo(MapUtils.getLong(map , "parent_order_id"));
} }
if (MapUtils.getInteger(map , "status") != null) { if (MapUtils.getString(map , "status") != null) {
criteria.andStatusEqualTo(MapUtils.getInteger(map , "status"));
String[] statusArray = MapUtils.getString(map, "status").split(",");
List<Integer> list = new ArrayList<>();
for (String status : statusArray) {
list.add(Integer.parseInt(status));
}
criteria.andStatusIn(list);
} }
example.setOrderByClause("create_time desc"); example.setOrderByClause("create_time desc");
@ -77,7 +83,7 @@ public class OutRechargeChildOrderServiceImpl implements OutRechargeChildOrderSe
OutRechargeChildOrderExample.Criteria criteria = example.createCriteria(); OutRechargeChildOrderExample.Criteria criteria = example.createCriteria();
criteria.andParentOrderIdEqualTo(orderId); criteria.andParentOrderIdEqualTo(orderId);
example.setOrderByClause("create_time desc");
List<OutRechargeChildOrder> list = rechargeChildOrderMapper.selectByExample(example); List<OutRechargeChildOrder> list = rechargeChildOrderMapper.selectByExample(example);
if (list.size() > 0 ) { if (list.size() > 0 ) {

@ -20,6 +20,7 @@ import com.hai.order.service.OrderService;
import com.hai.order.type.OrderChildStatus; import com.hai.order.type.OrderChildStatus;
import com.hai.order.type.OrderPayType; import com.hai.order.type.OrderPayType;
import com.hai.order.type.OrderRefundOpUserType; import com.hai.order.type.OrderRefundOpUserType;
import com.hai.order.utils.OrderUtil;
import com.hai.service.*; import com.hai.service.*;
import com.hai.service.pay.impl.GoodsOrderServiceImpl; import com.hai.service.pay.impl.GoodsOrderServiceImpl;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
@ -53,9 +54,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
@Resource @Resource
private OrderService orderService; private OrderService orderService;
@Resource
private HighGasOrderPushMapper highGasOrderPushMapper;
@Resource @Resource
private HighUserService highUserService; private HighUserService highUserService;
@ -65,12 +63,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
@Resource @Resource
private OutRechargePriceService outRechargePriceService; private OutRechargePriceService outRechargePriceService;
@Resource
private GoodsOrderServiceImpl goodsOrderService;
@Resource
private BsIntegralRebateService bsIntegralRebateService;
@Resource @Resource
private HighDiscountUserRelService highDiscountUserRelService; private HighDiscountUserRelService highDiscountUserRelService;
@ -80,26 +72,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
@Resource @Resource
private OutRechargeChildOrderService outRechargeChildOrderService; private OutRechargeChildOrderService outRechargeChildOrderService;
@Resource
private BsRequestRecordService bsRequestRecordService;
@Resource
private BsConfigService bsConfigService;
@Resource
private SecConfigService secConfigService;
@Resource
private HighUserPayPasswordService highUserPayPasswordService;
@Resource
private ApiMerchantsService apiMerchantsService;
@Resource
private ApiAmountRecordService apiAmountRecordService;
@Resource
private ApiOrderRecordService apiOrderRecordService;
@Resource @Resource
private BsRechargeCodeService rechargeCodeService; private BsRechargeCodeService rechargeCodeService;
@ -177,11 +149,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
return outRechargeOrderMapper.selectByExample(example); return outRechargeOrderMapper.selectByExample(example);
} }
@Override
public List<OutRechargeOrder> selectList() {
return outRechargeOrderMapper.selectList();
}
@Override @Override
public OutRechargeOrder findByOrderId(Long orderId) { public OutRechargeOrder findByOrderId(Long orderId) {
return outRechargeOrderMapper.selectByPrimaryKey(orderId); return outRechargeOrderMapper.selectByPrimaryKey(orderId);
@ -207,203 +174,19 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
return outRechargeOrder; return outRechargeOrder;
} }
// todo 接口已经废弃
@Override @Override
@Transactional( public OutRechargeOrder findByOrderNoNotChild(String orderNo) {
isolation = Isolation.SERIALIZABLE,
propagation = Propagation.REQUIRES_NEW)
public OutRechargeOrder insertOrder(JSONObject object) throws Exception {
OutRechargeOrder outRechargeOrder = new OutRechargeOrder();
HighUser user = highUserService.findByUserId(object.getLong("userId"));
// 产品id OutRechargeOrderExample example = new OutRechargeOrderExample();
Long goodsId = object.getLong("goodsId"); example.createCriteria().andOrderNoEqualTo(orderNo);
// 充值内容
String rechargeContent = object.getString("rechargeContent");
// 查询产品详情
OutRechargePriceModel outRechargePrice = outRechargePriceService.findById(goodsId, null);
Map<String, Object> listMap = new HashMap<>();
listMap.put("productType", "3");
listMap.put("returnType", 1);
listMap.put("sourceId", goodsId);
// 查询产品积分抵扣比例
BsProductDiscount bsProductDiscount = bsConfigService.getProductDiscountByMap(listMap);
// 判断充值系统是否关闭
if (!secConfigService.isConfig("RECHARGE", "1")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.RECHARGE_CLOSE, "");
}
HighDiscountUserRel highDiscountUserRel = null;
// 判断是否有优惠券
if (object.getLong("memDiscountId") != null) {
outRechargeOrder.setMemDiscountId(object.getLong("memDiscountId"));
// 卡优惠券信息
highDiscountUserRel = highDiscountUserRelService.getRelById(object.getLong("memDiscountId"));
if (highDiscountUserRel == null || highDiscountUserRel.getStatus() != 1) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券状态错误");
}
if (!highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type1.getType())
&& !highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type3.getType())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法使用此优惠券");
}
} else {
outRechargeOrder.setPayRealPrice(outRechargePrice.getPayPrice());
}
// 优惠券抵扣
if (highDiscountUserRel != null) {
outRechargeOrder.setMemDiscountName(highDiscountUserRel.getHighDiscount().getDiscountName());
BigDecimal payPrice = new BigDecimal(0);
// 卡卷类型 1:满减 2:抵扣 3:折扣
if (highDiscountUserRel.getHighDiscount().getDiscountType() == 1) {
// 如果商品支付总额 小于 满减价格
if (outRechargePrice.getRechargePrice().compareTo(highDiscountUserRel.getHighDiscount().getDiscountCondition()) < 0) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "订单未达到" + highDiscountUserRel.getHighDiscount().getDiscountCondition() + "元,无法使用此优惠券");
}
// 计算支付金额 = 商品充值总额 - 满减额度
payPrice = outRechargePrice.getRechargePrice().subtract(highDiscountUserRel.getHighDiscount().getDiscountPrice());
outRechargeOrder.setDiscountDeductionPrice(highDiscountUserRel.getHighDiscount().getDiscountPrice());
}
// 卡卷类型 1:满减 2:抵扣 3:折扣
if (highDiscountUserRel.getHighDiscount().getDiscountType() == 2) {
// 计算支付金额 = 商品充值总额 - 满减额度
payPrice = outRechargePrice.getRechargePrice().subtract(highDiscountUserRel.getHighDiscount().getDiscountPrice());
outRechargeOrder.setDiscountDeductionPrice(highDiscountUserRel.getHighDiscount().getDiscountPrice());
}
// 卡卷类型 1:满减 2:抵扣 3:折扣
if (highDiscountUserRel.getHighDiscount().getDiscountType() == 3) {
BigDecimal discountPrice = highDiscountUserRel.getHighDiscount().getDiscountPrice();
// 订单总额 * 折扣
payPrice = outRechargePrice.getRechargePrice().multiply(discountPrice);
outRechargeOrder.setDiscountDeductionPrice(outRechargePrice.getRechargePrice().subtract(payPrice));
outRechargeOrder.setPayRealPrice(payPrice);
}
// 如果总额小于0
if (payPrice.compareTo(new BigDecimal("0")) < 0) {
outRechargeOrder.setPayRealPrice(new BigDecimal("0"));
} else {
outRechargeOrder.setPayRealPrice(payPrice);
}
}
// 判断积分数量是否大于0
if (object.getLong("integralNum") > 0 && bsProductDiscount.getDiscount().compareTo(new BigDecimal("0")) > 0) {
// 判断用户积分是否够
if (object.getLong("integralNum") > user.getGold()) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "用户积分不足");
}
// 积分抵扣金额
BigDecimal integralDeductionPrice = object.getBigDecimal("integralNum").divide(new BigDecimal(100).setScale(2, RoundingMode.HALF_UP));
// 最高可抵扣金额
BigDecimal maxIntegralDeductionPrice = outRechargeOrder.getPayRealPrice().multiply(bsProductDiscount.getDiscount()).divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP);
// 判读积分是否大于限制额度
if (maxIntegralDeductionPrice.compareTo(integralDeductionPrice) < 0) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单最大抵扣积分金额:" + maxIntegralDeductionPrice);
}
// 判断积分抵扣比例是否为100% 并且积分数量是否可以抵扣最后的支付金额
if (bsProductDiscount.getDiscount().compareTo(new BigDecimal(100)) == 0 && integralDeductionPrice.compareTo(outRechargeOrder.getPayRealPrice()) == 0) {
// 查询用户支付密码
HighUserPayPassword userPayPassword = highUserPayPasswordService.getDetailByUser(object.getLong("userId"));
if (userPayPassword == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_SET_USER_PAY_PWD, "");
}
if (StringUtils.isBlank(object.getString("password"))) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_ENTER_USER_PAY_PWD, "");
}
// 校验支付密码
if (!AESEncodeUtil.aesEncrypt(object.getString("password")).equals(userPayPassword.getPassword())) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.USER_PAY_PWD_ERROR, "");
}
}
outRechargeOrder.setIntegralDeductionPrice(integralDeductionPrice);
outRechargeOrder.setPayRealPrice(outRechargeOrder.getPayRealPrice().subtract(outRechargeOrder.getIntegralDeductionPrice()));
}
outRechargeOrder.setUserId(user.getId());
outRechargeOrder.setIntegralNum(object.getBigDecimal("integralNum"));
outRechargeOrder.setRechargeContent(rechargeContent);
outRechargeOrder.setCompanyId(outRechargePrice.getCompanyId());
outRechargeOrder.setUserName(user.getName());
outRechargeOrder.setRechargeType(outRechargePrice.getRechargeType());
outRechargeOrder.setUserPhone(user.getPhone());
outRechargeOrder.setOrderNo("RCG" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5));
outRechargeOrder.setCreateTimed(new Date());
outRechargeOrder.setGoodsId(goodsId);
outRechargeOrder.setWhetherRebate(false);
outRechargeOrder.setMerchId(object.getString("mchId"));
outRechargeOrder.setRechargePrice(outRechargePrice.getRechargePrice());
if (object.getLong("memDiscountId") != null) {
outRechargeOrder.setPayPrice(outRechargePrice.getRechargePrice());
} else {
outRechargeOrder.setPayPrice(outRechargePrice.getPayPrice());
}
outRechargeOrder.setType(1);
outRechargeOrder.setOrderPrice(outRechargePrice.getRechargePrice());
outRechargeOrder.setOperatorName(OperatorEnum.getNameByType(outRechargePrice.getOperatorType()));
outRechargeOrder.setOperatorType(outRechargePrice.getOperatorType());
// 判断积分支付是否扣完金额
if (outRechargeOrder.getPayRealPrice().compareTo(new BigDecimal(0)) == 0) {
// 201:充值中 202:充值成功 203:充值失败 204:未充值
outRechargeOrder.setRechargeStatus(204);
// 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
outRechargeOrder.setPayStatus(102);
outRechargeOrder.setPayTime(new Date());
outRechargeOrder.setPaySerialNo("22" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5));
} else {
// 201:充值中 202:充值成功 203:充值失败 204:未充值
outRechargeOrder.setRechargeStatus(204);
// 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
outRechargeOrder.setPayStatus(101);
}
// 使用优惠券
if (outRechargeOrder.getMemDiscountId() != null) {
HighDiscountUserRel discountUserRel = highDiscountUserRelService.getRelById(outRechargeOrder.getMemDiscountId());
discountUserRel.setUseTime(new Date()); // 使用时间
discountUserRel.setStatus(2); //状态 0:已过期 1:未使用 2:已使用
highDiscountUserRelService.updateDiscountUserRel(discountUserRel);
HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(discountUserRel.getDiscountAgentCodeId());
code.setStatus(3);
highDiscountAgentCodeService.updateCode(code);
}
outRechargeOrderMapper.insert(outRechargeOrder);
if (outRechargeOrder.getIntegralNum() != null) { List<OutRechargeOrder> list = outRechargeOrderMapper.selectByExample(example);
String remark = "话费订单" + outRechargeOrder.getOrderNo() + "下单,使用积分:" + object.getInteger("integralNum");
highUserService.goldHandle(outRechargeOrder.getUserId(), outRechargeOrder.getIntegralNum().intValue(), 2, 2, outRechargeOrder.getId() , remark);
}
if (outRechargeOrder.getPayStatus() == 102) { if (list.size() == 0) {
pollRequest(outRechargeOrder); return null;
} }
return outRechargeOrder; return list.get(0);
} }
@Override @Override
@ -574,9 +357,11 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
isolation = Isolation.READ_COMMITTED, isolation = Isolation.READ_COMMITTED,
timeout = 25, timeout = 25,
rollbackFor = Exception.class) rollbackFor = Exception.class)
public void refundOrder(Long orderId , OutRechargeChildOrder childOrder) throws Exception { public void refundOrder(Long orderId) throws Exception {
OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderId(orderId); OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderId(orderId);
log.info("发起话费订单退款" + outRechargeOrder.getOrderNo() + "");
// 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款 // 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
if (outRechargeOrder.getPayStatus() != 102) { if (outRechargeOrder.getPayStatus() != 102) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态");
@ -584,7 +369,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
// 充值状态:201:充值中 202:充值成功 203:充值失败 204:未充值 // 充值状态:201:充值中 202:充值成功 203:充值失败 204:未充值
if (outRechargeOrder.getRechargeStatus() == 202) { if (outRechargeOrder.getRechargeStatus() == 202) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单已充值成功无法退款z"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单已充值成功无法退款");
} }
// 订单处理 // 订单处理
@ -599,192 +384,104 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
outRechargeOrder.setRefundTime(new Date()); outRechargeOrder.setRefundTime(new Date());
outRechargeOrderService.updateOrder(outRechargeOrder); outRechargeOrderService.updateOrder(outRechargeOrder);
// 充值订单记录修改状态
childOrder.setStatus(103);
outRechargeChildOrderService.updateOrder(childOrder);
} }
@Override @Override
public void pollRequest(OutRechargeOrder outRechargeOrder) throws Exception { public void getPrepaidRechargeApi(OutRechargeOrder outRechargeOrder) throws Exception {
// 查询充值产品 JSONObject object = new JSONObject();
OutRechargePriceModel outRechargePrice = outRechargePriceService.findById(outRechargeOrder.getGoodsId(), null); object.put("rechargePrice" , outRechargeOrder.getRechargePrice());
object.put("rechargeMobile" , outRechargeOrder.getRechargeContent());
object.put("productId" , outRechargeOrder.getGoodsId());
object.put("parentOrderId" , outRechargeOrder.getId());
// 判断参数是否为空
if (
object.getBigDecimal("rechargePrice") == null ||
object.getString("rechargeMobile") == null ||
object.getInteger("productId") == null ||
object.getLong("parentOrderId") == null
) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 定义子订单对象
OutRechargeChildOrder childOrder = new OutRechargeChildOrder();
// 查询是否存在充值中的订单 // 补充下单参数
// 定义子订单请求map object = prepaidRechargeOrderHandle(object);
Map<String, Object> childOrderMap102 = new HashMap<>();
// 组装查询子订单数据 // 补充子订单参数
childOrderMap102.put("parent_order_id", outRechargeOrder.getId()); childOrder.setParentOrderId(object.getLong("parentOrderId"));
childOrderMap102.put("status", 102); childOrder.setRechargePlatform(object.getInteger("rechargePlatform"));
// 查询子订单 childOrder.setStatus(102);
List<OutRechargeChildOrder> childOrderList102 = outRechargeChildOrderService.getListRechargeChildOrder(childOrderMap102); childOrder.setOrderNo("CZ" + OrderUtil.generateOrderNo());
childOrder.setUpdateTime(new Date());
childOrder.setCreateTime(new Date());
if (childOrderList102.size() > 0) { // 尖椒充值
return; if (object.getInteger("rechargePlatform") == 1) {
object.put("out_order_id", childOrder.getOrderNo());
object.put("amount", object.getBigDecimal("rechargePrice"));
object.put("mobile", object.getString("rechargeMobile"));
object.put("notifyUrl", CommonSysConst.getSysConfig().getJjNotifyUrl());
JSONObject returnObject = RechargeConfig.rechargeOrderByJj(object);
childOrder.setExt1(returnObject.toJSONString());
} }
// 查询充值子订单列表 // 龙阅
// 定义子订单请求map if (object.getInteger("rechargePlatform") == 2) {
Map<String, Object> childOrderMap = new HashMap<>();
// 组装查询子订单数据
childOrderMap.put("parent_order_id", outRechargeOrder.getId());
// 查询子订单
List<OutRechargeChildOrder> childOrderList = outRechargeChildOrderService.getListRechargeChildOrder(childOrderMap);
// 定义新的子订单对象
OutRechargeChildOrder childOrder = new OutRechargeChildOrder();
// 初始化充值平台 1:尖椒 2:龙阅 3:城宇 4.畅停 if (object.getString("code") == null) {
int platformType = 0; throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
// 判断子订单是否存在充值中订单
if (childOrderList.size() > 0) {
// 修改之前的自订单充值记录
childOrder = childOrderList.get(0);
// -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功 99 未配置平台查询方法
Integer status = getRechargeOrderLegality(outRechargeOrder , childOrder);
if (status == 0 || status == 3 || status == 99) {
return;
} else if (status == 1) {
completeOrder(childOrder.getOrderNo());
} }
// 修改充值记录状态 object.put("out_trade_num", childOrder.getOrderNo());
childOrder.setStatus(103); object.put("product_id", object.getString("code"));
childOrder.setUpdateTime(new Date()); object.put("mobile", object.getString("rechargeMobile"));
outRechargeChildOrderService.updateOrder(childOrder); object.put("notifyUrl", CommonSysConst.getSysConfig().getLyNotifyUrl());
JSONObject returnObject = RechargeConfig.rechargeOrderByLy(object);
childOrder.setExt1(returnObject.toJSONString());
} }
// 获取充值平台 // 畅停充值
platformType = getRechargePlatformType(); if (object.getInteger("rechargePlatform") == 4) {
// 定义下单请求数据对象 if (object.getString("code") == null) {
JSONObject object = new JSONObject(); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
// 定义新充值订单号
String orderNo = "CZ" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5);
// 查询平台
String string = outRechargePrice.getRechargePlatform().substring(1,outRechargePrice.getRechargePlatform().length()-1);
String[] rechargePlatform = string.split("-");
// 判断平台只定义一个那么类型就是唯一
if (string.length() == 1) {
platformType = Integer.parseInt(string);
} else {
// 如果平台充值记录暂无 则充值第一个
if (platformType == 0) {
platformType = Integer.parseInt(rechargePlatform[0]);
} else {
// 获取上一条充值平台的下一个平台内容
platformType = Integer.parseInt(rechargePlatform[ArrayUtils.arrayIndex(rechargePlatform , String.valueOf(platformType))]);
} }
object.put("orderid", childOrder.getOrderNo());
object.put("product_id", object.getString("code"));
object.put("phone", object.getString("rechargeMobile"));
object.put("price", object.getBigDecimal("rechargePrice"));
JSONObject returnObject = RechargeConfig.rechargeOrderByHg(object);
childOrder.setExt1(returnObject.toJSONString());
} }
// 定义查询充值产品编码
Map<String, Object> map = new HashMap<>();
map.put("type" , 1);
for (String s : rechargePlatform) {
// 尖椒充值
if (s.equals("1") && platformType == 1) {
object.put("out_order_id", orderNo);
object.put("amount", outRechargePrice.getRechargePrice());
object.put("mobile", outRechargeOrder.getRechargeContent());
object.put("notifyUrl", CommonSysConst.getSysConfig().getJjNotifyUrl());
JSONObject returnObject = RechargeConfig.rechargeOrderByJj(object);
object.put("return_content", returnObject);
if (returnObject.getLong("code") == 200) {
childOrder.setStatus(102);
} else {
childOrder.setStatus(103);
}
childOrder.setRechargePlatform(1);
break;
}
// 龙阅充值
if (s.equals("2") && platformType == 2) {
map.put("sourceId" , outRechargePrice.getId());
map.put("rechargePlatform" , platformType);
BsRechargeCode rechargeCode = rechargeCodeService.findByMap(map);
object.put("out_trade_num", orderNo);
object.put("product_id", rechargeCode.getGoodsId());
object.put("mobile", outRechargeOrder.getRechargeContent());
object.put("notifyUrl", CommonSysConst.getSysConfig().getLyNotifyUrl());
JSONObject returnObject = RechargeConfig.rechargeOrderByLy(object);
object.put("return_content", returnObject);
if (returnObject.getLong("errno") == 0) {
childOrder.setStatus(102);
} else {
childOrder.setStatus(103);
}
childOrder.setRechargePlatform(2);
break;
}
// 城宇充值
if (s.equals("3") && platformType == 3) {
map.put("sourceId" , outRechargePrice.getId());
map.put("rechargePlatform" , platformType);
BsRechargeCode rechargeCode = rechargeCodeService.findByMap(map);
object.put("agentOrderId", orderNo);
object.put("productId", rechargeCode.getGoodsId());
object.put("mobile", outRechargeOrder.getRechargeContent());
JSONObject returnObject = RechargeConfig.rechargeOrderByCy(object);
object.put("return_content", returnObject);
if (returnObject.getBoolean("success")) {
childOrder.setStatus(102);
} else {
childOrder.setStatus(103);
}
childOrder.setRechargePlatform(3);
break;
}
// 畅停充值
if (s.equals("4") && platformType == 4) {
map.put("sourceId" , outRechargePrice.getId());
map.put("rechargePlatform" , platformType);
BsRechargeCode rechargeCode = rechargeCodeService.findByMap(map);
object.put("orderid", orderNo);
object.put("product_id", rechargeCode.getGoodsId());
object.put("phone", outRechargeOrder.getRechargeContent());
object.put("price", outRechargeOrder.getRechargePrice());
JSONObject returnObject = RechargeConfig.rechargeOrderByHg(object);
object.put("return_content", returnObject);
if (returnObject.getLong("code") != null && returnObject.getLong("code") == 200) {
childOrder.setStatus(102);
} else {
childOrder.setStatus(103);
}
childOrder.setRechargePlatform(4);
break;
}
}
childOrder.setOrderNo(orderNo);
childOrder.setCreateTime(new Date());
childOrder.setParentOrderId(outRechargeOrder.getId());
childOrder.setUpdateTime(new Date());
outRechargeChildOrderService.insertOrder(childOrder); outRechargeChildOrderService.insertOrder(childOrder);
}
// 判断是否充值提交成功 @Override
if (childOrder.getStatus() == 102) { public void prepaidRechargeHandle(OutRechargeOrder outRechargeOrder) throws Exception {
outRechargeOrder.setRechargeStatus(201);
outRechargeOrder.setPayStatus(102); // 判断订单是否可以继续充值 1:满足继续充值条件 2:订单满足退款条件 3:订单不可以退款不可以继续充值 4:订单异常 5:订单充值完成
} int orderStatus = orderWhetherRecharge(outRechargeOrder);
if (childOrder.getStatus() == 103) { if (orderStatus == 1) {
outRechargeOrder.setRechargeStatus(205); getPrepaidRechargeApi(outRechargeOrder);
outRechargeOrder.setPayStatus(102); }
if (orderStatus == 2) {
refundOrder(outRechargeOrder.getId());
}
if (orderStatus == 4) {
HighOrder highOrder = highOrderService.getOrderByOrderNo(outRechargeOrder.getOrderNo());
highOrder.setExceptionStatus(true);
highOrder.setExceptionContent("话费订单存在多条重复记录");
highOrderService.updateOrder(highOrder);
}
if (orderStatus == 5) {
completeOrder(outRechargeOrder.getOrderNo());
} }
outRechargeOrderService.updateOrder(outRechargeOrder);
} }
@Override @Override
@ -831,8 +528,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
@Override @Override
public void editOutRechargeOrder(HighOrder orderData) { public void editOutRechargeOrder(HighOrder orderData , OutRechargeOrder outRechargeOrder) {
OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(orderData.getOrderNo());
// 201:充值中 202:充值成功 203:充值失败 204:未充值 // 201:充值中 202:充值成功 203:充值失败 204:未充值
outRechargeOrder.setRechargeStatus(201); outRechargeOrder.setRechargeStatus(201);
@ -855,43 +551,8 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
} }
@Override @Override
public void rechargeOrderHandle(String orderNo) throws Exception { public Integer getRechargeOrderLegality(OutRechargeChildOrder childOrder) throws Exception {
// 定义话费充值业务订单模型 or 充值记录订单模型
OutRechargeOrder outRechargeOrder = findByOrderNo(orderNo);
OutRechargeChildOrder childOrder = outRechargeOrder.getOutRechargeChildOrders().get(0);
// 状态需要支付状态为已充值 并且 充值状态不为 充值成功
if (outRechargeOrder.getPayStatus() == 102 && outRechargeOrder.getRechargeStatus() != 202) {
// 判断充值记录是否存在
if (outRechargeOrder.getOutRechargeChildOrders().size() == 0) {
//
OutRechargeChildOrder outRechargeChildOrder = new OutRechargeChildOrder();
outRechargeChildOrder.setOrderNo("CZ" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5));
outRechargeChildOrder.setParentOrderId(outRechargeOrder.getId());
outRechargeChildOrder.setUpdateTime(new Date());
outRechargeChildOrder.setCreateTime(new Date());
outRechargeChildOrderService.insertOrder(outRechargeChildOrder);
// 话费退款
refundOrder(outRechargeOrder.getId() , outRechargeChildOrder);
} else {
// -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功
Integer status = getRechargeOrderLegality(outRechargeOrder , childOrder);
if (status == 2 || status == -1) {
refundOrder(outRechargeOrder.getId() , childOrder);
} else if (status == 1) {
completeOrder(childOrder.getOrderNo());
}
}
}
}
@Override
public Integer getRechargeOrderLegality(OutRechargeOrder outRechargeOrder, OutRechargeChildOrder childOrder) throws Exception {
JSONObject object = new JSONObject(); JSONObject object = new JSONObject();
// 龙阅 // 龙阅
if (childOrder.getRechargePlatform() == 2) { if (childOrder.getRechargePlatform() == 2) {
@ -953,12 +614,175 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
return 99; return 99;
} }
// 获取当前最新的充值平台
private Integer getRechargePlatformType() { private Integer getRechargePlatformType() {
OutRechargeChildOrder outRechargeChildOrder = outRechargeChildOrderService.findOutRechargeChildOrderByDesc(); OutRechargeChildOrder outRechargeChildOrder = outRechargeChildOrderService.findOutRechargeChildOrderByDesc();
if (outRechargeChildOrder != null) { if (outRechargeChildOrder != null) {
return outRechargeChildOrder.getRechargePlatform(); return outRechargeChildOrder.getRechargePlatform();
} }
return 0; return null;
}
/**
* @Author Sum1Dream
* @Name prepaidRechargeOrderHandle
* @Description // 充值订单下单数据操作
* @Date 18:54 2023/3/28
* @Param [object]
* @Return com.alibaba.fastjson.JSONObject
*/
private JSONObject prepaidRechargeOrderHandle(JSONObject object) {
if (object.getLong("productId") == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "产品编码为空");
}
// 查询充值产品
OutRechargePrice outRechargePrice = outRechargePriceService.findByGoodsId(object.getLong("productId"));
if (outRechargePrice == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未知产品编码");
}
// 初始化充值平台 1:尖椒 2:龙阅 3:城宇 4.畅停
Integer platformType = getRechargePlatformType();
// 截取可平台字符串
String rechargePlatformString = outRechargePrice.getRechargePlatform().substring(1,outRechargePrice.getRechargePlatform().length()-1);
String[] rechargePlatform = rechargePlatformString.split("-");
if (rechargePlatform.length == 1) {
platformType = Integer.parseInt(rechargePlatformString);
}
if (rechargePlatform.length > 1) {
// 如果平台充值记录暂无 则充值第一个
if (platformType == null) {
platformType = Integer.parseInt(rechargePlatform[0]);
} else {
// 获取上一条充值平台的下一个平台内容
platformType = Integer.parseInt(rechargePlatform[ArrayUtils.arrayIndex(rechargePlatform , String.valueOf(platformType))]);
}
}
Map<String , Object> rechargeCodeMap = new HashMap<>();
rechargeCodeMap.put("sourceId" , outRechargePrice.getId());
rechargeCodeMap.put("rechargePlatform" , platformType);
BsRechargeCode rechargeCode = rechargeCodeService.findByMap(rechargeCodeMap);
object.put("code" , rechargeCode.getGoodsId());
object.put("rechargePlatform" , platformType);
return object;
}
/**
* @Author Sum1Dream
* @Name orderWhetherRecharge
* @Description // 订单是否可以充值
* @Date 16:11 2023/3/28
* @Param [childOrder]
* @Return java.lang.Integer 1满足继续充值条件 2订单满足退款条件 3订单不可以退款不可以继续充值 4:订单异常 5:订单充值完成
*/
private Integer orderWhetherRecharge(OutRechargeOrder rechargeOrder) throws Exception {
// 查询子订单
List<OutRechargeChildOrder> childOrderList = outRechargeChildOrderService.getListRechargeChildOrderByOrderId(rechargeOrder.getId());
// 充值订单充值时间
Date rechargeTime = rechargeOrder.getCreateTimed();
Date currentTime = new Date();
int hours = (int) ((currentTime.getTime() - rechargeTime.getTime()) / (1000 * 60 * 60));
// 判断订单是否存在充值完成订单
Map<String , Object> childMap = new HashMap<>();
childMap.put("parent_order_id", rechargeOrder.getId());
childMap.put("status", 101);
List<OutRechargeChildOrder> childOrders101 = outRechargeChildOrderService.getListRechargeChildOrder(childMap);
// 判断充值成功是否存在多个 存在返回异常
if (childOrders101.size() > 1) {
return 4;
}
// 判断是否存在充值成功的订单
if (childOrders101.size() == 1) {
return 5;
}
// 查询充值中的订单
childMap.put("status", 102);
List<OutRechargeChildOrder> childOrders102 = outRechargeChildOrderService.getListRechargeChildOrder(childMap);
// 充值中的订单存在多个 返回异常
if (childOrders102.size() > 1) {
return 4;
}
// 只存在一个充值中的订单需要查询当前充值中的订单状态
if (childOrders102.size() == 1) {
// -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功
Integer status = getRechargeOrderLegality(childOrders102.get(0));
if (status == 2 || status == -1) {
// 修改充值订单状态
rechargeChildOrderHandle(childOrders102.get(0) , 103);
// 如果订单记录超过5条退款 反之继续充值
if (childOrderList.size() > 4) {
return 2;
} else {
// 如果订单记录超过71小时 反之继续充值
return hours > 71 ? 2 : 1;
}
}
// 充值订单为充值成功
if (status == 1) {
// 修改充值订单状态
rechargeChildOrderHandle(childOrders102.get(0) , 101);
return 5;
}
}
// 没有充值中的订单 查询所有订单中最新的一条订单状态
if (childOrders102.size() == 0) {
// -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功
Integer status = getRechargeOrderLegality(childOrderList.get(0));
if (status == 2 || status == -1) {
// 修改充值订单状态
rechargeChildOrderHandle(childOrderList.get(0) , 103);
// 如果订单记录超过5条退款 反之继续充值
if (childOrderList.size() > 4) {
return 2;
} else {
// 如果订单记录超过71小时 反之继续充值
return hours > 71 ? 2 : 1;
}
}
if (status == 1) {
// 修改充值订单状态
rechargeChildOrderHandle(childOrderList.get(0) , 101);
return 5;
}
}
return 3;
}
/**
* @Author Sum1Dream
* @Name rechargeChildOrderHandle
* @Description // 处理子订单
* @Date 18:50 2023/3/28
* @Param [rechargeChildOrder]
* @Return void
*/
private void rechargeChildOrderHandle(OutRechargeChildOrder rechargeChildOrder , Integer status) {
rechargeChildOrder.setUpdateTime(new Date());
rechargeChildOrder.setStatus(status);
outRechargeChildOrderService.updateOrder(rechargeChildOrder);
} }
} }

@ -1,98 +0,0 @@
package com.hai.service.pay.impl;
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.pay.util.XmlUtil;
import com.hai.common.pay.util.sdk.WXPayConstants;
import com.hai.common.utils.WxUtils;
import com.hai.config.CommonSysConst;
import com.hai.dao.HighGasOrderPushMapper;
import com.hai.entity.*;
import com.hai.enum_type.OrderPushType;
import com.hai.model.ResultProfitSharing;
import com.hai.service.*;
import com.hai.service.pay.PayService;
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.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.net.ssl.SSLContext;
import java.io.FileInputStream;
import java.math.BigDecimal;
import java.security.KeyStore;
import java.util.*;
/**
* @Auther: 胡锐
* @Description:
* @Date: 2021/3/27 00:35
*/
@Service("rechargeOrderService")
public class RechargeOrderServiceImpl implements PayService {
private static Logger log = LoggerFactory.getLogger(RechargeOrderServiceImpl.class);
@Resource
private OutRechargeOrderService outRechargeOrderService;
@Resource
private HighGasOrderPushMapper highGasOrderPushMapper;
// todo 当前接口已经废弃
@Override
public void paySuccess(Map<String, String> map, String payType) throws Exception {
if (payType.equals("Alipay")) {
// 支付宝支付 todo 暂未开发
return;
}
if (payType.equals("WechatPay")) {
// 查询订单信息
OutRechargeOrder order = outRechargeOrderService.findByOrderNo(map.get("out_trade_no"));
// 推送订单记录
HighGasOrderPush highGasOrderPush = new HighGasOrderPush();
highGasOrderPush.setType(OrderPushType.type2.getType());
highGasOrderPush.setOrderNo(order.getOrderNo());
highGasOrderPush.setCreateTime(new Date());
highGasOrderPush.setRequestContent(order.getOrderNo());
highGasOrderPush.setReturnContent(String.valueOf(map));
highGasOrderPushMapper.insert(highGasOrderPush);
if (order.getPayStatus() == 101) {
order.setPaySerialNo(map.get("transaction_id")); // 支付流水号
order.setPayRealPrice(new BigDecimal(map.get("total_fee")).divide(new BigDecimal("100"))); // 实付金额
order.setPayTime(new Date()); // 支付时间
// 订单支付状态 : 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
order.setPayStatus(102);
order.setRechargeStatus(204);
order.setPayType(2);
outRechargeOrderService.updateOrder(order);
// if (order.getRechargeType() == 1) {
// JSONObject object = outRechargeOrderService.getMobile(order.getRechargeContent() , order.getOrderPrice().intValue() , order.getOrderNo() , order.getRechargeType());
// if (object.getInteger("code") != 200) {
// order.setRechargeStatus(1);
// order.setAbnormalMsg(object.getString("message"));
// }
// }
outRechargeOrderService.pollRequest(order);
}
}
}
}

@ -181,32 +181,43 @@ public class WxMsgController {
// 4:支付码牌扫码 // 4:支付码牌扫码
if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type4.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type4.getType())){ if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type4.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type4.getType())){
// 支付码码牌上的二维码 // 支付码码牌上的二维码
if (Objects.equals(object.getString("codeTyp"), "PAYMENT_CODE")) { if (Objects.equals(object.getString("codeType"), "PAYMENT_CODE")) {
linkContent = linkContent =
"支付分享,享受更高优惠[礼物]\n\n" "点击领取优惠券,享受更多优惠[礼物]\n\n"
+ "<a data-miniprogram-appid='wx8d49e2f83025229d' data-miniprogram-path=\"/pages/qianZhuPay/union-pay/union-pay\" " + + "<a href='" +
"href='" + "https://hsgcs.dctpay.com"
CommonSysConst.getSysConfig().getHsgDomainName() // CommonSysConst.getSysConfig().getHsgDomainName()
+ "/hsgH5?accountId=0000012&key=&code=" + "/hsgH5?accountId=0000014&key=&code="
+ object.getString("code") + object.getString("code")
+ + "'>立即领取优惠券</a>\n\n";
" data-miniprogram-type=\"text\"></a>\n\n";
} }
// 支付成功生成的二维码 // 支付成功生成的二维码
if (Objects.equals(object.getString("codeTyp"), "PAYMENT_SUCCESS")) { if (Objects.equals(object.getString("codeType"), "PAYMENT_SUCCESS")) {
linkContent = linkContent =
"支付分享,享受更高优惠[礼物]\n\n" "支付分享,享受更高优惠[礼物]\n\n"
+ "<a href='" + "<a href='"
// + "https://hsgcs.dctpay.com" + "https://hsgcs.dctpay.com"
+ CommonSysConst.getSysConfig().getHsgDomainName() // + CommonSysConst.getSysConfig().getHsgDomainName()
+ "/hsgH5?accountId=0000012&key=&code="
+ object.getString("code")
+ "'>分享好友</a>\n\n";
}
// 扫码分享二维码进入
if (Objects.equals(object.getString("codeType"), "SHARE")) {
linkContent =
"支付分享,享受更高优惠[礼物]\n\n"
+ "<a href='"
+ "https://hsgcs.dctpay.com"
// + CommonSysConst.getSysConfig().getHsgDomainName()
+ "/hsgH5?accountId=0000012&key=&code=" + "/hsgH5?accountId=0000012&key=&code="
+ object.getString("code") + object.getString("code")
+ "'>分享好友</a>\n\n"; + "'>分享好友</a>\n\n";
} }
} }
// 5:扫码贵州中石化优惠券二维码 // 5:扫码贵州中石化优惠券二维码
if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type5.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type5.getType())){ if (Objects.equals(object.getString("qrscene_type"), WxQrCodeTypeEnum.type5.getType()) || Objects.equals(object.getString("type"), WxQrCodeTypeEnum.type5.getType())){
mapQrCode.put("type", object.getString("encryptType")); mapQrCode.put("type", object.getString("encryptType"));
@ -248,6 +259,7 @@ public class WxMsgController {
linkContent = "<a href='" + CommonSysConst.getSysConfig().getHsgDomainName() + "/hsgH5'>点击查看更多优惠</a>\n\n"; linkContent = "<a href='" + CommonSysConst.getSysConfig().getHsgDomainName() + "/hsgH5'>点击查看更多优惠</a>\n\n";
} }
System.out.println("===================" + linkContent);
// 判断是否是新用户 // 判断是否是新用户
// if (user == null) { // if (user == null) {

@ -5,11 +5,14 @@ import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp; import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode; import com.hai.common.exception.SysCode;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.WxOrderConfig;
import com.hai.entity.ApiMerchants; import com.hai.entity.ApiMerchants;
import com.hai.entity.ApiOrder; import com.hai.entity.ApiOrder;
import com.hai.entity.ApiProductConfig; import com.hai.entity.ApiProductConfig;
import com.hai.model.OrderRefundModel;
import com.hai.model.ResponseData; import com.hai.model.ResponseData;
import com.hai.openApi.service.ApiOrderService; import com.hai.openApi.service.ApiOrderService;
import com.hai.order.model.RefundPriceModel;
import com.hai.order.type.OrderProductType; import com.hai.order.type.OrderProductType;
import com.hai.service.*; import com.hai.service.*;
import com.v1.config.ToolConfig; import com.v1.config.ToolConfig;
@ -26,6 +29,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.sound.midi.Soundbank;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -259,4 +263,68 @@ public class orderController {
} }
} }
@RequestMapping(value = "/externalOrderRefund", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "对外订单退款接口")
public ResponseData externalOrderRefund(@RequestBody JSONObject object , HttpServletRequest request) {
try {
System.out.println(object);
String ip = "";
// 有的user可能使用代理,为处理用户使用代理的情况,使用x-forwarded-for
if (request.getHeader("x-forwarded-for") == null) {
ip = request.getRemoteAddr();
} else {
ip = request.getHeader("x-forwarded-for");
}
if (!apiIpAddressService.validationIpAddressLegal(object.getString("merchId") , ip)) {
log.error("getRechargeProduct error!", "非法ip地址,请联系管理人员!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.IP_ERROR, "非法ip地址,请联系管理人员!");
}
if (
StringUtils.isBlank(object.getString("apiKey")) ||
StringUtils.isBlank(object.getString("paySerialNo")) ||
StringUtils.isBlank(object.getString("wxMchId")) ||
StringUtils.isBlank(object.getString("refundPrice")) ||
StringUtils.isBlank(object.getString("payRealPrice")) ||
StringUtils.isBlank(object.getString("sign")) ||
StringUtils.isBlank(object.getString("merchId"))
) {
log.error("createOrder error!", "请求参数校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR);
}
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(object.getString("merchId"));
if (apiMerchants == null) {
log.error("getRechargeProduct error!", "帐户错误!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.ACCOUNT_NOT_EXIST);
}
Map<String , Object> map = new HashMap<>();
map.put("paySerialNo" , object.getString("paySerialNo"));
map.put("wxMchId" , object.getString("wxMchId"));
map.put("payRealPrice" , object.getString("payRealPrice"));
map.put("refundPrice" , object.getString("refundPrice"));
map.put("apiKey" , object.getString("apiKey"));
map.put("merchId" , object.getString("merchId"));
if (!secConfigService.isSignVerify(map, object.getString("sign"))) {
log.error("createOrder error!", "签名校验失败!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.SIGN_VERIFY);
}
return ResponseMsgUtil.success(WxOrderConfig.orderToRefund(object.getString("paySerialNo"),object.getBigDecimal("payRealPrice"), object.getString("wxMchId"), object.getBigDecimal("refundPrice")));
} catch (Exception e) {
log.error("HighOpenApiController --> createOrder() error!", e);
return ResponseMsgUtil.exception(e);
}
}
} }

Loading…
Cancel
Save