提交修改

dev-discount
袁野 3 years ago
parent 41ecc8ef9b
commit e0baa1e5c9
  1. 35
      hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java
  2. 7
      hai-bweb/src/main/java/com/bweb/controller/OutRechargePriceController.java
  3. 85
      hai-bweb/src/main/java/com/bweb/excelListener/ImportRechargeOrderListener.java
  4. 23
      hai-bweb/src/main/java/com/bweb/model/ExportOutRechargeOrder.java
  5. 102
      hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java
  6. 4
      hai-cweb/src/main/java/com/cweb/controller/OutRechargePriceController.java
  7. 8
      hai-cweb/src/main/java/com/cweb/controller/pay/CzOrderController.java
  8. 2
      hai-service/src/main/java/com/hai/dao/OutRechargeOrderMapperExt.java
  9. 9
      hai-service/src/main/java/com/hai/model/OutRechargeOrderModel.java
  10. 13
      hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java
  11. 147
      hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java
  12. 3
      hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java
  13. 3
      hai-service/src/main/resources/prod/commonConfig.properties

@ -3,9 +3,12 @@ package com.bweb.controller;
import com.alibaba.excel.EasyExcel; import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.bweb.config.SysConst; import com.bweb.config.SysConst;
import com.bweb.excelListener.ImportCouponListener;
import com.bweb.excelListener.ImportRechargeOrderListener;
import com.bweb.model.ExportOutRechargeOrder; import com.bweb.model.ExportOutRechargeOrder;
import com.bweb.model.ExportOutRechargeOrderCount; import com.bweb.model.ExportOutRechargeOrderCount;
import com.bweb.model.ExportOutRechargeUserOrderCount; import com.bweb.model.ExportOutRechargeUserOrderCount;
import com.bweb.model.ImportCouponModel;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.hai.common.exception.ErrorCode; import com.hai.common.exception.ErrorCode;
@ -13,10 +16,12 @@ import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode; import com.hai.common.exception.SysCode;
import com.hai.common.pay.util.XmlUtil; import com.hai.common.pay.util.XmlUtil;
import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.pay.util.sdk.WXPayConstants;
import com.hai.common.security.SessionObject;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.ResponseMsgUtil;
import com.hai.common.utils.WxUtils; import com.hai.common.utils.WxUtils;
import com.hai.config.HuiLianTongUnionCardConfig; import com.hai.config.HuiLianTongUnionCardConfig;
import com.hai.config.UnionPayConfig; import com.hai.config.UnionPayConfig;
import com.hai.entity.HighCoupon;
import com.hai.entity.HighRefundAudit; import com.hai.entity.HighRefundAudit;
import com.hai.entity.OutRechargeOrder; import com.hai.entity.OutRechargeOrder;
import com.hai.model.*; import com.hai.model.*;
@ -36,6 +41,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
@ -119,6 +125,29 @@ public class OutRechargeOrderController {
} }
} }
@RequestMapping(value="/importRechargeOrder",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "导入话费充值订单")
public ResponseData importRechargeOrder( @RequestParam(value = "file" , required = true) MultipartFile files,
HttpServletRequest request) {
try {
ImportRechargeOrderListener importRechargeOrderListener = new ImportRechargeOrderListener();
importRechargeOrderListener.initData(outRechargeOrderService);
EasyExcel.read(files.getInputStream(), ExportOutRechargeOrder.class, importRechargeOrderListener).sheet().doRead();
Map<String, Object> map = new HashMap<>();
map.put("errorData", importRechargeOrderListener.getErrorData());
map.put("errorTotal", importRechargeOrderListener.getErrorData().size());
return ResponseMsgUtil.success(map);
} catch (Exception e) {
log.error("HighCouponController -> importStock() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/getOrderList", method = RequestMethod.GET) @RequestMapping(value = "/getOrderList", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "获取订单") @ApiOperation(value = "获取订单")
@ -127,6 +156,7 @@ public class OutRechargeOrderController {
@RequestParam(name = "orderNo", required = false) String orderNo, @RequestParam(name = "orderNo", required = false) String orderNo,
@RequestParam(name = "rechargeModel", required = false) String rechargeModel, @RequestParam(name = "rechargeModel", required = false) String rechargeModel,
@RequestParam(name = "rechargeContent", required = false) String rechargeContent, @RequestParam(name = "rechargeContent", required = false) String rechargeContent,
@RequestParam(name = "rechargeType", required = false) String rechargeType,
@RequestParam(name = "userPhone", required = false) String userPhone, @RequestParam(name = "userPhone", required = false) String userPhone,
@RequestParam(name = "idCard", required = false) String idCard, @RequestParam(name = "idCard", required = false) String idCard,
@RequestParam(name = "payType", required = false) Integer payType, @RequestParam(name = "payType", required = false) Integer payType,
@ -153,6 +183,9 @@ public class OutRechargeOrderController {
if (StringUtils.isNotBlank(rechargeContent)) { if (StringUtils.isNotBlank(rechargeContent)) {
map.put("rechargeContent", rechargeContent); map.put("rechargeContent", rechargeContent);
} }
if (StringUtils.isNotBlank(rechargeType)) {
map.put("rechargeType", rechargeType);
}
if (StringUtils.isNotBlank(userPhone)) { if (StringUtils.isNotBlank(userPhone)) {
map.put("userPhone", userPhone); map.put("userPhone", userPhone);
@ -205,6 +238,7 @@ public class OutRechargeOrderController {
@RequestParam(name = "rechargeContent", required = false) String rechargeContent, @RequestParam(name = "rechargeContent", required = false) String rechargeContent,
@RequestParam(name = "userPhone", required = false) String userPhone, @RequestParam(name = "userPhone", required = false) String userPhone,
@RequestParam(name = "idCard", required = false) String idCard, @RequestParam(name = "idCard", required = false) String idCard,
@RequestParam(name = "rechargeType", required = false) String rechargeType,
@RequestParam(name = "payType", required = false) Integer payType, @RequestParam(name = "payType", required = false) Integer payType,
@RequestParam(name = "code", required = false) Integer code, @RequestParam(name = "code", required = false) Integer code,
@RequestParam(name = "createTimeS", required = false) Long createTimeS, @RequestParam(name = "createTimeS", required = false) Long createTimeS,
@ -222,6 +256,7 @@ public class OutRechargeOrderController {
map.put("idCard", idCard); map.put("idCard", idCard);
map.put("payType", payType); map.put("payType", payType);
map.put("code", code); map.put("code", code);
map.put("rechargeType", rechargeType);
map.put("createTimeS", createTimeS); map.put("createTimeS", createTimeS);
map.put("createTimeE", createTimeE); map.put("createTimeE", createTimeE);
map.put("payTimeS", payTimeS); map.put("payTimeS", payTimeS);

@ -46,6 +46,7 @@ public class OutRechargePriceController {
public ResponseData getListOutRechargePrice( public ResponseData getListOutRechargePrice(
@RequestParam(value = "type", required = false) Integer type , @RequestParam(value = "type", required = false) Integer type ,
@RequestParam(value = "showType", required = false) Integer showType , @RequestParam(value = "showType", required = false) Integer showType ,
@RequestParam(value = "rechargeType", required = false) Integer rechargeType ,
@RequestParam(name = "pageNum", required = true) Integer pageNum, @RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request @RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request
) { ) {
@ -64,6 +65,10 @@ public class OutRechargePriceController {
map.put("showType", String.valueOf(showType)); map.put("showType", String.valueOf(showType));
} }
if (rechargeType != null ) {
map.put("rechargeType", String.valueOf(rechargeType));
}
map.put("companyId" , String.valueOf(userInfoModel.getBsCompany().getId())); map.put("companyId" , String.valueOf(userInfoModel.getBsCompany().getId()));
PageHelper.startPage(pageNum, pageSize); PageHelper.startPage(pageNum, pageSize);
@ -90,6 +95,7 @@ public class OutRechargePriceController {
|| outRechargePrice.getPrice() == null || outRechargePrice.getPrice() == null
|| outRechargePrice.getRealPrice() == null || outRechargePrice.getRealPrice() == null
|| outRechargePrice.getShowType() == null || outRechargePrice.getShowType() == null
|| outRechargePrice.getRechargeType() == null
|| outRechargePrice.getSort() == null || outRechargePrice.getSort() == null
) { ) {
log.error("SecOrganizationController -> insertPrice() error!"); log.error("SecOrganizationController -> insertPrice() error!");
@ -120,6 +126,7 @@ public class OutRechargePriceController {
|| outRechargePrice.getId() == null || outRechargePrice.getId() == null
|| outRechargePrice.getPrice() == null || outRechargePrice.getPrice() == null
|| outRechargePrice.getRealPrice() == null || outRechargePrice.getRealPrice() == null
|| outRechargePrice.getRechargeType() == null
|| outRechargePrice.getShowType() == null || outRechargePrice.getShowType() == null
|| outRechargePrice.getSort() == null || outRechargePrice.getSort() == null
) { ) {

@ -0,0 +1,85 @@
package com.bweb.excelListener;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.bweb.model.ExportOutRechargeOrder;
import com.bweb.model.ImportCouponModel;
import com.hai.common.utils.DateUtil;
import com.hai.entity.OutRechargeOrder;
import com.hai.service.OutRechargeOrderService;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
public class ImportRechargeOrderListener extends AnalysisEventListener<ExportOutRechargeOrder> {
List<ExportOutRechargeOrder> errorData = new ArrayList<>();
List<OutRechargeOrder> successData = new ArrayList<>();
private OutRechargeOrderService outRechargeOrderService;
/**
* @Author Sum1Dream
* @name invoke.java
* @Description // 解析到的每一条数据都会调用此方法
* @Date 4:03 下午 2022/1/24
* @Param [com.bweb.model.ExportOutRechargeOrder, com.alibaba.excel.context.AnalysisContext]
* @return void
*/
@Override
public void invoke(ExportOutRechargeOrder data, AnalysisContext context) {
if (StringUtils.isBlank(data.getOrderNo())
|| StringUtils.isBlank(data.getStatusName()) ) {
data.setErrorMessage("有必填项未填写");
errorData.add(data);
return;
}
OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderNo(data.getOrderNo());
if (rechargeOrder.getStatus() != 2) {
data.setErrorMessage("当前订单状态错误。");
errorData.add(data);
return;
}
if (rechargeOrder.getRechargeType() != 2) {
data.setErrorMessage("当前话费订单充值类型为快充。");
errorData.add(data);
return;
}
if (Objects.equals(data.getStatusName(), "已完成")) {
rechargeOrder.setStatus(3);
rechargeOrder.setFinishTime(new Date());
} else if (Objects.equals(data.getStatusName(), "失败")){
rechargeOrder.setStatus(6);
}
successData.add(rechargeOrder);
}
@Override
public void doAfterAllAnalysed(AnalysisContext context) {
if (successData.size() > 0) {
try {
outRechargeOrderService.updateOrderList(successData);
} catch (Exception e) {
e.printStackTrace();
}
}
this.successData.clear();
}
public List<ExportOutRechargeOrder> getErrorData() {
return errorData;
}
public void initData(OutRechargeOrderService outRechargeOrderService) {
this.outRechargeOrderService = outRechargeOrderService;
}
}

@ -37,6 +37,9 @@ public class ExportOutRechargeOrder {
@ExcelProperty("应付金额") @ExcelProperty("应付金额")
private BigDecimal payPrice; private BigDecimal payPrice;
@ExcelProperty("充值类型")
private String rechargeTypeName;
@ExcelProperty("实付金额") @ExcelProperty("实付金额")
private BigDecimal payRealPrice; private BigDecimal payRealPrice;
@ -67,6 +70,9 @@ public class ExportOutRechargeOrder {
@ExcelProperty("第三方退款订单号") @ExcelProperty("第三方退款订单号")
private String refundId; private String refundId;
// 错误消息
private String errorMessage;
public String getOrderNo() { public String getOrderNo() {
return orderNo; return orderNo;
} }
@ -226,4 +232,21 @@ public class ExportOutRechargeOrder {
public void setCardNo(String cardNo) { public void setCardNo(String cardNo) {
this.cardNo = cardNo; this.cardNo = cardNo;
} }
public String getErrorMessage() {
return errorMessage;
}
public void setErrorMessage(String errorMessage) {
this.errorMessage = errorMessage;
}
public String getRechargeTypeName() {
return rechargeTypeName;
}
public void setRechargeTypeName(String rechargeTypeName) {
this.rechargeTypeName = rechargeTypeName;
}
} }

@ -527,57 +527,57 @@ public class OutRechargeOrderController {
} }
@RequestMapping(value = "/orderToRefund", method = RequestMethod.GET) // @RequestMapping(value = "/orderToRefund", method = RequestMethod.GET)
@ResponseBody // @ResponseBody
@ApiOperation(value = "订单退款") // @ApiOperation(value = "订单退款")
public ResponseData orderToRefund(@RequestParam(name = "orderId", required = false) Long orderId, // public ResponseData orderToRefund(@RequestParam(name = "orderId", required = false) Long orderId,
HttpServletRequest request) { // HttpServletRequest request) {
try { // try {
//
OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); // OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId);
if (order == null) { // if (order == null) {
log.error("orderToPay error!", "未找到充值订单"); // log.error("orderToPay error!", "未找到充值订单");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到充值订单"); // throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到充值订单");
} // }
//
// 订单状态 : 1.待支付 2.已支付 3.已完成 4.已取消 5.已退款 // // 订单状态 : 1.待支付 2.已支付 3.已完成 4.已取消 5.已退款
if (order.getStatus() != 2) { // if (order.getStatus() != 2) {
log.error("orderToPay error!", "无法退款,订单不处于已支付状态"); // log.error("orderToPay error!", "无法退款,订单不处于已支付状态");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态"); // throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态");
} // }
//
Map<String,String> param = new HashMap<>(); // Map<String,String> param = new HashMap<>();
param.put("appid", "wx637bd6f7314daa46"); // param.put("appid", "wx637bd6f7314daa46");
param.put("mch_id", "1289663601"); // param.put("mch_id", "1289663601");
param.put("sub_mch_id" , "1609882817"); // param.put("sub_mch_id" , "1609882817");
param.put("nonce_str", WxUtils.makeNonStr()); // param.put("nonce_str", WxUtils.makeNonStr());
param.put("transaction_id", order.getPaySerialNo()); // param.put("transaction_id", order.getPaySerialNo());
param.put("out_refund_no", "HFR"+new Date().getTime()); // param.put("out_refund_no", "HFR"+new Date().getTime());
param.put("total_fee", String.valueOf(order.getPayRealPrice().multiply(new BigDecimal("100")).intValue())); // 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("refund_fee", String.valueOf(order.getPayRealPrice().multiply(new BigDecimal("100")).intValue()));
param.put("sign_type", "HMAC-SHA256"); // param.put("sign_type", "HMAC-SHA256");
//
String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256); // String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256);
param.put("sign", signStr); // param.put("sign", signStr);
//
String resultXmL = doRefundRequest(param.get("mch_id"), null, WxUtils.mapToXml(param)); // String resultXmL = doRefundRequest(param.get("mch_id"), null, WxUtils.mapToXml(param));
OrderRefundModel orderRefundModel = XmlUtil.getObjectFromXML(resultXmL, OrderRefundModel.class); // OrderRefundModel orderRefundModel = XmlUtil.getObjectFromXML(resultXmL, OrderRefundModel.class);
if(orderRefundModel.getResult_code().equals("SUCCESS")) { // if(orderRefundModel.getResult_code().equals("SUCCESS")) {
order.setStatus(5); // order.setStatus(5);
order.setRefundTime(new Date()); // order.setRefundTime(new Date());
order.setOutRefundNo(orderRefundModel.getOut_refund_no()); // order.setOutRefundNo(orderRefundModel.getOut_refund_no());
order.setRefundId(orderRefundModel.getRefund_id()); // order.setRefundId(orderRefundModel.getRefund_id());
order.setRefundFee(new BigDecimal(orderRefundModel.getRefund_fee()).divide(new BigDecimal("100"))); // order.setRefundFee(new BigDecimal(orderRefundModel.getRefund_fee()).divide(new BigDecimal("100")));
outRechargeOrderService.updateOrder(order); // outRechargeOrderService.updateOrder(order);
return ResponseMsgUtil.success("退款成功"); // return ResponseMsgUtil.success("退款成功");
} // }
return ResponseMsgUtil.success("退款失败!错误代码:"+orderRefundModel.getErr_code()+",错误描述"+orderRefundModel.getErr_code_des()); // return ResponseMsgUtil.success("退款失败!错误代码:"+orderRefundModel.getErr_code()+",错误描述"+orderRefundModel.getErr_code_des());
//
} catch (Exception e) { // } catch (Exception e) {
log.error("HighOrderController --> getUserOrderList() error!", e); // log.error("HighOrderController --> getUserOrderList() error!", e);
return ResponseMsgUtil.exception(e); // return ResponseMsgUtil.exception(e);
} // }
} // }
@RequestMapping(value = "/wxProfitsharing", method = RequestMethod.GET) @RequestMapping(value = "/wxProfitsharing", method = RequestMethod.GET)

@ -72,11 +72,11 @@ public class OutRechargePriceController {
map.put("companyId", String.valueOf(bsCompany.getId())); map.put("companyId", String.valueOf(bsCompany.getId()));
} }
if (type != null ) { if (showType != null ) {
map.put("showType", String.valueOf(showType)); map.put("showType", String.valueOf(showType));
} }
if (type != null ) { if (rechargeType != null ) {
map.put("rechargeType", String.valueOf(rechargeType)); map.put("rechargeType", String.valueOf(rechargeType));
} }

@ -21,6 +21,7 @@ import com.hai.entity.OutRechargeOrder;
import com.hai.model.OrderRefundModel; import com.hai.model.OrderRefundModel;
import com.hai.model.ResponseData; import com.hai.model.ResponseData;
import com.hai.service.HighRefundAuditService; import com.hai.service.HighRefundAuditService;
import com.hai.service.HighUserService;
import com.hai.service.OutRechargeOrderService; import com.hai.service.OutRechargeOrderService;
import com.hai.service.pay.impl.GoodsOrderServiceImpl; import com.hai.service.pay.impl.GoodsOrderServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -62,6 +63,9 @@ public class CzOrderController {
@Resource @Resource
private GoodsOrderServiceImpl goodsOrderService; private GoodsOrderServiceImpl goodsOrderService;
@Resource
private HighUserService highUserService;
@RequestMapping(value = "/rechargeCallback", method = RequestMethod.POST) @RequestMapping(value = "/rechargeCallback", method = RequestMethod.POST)
@ApiOperation(value = "话费充值回调") @ApiOperation(value = "话费充值回调")
@ResponseBody @ResponseBody
@ -168,6 +172,10 @@ public class CzOrderController {
} }
} }
if (order.getPayType() == 3) {
highUserService.goldHandle(order.getUserId(), order.getPayRealPrice().intValue() * 100, 1, 3, order.getId());
}
// 银联退款 // 银联退款
if (order.getPayType() == 4) { if (order.getPayType() == 4) {
// 订单退款 // 订单退款

@ -68,6 +68,7 @@ public interface OutRechargeOrderMapperExt {
" a.user_name userName," + " a.user_name userName," +
" a.user_phone userPhone," + " a.user_phone userPhone," +
" case a.recharge_model when 1 then '电信话费' when 2 then '移动话费' when 3 then '联通话费' end rechargeModelName," + " case a.recharge_model when 1 then '电信话费' when 2 then '移动话费' when 3 then '联通话费' end rechargeModelName," +
" case a.recharge_type when 1 then '快充' when 2 then '慢充' end getRechargeTypeName," +
" a.recharge_content rechargeContent," + " a.recharge_content rechargeContent," +
" a.remarks remarks," + " a.remarks remarks," +
" a.id_card cardNo," + " a.id_card cardNo," +
@ -91,6 +92,7 @@ public interface OutRechargeOrderMapperExt {
"<if test='map.payType != null'> and a.`pay_type` = #{map.payType} </if>", "<if test='map.payType != null'> and a.`pay_type` = #{map.payType} </if>",
"<if test='map.code != null'> and a.`Identification_code` = #{map.code} </if>", "<if test='map.code != null'> and a.`Identification_code` = #{map.code} </if>",
"<if test='map.orderNo != null'> and a.`order_no` = #{map.orderNo} </if>", "<if test='map.orderNo != null'> and a.`order_no` = #{map.orderNo} </if>",
"<if test='map.rechargeType != null'> and a.`recharge_type` = #{map.rechargeType} </if>",
"<if test='map.rechargeModel != null'> and a.`recharge_model` = #{map.rechargeModel} </if>", "<if test='map.rechargeModel != null'> and a.`recharge_model` = #{map.rechargeModel} </if>",
"<if test='map.rechargeContent != null'> and a.`recharge_content` LIKE '%${map.rechargeContent}%' </if>", "<if test='map.rechargeContent != null'> and a.`recharge_content` LIKE '%${map.rechargeContent}%' </if>",
"<if test='map.idCard != null'> and a.`id_card` LIKE '%${map.idCard}%' </if>", "<if test='map.idCard != null'> and a.`id_card` LIKE '%${map.idCard}%' </if>",

@ -28,6 +28,7 @@ public class OutRechargeOrderModel extends OutRechargeOrder {
private String outRefundNo; private String outRefundNo;
private String refundId; private String refundId;
private String cardNo; private String cardNo;
private String rechargeTypeName;
public String getOrderNo() { public String getOrderNo() {
return orderNo; return orderNo;
@ -196,4 +197,12 @@ public class OutRechargeOrderModel extends OutRechargeOrder {
public void setCardNo(String cardNo) { public void setCardNo(String cardNo) {
this.cardNo = cardNo; this.cardNo = cardNo;
} }
public String getRechargeTypeName() {
return rechargeTypeName;
}
public void setRechargeTypeName(String rechargeTypeName) {
this.rechargeTypeName = rechargeTypeName;
}
} }

@ -58,6 +58,8 @@ public interface OutRechargeOrderService {
**/ **/
void updateOrder(OutRechargeOrder outRechargeOrder); void updateOrder(OutRechargeOrder outRechargeOrder);
void updateOrderList(List<OutRechargeOrder> rechargeOrders) throws Exception;
/** /**
* @Author Sum1Dream * @Author Sum1Dream
* @Description //取消订单 Administrator * @Description //取消订单 Administrator
@ -146,12 +148,21 @@ public interface OutRechargeOrderService {
/** /**
* @Author Sum1Dream * @Author Sum1Dream
* @name getMobile.java * @name getMobile.java
* @Description // 请求话费 * @Description // 请求话费充值
* @Date 5:02 下午 2022/1/17 * @Date 5:02 下午 2022/1/17
* @Param [java.lang.String] * @Param [java.lang.String]
* @return com.alibaba.fastjson.JSONObject * @return com.alibaba.fastjson.JSONObject
*/ */
JSONObject getMobile(String phone , Integer amount , String orderNo) throws Exception; JSONObject getMobile(String phone , Integer amount , String orderNo) throws Exception;
/**
* @Author Sum1Dream
* @name orderToRefund.java
* @Description // 话费订单退款
* @Date 4:44 下午 2022/1/24
* @Param [java.lang.Long]
* @return void
*/
void rechargeOrderToRefund(Long orderId) throws Exception;
} }

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode; 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.pay.util.XmlUtil;
import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.pay.util.sdk.WXPayConstants;
import com.hai.common.utils.DateUtil; import com.hai.common.utils.DateUtil;
import com.hai.common.utils.HttpsUtils; import com.hai.common.utils.HttpsUtils;
@ -13,21 +14,26 @@ import com.hai.common.utils.WxUtils;
import com.hai.config.CommonSysConfig; import com.hai.config.CommonSysConfig;
import com.hai.config.CommonSysConst; import com.hai.config.CommonSysConst;
import com.hai.config.HuiLianTongUnionCardConfig; import com.hai.config.HuiLianTongUnionCardConfig;
import com.hai.config.UnionPayConfig;
import com.hai.dao.HighGasOrderPushMapper; import com.hai.dao.HighGasOrderPushMapper;
import com.hai.dao.OutRechargeOrderMapper; import com.hai.dao.OutRechargeOrderMapper;
import com.hai.dao.OutRechargeOrderMapperExt; import com.hai.dao.OutRechargeOrderMapperExt;
import com.hai.entity.*; import com.hai.entity.*;
import com.hai.enum_type.OrderPushType; import com.hai.enum_type.OrderPushType;
import com.hai.model.OrderCountModel; import com.hai.model.*;
import com.hai.model.OutOrderModel;
import com.hai.model.OutRechargeOrderModel;
import com.hai.model.OutUserOrderModel;
import com.hai.service.HighUserCardService; import com.hai.service.HighUserCardService;
import com.hai.service.HighUserService; import com.hai.service.HighUserService;
import com.hai.service.OutRechargeOrderService; import com.hai.service.OutRechargeOrderService;
import com.hai.service.pay.impl.GoodsOrderServiceImpl;
import io.swagger.models.auth.In; import io.swagger.models.auth.In;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -59,6 +65,9 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
@Resource @Resource
private OutRechargeOrderService outRechargeOrderService; private OutRechargeOrderService outRechargeOrderService;
@Resource
private GoodsOrderServiceImpl goodsOrderService;
@Override @Override
public List<OutRechargeOrder> getListRechargeOrder(Map<String, String> map) { public List<OutRechargeOrder> getListRechargeOrder(Map<String, String> map) {
OutRechargeOrderExample example = new OutRechargeOrderExample(); OutRechargeOrderExample example = new OutRechargeOrderExample();
@ -94,6 +103,9 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
if (MapUtils.getString(map, "rechargeContent") != null) { if (MapUtils.getString(map, "rechargeContent") != null) {
criteria.andRechargeContentLike("%" + MapUtils.getString(map, "rechargeContent") + "%"); criteria.andRechargeContentLike("%" + MapUtils.getString(map, "rechargeContent") + "%");
} }
if (MapUtils.getString(map, "rechargeType") != null) {
criteria.andRechargeTypeEqualTo(MapUtils.getInteger(map, "rechargeType"));
}
if (MapUtils.getString(map, "phone") != null) { if (MapUtils.getString(map, "phone") != null) {
criteria.andUserPhoneEqualTo(MapUtils.getString(map, "phone")); criteria.andUserPhoneEqualTo(MapUtils.getString(map, "phone"));
@ -142,6 +154,19 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
outRechargeOrderMapper.updateByPrimaryKey(outRechargeOrder); outRechargeOrderMapper.updateByPrimaryKey(outRechargeOrder);
} }
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
public void updateOrderList(List<OutRechargeOrder> rechargeOrders) throws Exception {
for (OutRechargeOrder list:rechargeOrders) {
if (list.getStatus() == 3) {
outRechargeOrderMapper.updateByPrimaryKey(list);
} else if (list.getStatus() == 6) {
rechargeOrderToRefund(list.getId());
}
}
}
@Override @Override
@Transactional(propagation= Propagation.REQUIRES_NEW) @Transactional(propagation= Propagation.REQUIRES_NEW)
public void cancelOrder(Long orderId) { public void cancelOrder(Long orderId) {
@ -383,4 +408,118 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
return HttpsUtils.doPost(CommonSysConst.getSysConfig().getCzUrl() , map); return HttpsUtils.doPost(CommonSysConst.getSysConfig().getCzUrl() , map);
} }
@Override
public void rechargeOrderToRefund(Long orderId) throws Exception {
OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId);
// 订单状态 : 1.待支付 2.已支付 3.已完成 4.已取消 5.已退款 6:退款中
if (order.getStatus() != 2) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态");
}
// 微信退款
if (order.getPayType() == 1) {
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.setStatus(5);
order.setRefundTime(new Date());
order.setOutRefundNo(orderRefundModel.getOut_refund_no());
order.setRefundId(orderRefundModel.getRefund_id());
order.setRefundFee(new BigDecimal(orderRefundModel.getRefund_fee()).divide(new BigDecimal("100")));
outRechargeOrderService.updateOrder(order);
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!错误代码:"+orderRefundModel.getErr_code()+",错误描述"+orderRefundModel.getErr_code_des());
}
}
// 工会卡退款
if (order.getPayType() == 2) {
JSONObject jsonObject = HuiLianTongUnionCardConfig.refund( "HFR"+new Date().getTime() , order.getOrderNo());
if (jsonObject == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求超时,请重新点击");
}
JSONObject dataObject = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data"));
if (dataObject.getBoolean("success") || Objects.equals(dataObject.getString("message"), "原交易已撤销,不可再次操作")) {
order.setStatus(5);
order.setRefundTime(new Date());
order.setOutRefundNo("HFR"+new Date().getTime() );
order.setRefundFee(order.getPayRealPrice());
order.setRefundId(dataObject.getString("orderId"));
outRechargeOrderService.updateOrder(order);
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, dataObject.getString("message"));
}
}
// 金币退款
if (order.getPayType() == 3) {
highUserService.goldHandle(order.getUserId(), order.getPayRealPrice().intValue() * 100, 1, 3, order.getId());
}
// 银联退款
if (order.getPayType() == 4) {
// 订单退款
JSONObject refund = UnionPayConfig.zwrefund(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.setStatus(5);
order.setRefundTime(new Date());
order.setOutRefundNo(refund.getString("oriwtorderid"));
order.setRefundFee(order.getPayRealPrice());
outRechargeOrderService.updateOrder(order);
}
}
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();
}
}
} }

@ -32,6 +32,9 @@ public class OutRechargePriceServiceImpl implements OutRechargePriceService {
if (StringUtils.isNotBlank(map.get("companyId"))) { if (StringUtils.isNotBlank(map.get("companyId"))) {
criteria.andCompanyIdEqualTo(Long.valueOf(map.get("companyId"))); criteria.andCompanyIdEqualTo(Long.valueOf(map.get("companyId")));
} }
if (StringUtils.isNotBlank(map.get("rechargeType"))) {
criteria.andRechargeTypeEqualTo(Integer.valueOf(map.get("rechargeType")));
}
example.setOrderByClause("type asc"); example.setOrderByClause("type asc");
return outRechargePriceMapper.selectByExample(example); return outRechargePriceMapper.selectByExample(example);

@ -46,4 +46,5 @@ TelMemberId=d13091df65d64aafbf0f35d2093157b7
// Mobile // Mobile
CzNotifyUrl = https://hsg.dctpay.com/crest/czOrder/orderRefundNotify CzNotifyUrl = https://hsg.dctpay.com/crest/czOrder/orderRefundNotify
CzAppKey = p429mlj3cvn5hb07 CzAppKey = p429mlj3cvn5hb07
CzUrl = https://hfcs.dmjvip.com/index.php/third/mobile/createOrder CzUrl = https://jj.dmjvip.com/index.php/third/mobile/createOrder
CzAppSecret = bf57pnqy8mkexr0v169c3g4odazwu2ij

Loading…
Cancel
Save