修改话费接口

dev-discount
袁野 3 years ago
parent 0542360671
commit a46d1da807
  1. 2
      hai-bweb/src/main/java/com/bweb/controller/HighRefundAuditController.java
  2. 2
      hai-bweb/src/main/java/com/bweb/controller/HighTestController.java
  3. 142
      hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java
  4. 148
      hai-bweb/src/main/java/com/bweb/controller/OutRechargePriceController.java
  5. 10
      hai-bweb/src/main/java/com/bweb/excelListener/ImportRechargeOrderListener.java
  6. 2
      hai-cweb/src/main/java/com/cweb/config/SysConfig.java
  7. 2
      hai-cweb/src/main/java/com/cweb/controller/HighTestController.java
  8. 1224
      hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java
  9. 6
      hai-cweb/src/main/java/com/cweb/controller/SendSmsController.java
  10. 488
      hai-cweb/src/main/java/com/cweb/controller/pay/CzOrderController.java
  11. 42
      hai-cweb/src/main/java/com/cweb/controller/pay/UnionPayController.java
  12. 4
      hai-service/src/main/java/com/hai/entity/OutRechargePrice.java
  13. 30
      hai-service/src/main/java/com/hai/service/CommonService.java
  14. 5
      hai-service/src/main/java/com/hai/service/OutRechargePriceService.java
  15. 988
      hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java
  16. 4
      hai-service/src/main/java/com/hai/service/impl/HighRefundAuditServiceImpl.java
  17. 351
      hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java
  18. 85
      hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java
  19. 44
      hai-service/src/main/java/com/hai/service/pay/impl/RechargeOrderServiceImpl.java

@ -156,7 +156,7 @@ public class HighRefundAuditController {
if (highRefundAudit.getRefundSource() == 1) {
OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(highRefundAudit.getSourceOrderNo());
outRechargeOrder.setStatus(2);
// outRechargeOrder.setStatus(2);
outRechargeOrderService.updateOrder(outRechargeOrder);
} else {
HighOrder highOrder = highOrderService.getOrderByOrderNo(highRefundAudit.getSourceOrderNo());

File diff suppressed because one or more lines are too long

@ -98,12 +98,12 @@ public class OutRechargeOrderController {
OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderId(orderId);
if (outRechargeOrder.getStatus() == 1) {
outRechargeOrderService.cancelOrder(orderId);
} else {
log.error("orderToPay error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, "");
}
// if (outRechargeOrder.getStatus() == 1) {
// outRechargeOrderService.cancelOrder(orderId);
// } else {
// log.error("orderToPay error!");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, "");
// }
return ResponseMsgUtil.success("操作成功");
@ -121,12 +121,12 @@ public class OutRechargeOrderController {
OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderId(orderId);
if (outRechargeOrder.getStatus() == 2) {
outRechargeOrderService.finishOrder(orderId);
} else {
log.error("orderToPay error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, "");
}
// if (outRechargeOrder.getStatus() == 2) {
// outRechargeOrderService.finishOrder(orderId);
// } else {
// log.error("orderToPay error!");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, "");
// }
return ResponseMsgUtil.success("操作成功");
@ -301,10 +301,10 @@ public class OutRechargeOrderController {
}
// 订单状态 : 1.待支付 2.已支付 3.已完成 4.已取消 5.已退款 6:退款中
if (order.getStatus() != 6) {
log.error("orderToPay error!", "无法退款,订单不处于退款中状态");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态");
}
// if (order.getStatus() != 6) {
// log.error("orderToPay error!", "无法退款,订单不处于退款中状态");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态");
// }
// 微信退款
if (order.getPayType() == 1) {
@ -324,19 +324,19 @@ public class OutRechargeOrderController {
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);
highRefundAudit.setStatus(1);
highRefundAuditService.updateRefundAudit(highRefundAudit);
} else {
log.error("orderToPay error!", "退款失败");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!错误代码:"+orderRefundModel.getErr_code()+",错误描述"+orderRefundModel.getErr_code_des());
}
// 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);
// highRefundAudit.setStatus(1);
// highRefundAuditService.updateRefundAudit(highRefundAudit);
// } else {
// log.error("orderToPay error!", "退款失败");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "退款失败!错误代码:"+orderRefundModel.getErr_code()+",错误描述"+orderRefundModel.getErr_code_des());
// }
}
// 工会卡退款
@ -350,21 +350,21 @@ public class OutRechargeOrderController {
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"));
highRefundAudit.setStatus(1);
highRefundAuditService.updateRefundAudit(highRefundAudit);
outRechargeOrderService.updateOrder(order);
} else {
log.error("orderToPay error!", dataObject.getString("message"));
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, dataObject.getString("message"));
}
// 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"));
//
// highRefundAudit.setStatus(1);
// highRefundAuditService.updateRefundAudit(highRefundAudit);
// outRechargeOrderService.updateOrder(order);
//
// } else {
// log.error("orderToPay error!", dataObject.getString("message"));
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, dataObject.getString("message"));
// }
}
// 积分退款
@ -374,7 +374,7 @@ public class OutRechargeOrderController {
}else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已有退款记录");
}
order.setStatus(5);
// order.setStatus(5);
order.setRefundTime(new Date());
order.setOutRefundNo("HFR"+new Date().getTime() );
order.setRefundFee(order.getPayRealPrice());
@ -390,7 +390,7 @@ public class OutRechargeOrderController {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refund.getString("returnmsg"));
}
order.setStatus(5);
// order.setStatus(5);
order.setRefundTime(new Date());
order.setOutRefundNo(refund.getString("oriwtorderid"));
order.setRefundFee(order.getPayRealPrice());
@ -585,31 +585,31 @@ public class OutRechargeOrderController {
try {
OutRechargeOrderRecord rechargeOrderRecord = rechargeOrderRecordService.findByOrderId(orderId);
if (rechargeOrderRecord == null) {
rechargeOrderRecord = new OutRechargeOrderRecord();
// 查询订单
OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId);
if (order.getRechargeType() == 1) {
String orderNo = "CZ" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5);
JSONObject object = outRechargeOrderService.getMobile(order.getRechargeContent() , order.getOrderPrice().intValue() , orderNo , order.getRechargeType());
if (object.getInteger("code") != 200) {
order.setRechargeStatus(1);
order.setAbnormalMsg(object.getString("message"));
}
outRechargeOrderService.updateOrder(order);
rechargeOrderRecord.setRechargeOrderId(order.getId());
rechargeOrderRecord.setRechargeOrderNo(orderNo);
rechargeOrderRecord.setCreateTime(new Date());
rechargeOrderRecord.setStatus(1);
rechargeOrderRecordService.insertOrder(rechargeOrderRecord);
}
} else {
// 查询订单
OutRechargeOrder order = outRechargeOrderService.findByOrderId(rechargeOrderRecord.getRechargeOrderId());
if (order.getStatus() == 2) {
outRechargeOrderService.rechargeOrderToRefund(order.getId());
}
}
// if (rechargeOrderRecord == null) {
// rechargeOrderRecord = new OutRechargeOrderRecord();
// // 查询订单
// OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId);
// if (order.getRechargeType() == 1) {
// String orderNo = "CZ" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5);
// JSONObject object = outRechargeOrderService.getMobile(order.getRechargeContent() , order.getOrderPrice().intValue() , orderNo , order.getRechargeType());
// if (object.getInteger("code") != 200) {
// order.setRechargeStatus(1);
// order.setAbnormalMsg(object.getString("message"));
// }
// outRechargeOrderService.updateOrder(order);
// rechargeOrderRecord.setRechargeOrderId(order.getId());
// rechargeOrderRecord.setRechargeOrderNo(orderNo);
// rechargeOrderRecord.setCreateTime(new Date());
// rechargeOrderRecord.setStatus(1);
// rechargeOrderRecordService.insertOrder(rechargeOrderRecord);
// }
// } else {
// // 查询订单
// OutRechargeOrder order = outRechargeOrderService.findByOrderId(rechargeOrderRecord.getRechargeOrderId());
// if (order.getStatus() == 2) {
// outRechargeOrderService.rechargeOrderToRefund(order.getId());
// }
// }
return ResponseMsgUtil.success("操作成功");

@ -1,5 +1,7 @@
package com.bweb.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hai.common.exception.ErrorCode;
@ -9,8 +11,10 @@ import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.entity.OutRechargePrice;
import com.hai.entity.SecDictionary;
import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel;
import com.hai.service.CommonService;
import com.hai.service.OutRechargePriceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@ -22,6 +26,8 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@ -40,13 +46,18 @@ public class OutRechargePriceController {
@Resource
private OutRechargePriceService outRechargePriceService;
@Resource
private CommonService commonService;
@RequestMapping(value = "/getListOutRechargePrice", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询充值金额列表")
public ResponseData getListOutRechargePrice(
@RequestParam(value = "type", required = false) Integer type ,
@RequestParam(value = "showType", required = false) Integer showType ,
@RequestParam(value = "rechargeType", required = false) Integer rechargeType ,
@RequestParam(value = "operatorType", required = false) Integer operatorType,
@RequestParam(value = "rechargePlatform", required = false) Integer rechargePlatform,
@RequestParam(value = "rechargeType", required = false) Integer rechargeType,
@RequestParam(value = "rechargeWay", required = false) Integer rechargeWay,
@RequestParam(value = "status", required = false) Integer status,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize, HttpServletRequest request
) {
@ -55,27 +66,21 @@ public class OutRechargePriceController {
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
Map<String, String> map = new HashMap<>();
if (type != null ) {
map.put("type", String.valueOf(type));
}
if (showType != null ) {
map.put("showType", String.valueOf(showType));
}
Map<String, Object> map = new HashMap<>();
if (rechargeType != null ) {
map.put("rechargeType", String.valueOf(rechargeType));
}
map.put("operatorType", operatorType);
map.put("rechargePlatform", rechargePlatform);
map.put("rechargeType", rechargeType);
map.put("rechargeWay", rechargeWay);
map.put("status", status);
map.put("companyId" , String.valueOf(userInfoModel.getBsCompany().getId()));
map.put("companyId", String.valueOf(userInfoModel.getBsCompany().getId()));
PageHelper.startPage(pageNum, pageSize);
List<OutRechargePrice> outRechargePrices = outRechargePriceService.getListRechargePrice(map);
return ResponseMsgUtil.success(new PageInfo<>(outRechargePrices));
return ResponseMsgUtil.success(new PageInfo<>(outRechargePrices));
} catch (Exception e) {
log.error("OutRechargePriceController --> getListUser() error!", e);
return ResponseMsgUtil.exception(e);
@ -85,29 +90,32 @@ public class OutRechargePriceController {
@RequestMapping(value = "/insertPrice", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "新增金额")
public ResponseData insertAgent(@RequestBody OutRechargePrice outRechargePrice, HttpServletRequest request) {
public ResponseData insertPrice(@RequestBody JSONObject object, HttpServletRequest request) {
try {
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (outRechargePrice.getType() == null
|| outRechargePrice.getPrice() == null
|| outRechargePrice.getRealPrice() == null
|| outRechargePrice.getShowType() == null
|| outRechargePrice.getRechargeType() == null
|| outRechargePrice.getSort() == null
if (object == null ||
object.getJSONArray("rechargePrices") == null ||
object.getBigDecimal("discount") == null ||
object.getString("operatorType") == null ||
object.getJSONArray("rechargePlatform") == null ||
object.getJSONArray("productPlatform") == null ||
object.getInteger("rechargeType") == null ||
object.getJSONArray("payType") == null ||
object.getInteger("rechargeWay") == null ||
object.getBigDecimal("integralDiscount") == null
) {
log.error("SecOrganizationController -> insertPrice() error!");
log.error("OutRechargePriceController -> insertPrice() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
object.put("operatorId", userInfoModel.getSecUser().getId());
object.put("operatorName", userInfoModel.getSecUser().getLoginName());
object.put("companyId", userInfoModel.getBsCompany().getId());
outRechargePrice.setCompanyId(userInfoModel.getBsCompany().getId());
outRechargePrice.setCreateTime(new Date());
outRechargePrice.setStatus(0);
outRechargePriceService.insertRechargePrice(outRechargePrice);
outRechargePriceService.insertRechargePrice(object);
return ResponseMsgUtil.success("新增成功");
@ -120,33 +128,60 @@ public class OutRechargePriceController {
@RequestMapping(value = "/updatePrice", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "修改金额")
public ResponseData updatePrice(@RequestBody OutRechargePrice outRechargePrice) {
public ResponseData updatePrice(@RequestBody JSONObject object, HttpServletRequest request) {
try {
if (outRechargePrice.getType() == null
|| outRechargePrice.getId() == null
|| outRechargePrice.getPrice() == null
|| outRechargePrice.getRealPrice() == null
|| outRechargePrice.getRechargeType() == null
|| outRechargePrice.getShowType() == null
|| outRechargePrice.getSort() == null
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (object == null ||
object.getString("rechargePrices") == null ||
object.getLong("id") == null ||
object.getBigDecimal("discount") == null ||
object.getString("operatorType") == null ||
object.getString("rechargePlatform") == null ||
object.getInteger("rechargeType") == null ||
object.getString("payType") == null ||
object.getString("rechargeWay") == null ||
object.getString("platformType") == null ||
object.getBigDecimal("integralDiscount") == null
) {
log.error("SecOrganizationController -> updatePrice() error!");
log.error("OutRechargePriceController -> insertPrice() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
OutRechargePrice outRechargePrice1 = outRechargePriceService.findById(outRechargePrice.getId());
OutRechargePrice outRechargePrice = outRechargePriceService.findById(object.getLong("id"));
if (outRechargePrice1 == null ) {
log.error("SecOrganizationController -> updatePrice() error!");
if (outRechargePrice == null) {
log.error("OutRechargePriceController -> updatePrice() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.UPDATE_DATA_ERROR, "");
}
outRechargePrice.setCompanyId(outRechargePrice1.getCompanyId());
outRechargePrice.setStatus(0);
outRechargePrice.setCreateTime(outRechargePrice1.getCreateTime());
outRechargePrice.setPayPrice(outRechargePrice.getRechargePrice().multiply(object.getBigDecimal("discount").divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP)));
outRechargePrice.setRechargeType(object.getInteger("rechargeType"));
outRechargePrice.setOperatorType(object.getInteger("operatorType"));
outRechargePrice.setRechargePlatform(object.getString("rechargePlatform"));
outRechargePrice.setRechargeWay(object.getInteger("rechargeWay"));
outRechargePrice.setUpdateTime(new Date());
outRechargePrice.setStatus(3);
outRechargePriceService.updateRechargePrice(outRechargePrice);
JSONObject postObject = new JSONObject();
postObject.put("payType", object.getString("payType"));
postObject.put("integralDiscount", object.getBigDecimal("integralDiscount"));
postObject.put("productPlatform", object.getString("productPlatform"));
postObject.put("operatorId", userInfoModel.getSecUser().getId());
postObject.put("operatorName", userInfoModel.getSecUser().getLoginName());
postObject.put("sourceId", outRechargePrice.getId());
// 配置支付方式
commonService.configPayType(postObject);
// 配置积分折扣比例
commonService.configPayType(postObject);
// 配置展示平台
commonService.configPlatform(postObject);
return ResponseMsgUtil.success("修改成功");
} catch (Exception e) {
@ -165,7 +200,7 @@ public class OutRechargePriceController {
return ResponseMsgUtil.success(outRechargePrice);
} catch (Exception e) {
log.error("HighUserController --> findByUserId() error!", e);
log.error("OutRechargePriceController --> findById() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@ -176,35 +211,30 @@ public class OutRechargePriceController {
public ResponseData deletePrice(@RequestParam(value = "id", required = true) Long id) {
try {
outRechargePriceService.deletePrice(id);
outRechargePriceService.deletePrice(id);
return ResponseMsgUtil.success("删除成功");
} catch (Exception e) {
log.error("HighUserController --> findByUserId() error!", e);
log.error("OutRechargePriceController --> deletePrice() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/onAndOffShelves", method = RequestMethod.GET)
@RequestMapping(value = "/editPriceStatus", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "上下架")
public ResponseData onAndOffShelves(@RequestParam(value = "id", required = true) Long id) {
@ApiOperation(value = "修改价格状态")
public ResponseData editPriceStatus(@RequestParam(value = "id", required = true) Long id,
@RequestParam(value = "status", required = true) Integer status) {
try {
OutRechargePrice outRechargePrice = outRechargePriceService.findById(id);
if (outRechargePrice.getStatus() == 1) {
outRechargePrice.setStatus(0);
} else {
outRechargePrice.setStatus(1);
}
outRechargePrice.setStatus(status);
outRechargePriceService.updateRechargePrice(outRechargePrice);
return ResponseMsgUtil.success("修改成功");
} catch (Exception e) {
log.error("HighUserController --> findByUserId() error!", e);
log.error("OutRechargePriceController --> editPriceStatus() error!", e);
return ResponseMsgUtil.exception(e);
}
}

@ -40,11 +40,11 @@ public class ImportRechargeOrderListener extends AnalysisEventListener<ExportOut
OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderNo(data.getOrderNo());
if (rechargeOrder.getStatus() != 2) {
data.setErrorMessage("当前订单状态错误。");
errorData.add(data);
return;
}
// if (rechargeOrder.getStatus() != 2) {
// data.setErrorMessage("当前订单状态错误。");
// errorData.add(data);
// return;
// }
if (Objects.equals(data.getStatusName(), "已完成")) {
outRechargeOrderService.finishOrder(rechargeOrder.getId());

@ -30,7 +30,7 @@ public class SysConfig {
private String wxGzSubAppId;
private String wxGzSubMchId;
// 重庆惠兑电子商务有限公司
// 重庆电子商务有限公司
private String HDAppId;
public String getQzNotifyUrl() {

File diff suppressed because one or more lines are too long

@ -53,11 +53,7 @@ public class SendSmsController {
smsMsgId = MessageConfig.HWMSG_ID5;
break;
default :
smsMsgId = "错误";
}
if (HWMSG > 3) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂无当前模版");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂无当前模版");
}
return ResponseMsgUtil.success(messageConfig.sendSmsCodeHw(phone , smsMsgId));

@ -76,248 +76,248 @@ public class CzOrderController {
@Resource
private OutRechargeOrderRecordService rechargeOrderRecordService;
@RequestMapping(value = "/rechargeCallback", method = RequestMethod.POST)
@ApiOperation(value = "话费充值回调")
@ResponseBody
public void rechargeCallback(@RequestBody String reqBodyStr, HttpServletRequest request, HttpServletResponse response) {
try {
JSONObject dataObject = JSONObject.parseObject(reqBodyStr, JSONObject.class);
HighGasOrderRefund highGasOrderRefund = new HighGasOrderRefund();
highGasOrderRefund.setCreateTime(new Date());
highGasOrderRefund.setReturnContent(String.valueOf(dataObject));
highGasOrderRefundMapper.insert(highGasOrderRefund);
if (dataObject.getInteger("status") == 3) {
OutRechargeOrder order;
OutRechargeOrderRecord rechargeOrderRecord = rechargeOrderRecordService.findByOrderNo(dataObject.getString("out_order_id"));
if (rechargeOrderRecord == null) {
// 查询订单
order = outRechargeOrderService.findByOrderNo(dataObject.getString("out_order_id"));
order.setStatus(3);
order.setFinishTime(new Date());
outRechargeOrderService.updateOrder(order);
} else {
// 查询订单
order = outRechargeOrderService.findByOrderId(rechargeOrderRecord.getRechargeOrderId());
order.setStatus(3);
order.setFinishTime(new Date());
outRechargeOrderService.updateOrder(order);
}
new Thread(() -> {
HighUser highUser = highUserService.findByUserId(order.getUserId());
WxMsgConfig.rechargedSuccess(
order.getRechargeName() + "充值成功",
String.valueOf(order.getPayRealPrice()),
order.getOrderNo(),
order.getFinishTime(),
RechargePayType.getNameByType(order.getPayType()),
highUser.getOpenId());
}).start();
} else {
OutRechargeOrderRecord rechargeOrderRecord = rechargeOrderRecordService.findByOrderNo(dataObject.getString("out_order_id"));
if (rechargeOrderRecord == null) {
rechargeOrderRecord = new OutRechargeOrderRecord();
// 查询订单
OutRechargeOrder order = outRechargeOrderService.findByOrderNo(dataObject.getString("out_order_id"));
if (order.getStatus() == 2) {
if (order.getRechargeType() == 1) {
String orderNo = "CZ" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5);
JSONObject object = outRechargeOrderService.getMobile(order.getRechargeContent() , order.getOrderPrice().intValue() , orderNo , order.getRechargeType());
if (object.getInteger("code") != 200) {
order.setRechargeStatus(1);
order.setAbnormalMsg(object.getString("message"));
}
outRechargeOrderService.updateOrder(order);
rechargeOrderRecord.setRechargeOrderId(order.getId());
rechargeOrderRecord.setRechargeOrderNo(orderNo);
rechargeOrderRecord.setCreateTime(new Date());
rechargeOrderRecord.setStatus(1);
rechargeOrderRecordService.insertOrder(rechargeOrderRecord);
}
}
} else {
// 查询订单
OutRechargeOrder order = outRechargeOrderService.findByOrderId(rechargeOrderRecord.getRechargeOrderId());
if (order.getStatus() == 2) {
orderToRefund(order.getId());
order.setStatus(5);
outRechargeOrderService.updateOrder(order);
}
}
}
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=utf-8");
PrintWriter writer= response.getWriter();
writer.write("SUCCESS");
} catch (Exception e) {
log.error("WechatPayController --> wechatNotify() error!", e);
}
}
public Boolean orderToRefund(Long orderId) {
try {
OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId);
// 订单状态 : 1.待支付 2.已支付 3.已完成 4.已取消 5.已退款 6:退款中
if (order.getStatus() != 2) {
log.error("orderToPay error!", "无法退款,订单状态错误!");
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 {
log.error("orderToPay error!", "退款失败");
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) {
log.error("orderToPay error!", "请求超时");
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 {
log.error("orderToPay error!", dataObject.getString("message"));
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, dataObject.getString("message"));
}
}
// 积分退款
if (order.getPayType() == 3) {
if (highUserService.findGoldRepeat(3 , order.getId())) {
highUserService.goldHandle(order.getUserId(), order.getPayRealPrice().multiply(BigDecimal.valueOf(100)).intValue(), 1, 3, order.getId());
}else {
log.error("orderToPay error!", "已有退款记录");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已有退款记录");
}
}
// 银联退款
if (order.getPayType() == 4) {
// 订单退款
JSONObject refund = UnionPayConfig.zwrefund(UnionPayConfig.MER_ID2, UnionPayConfig.TERM_ID2, order.getOrderNo(), order.getPaySerialNo(), order.getPayRealPrice().multiply(new BigDecimal("100")).longValue());
if (!refund.getString("resultcode").equals("W6")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refund.getString("returnmsg"));
}
order.setStatus(5);
order.setRefundTime(new Date());
order.setOutRefundNo(refund.getString("oriwtorderid"));
order.setRefundFee(order.getPayRealPrice());
outRechargeOrderService.updateOrder(order);
}
if (order.getMemDiscountId() != null) {
HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId());
if (rel != null) {
rel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
rel.setUseTime(null);
highDiscountUserRelService.updateDiscountUserRel(rel);
HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(rel.getDiscountAgentCodeId());
code.setStatus(2);
highDiscountAgentCodeService.updateCode(code);
}
}
new Thread(() -> {
HighUser highUser = highUserService.findByUserId(order.getUserId());
WxMsgConfig.rechargedFail(
"订单号:" + order.getOrderNo() + "-" + order.getRechargeName(),
String.valueOf(order.getPayRealPrice()),
highUser.getOpenId());
}).start();
return true;
} catch (Exception e) {
log.error("HighOrderController --> getUserOrderList() error!", e);
return false;
}
}
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();
}
}
// @RequestMapping(value = "/rechargeCallback", method = RequestMethod.POST)
// @ApiOperation(value = "话费充值回调")
// @ResponseBody
// public void rechargeCallback(@RequestBody String reqBodyStr, HttpServletRequest request, HttpServletResponse response) {
// try {
//
//
// JSONObject dataObject = JSONObject.parseObject(reqBodyStr, JSONObject.class);
//
// HighGasOrderRefund highGasOrderRefund = new HighGasOrderRefund();
// highGasOrderRefund.setCreateTime(new Date());
// highGasOrderRefund.setReturnContent(String.valueOf(dataObject));
//
// highGasOrderRefundMapper.insert(highGasOrderRefund);
//
// if (dataObject.getInteger("status") == 3) {
// OutRechargeOrder order;
// OutRechargeOrderRecord rechargeOrderRecord = rechargeOrderRecordService.findByOrderNo(dataObject.getString("out_order_id"));
// if (rechargeOrderRecord == null) {
// // 查询订单
// order = outRechargeOrderService.findByOrderNo(dataObject.getString("out_order_id"));
// order.setStatus(3);
// order.setFinishTime(new Date());
// outRechargeOrderService.updateOrder(order);
// } else {
// // 查询订单
// order = outRechargeOrderService.findByOrderId(rechargeOrderRecord.getRechargeOrderId());
// order.setStatus(3);
// order.setFinishTime(new Date());
// outRechargeOrderService.updateOrder(order);
// }
//
// new Thread(() -> {
// HighUser highUser = highUserService.findByUserId(order.getUserId());
// WxMsgConfig.rechargedSuccess(
// order.getRechargeName() + "充值成功",
// String.valueOf(order.getPayRealPrice()),
// order.getOrderNo(),
// order.getFinishTime(),
// RechargePayType.getNameByType(order.getPayType()),
// highUser.getOpenId());
// }).start();
//
// } else {
// OutRechargeOrderRecord rechargeOrderRecord = rechargeOrderRecordService.findByOrderNo(dataObject.getString("out_order_id"));
// if (rechargeOrderRecord == null) {
// rechargeOrderRecord = new OutRechargeOrderRecord();
// // 查询订单
// OutRechargeOrder order = outRechargeOrderService.findByOrderNo(dataObject.getString("out_order_id"));
// if (order.getStatus() == 2) {
// if (order.getRechargeType() == 1) {
// String orderNo = "CZ" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5);
// JSONObject object = outRechargeOrderService.getMobile(order.getRechargeContent() , order.getOrderPrice().intValue() , orderNo , order.getRechargeType());
// if (object.getInteger("code") != 200) {
// order.setRechargeStatus(1);
// order.setAbnormalMsg(object.getString("message"));
// }
// outRechargeOrderService.updateOrder(order);
// rechargeOrderRecord.setRechargeOrderId(order.getId());
// rechargeOrderRecord.setRechargeOrderNo(orderNo);
// rechargeOrderRecord.setCreateTime(new Date());
// rechargeOrderRecord.setStatus(1);
// rechargeOrderRecordService.insertOrder(rechargeOrderRecord);
// }
// }
//
// } else {
// // 查询订单
// OutRechargeOrder order = outRechargeOrderService.findByOrderId(rechargeOrderRecord.getRechargeOrderId());
// if (order.getStatus() == 2) {
// orderToRefund(order.getId());
// order.setStatus(5);
// outRechargeOrderService.updateOrder(order);
// }
// }
//
// }
//
// response.setCharacterEncoding("UTF-8");
// response.setContentType("text/html;charset=utf-8");
// PrintWriter writer= response.getWriter();
// writer.write("SUCCESS");
//
//
// } catch (Exception e) {
// log.error("WechatPayController --> wechatNotify() error!", e);
// }
// }
//
//
// public Boolean orderToRefund(Long orderId) {
// try {
//
// OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId);
//
//
// // 订单状态 : 1.待支付 2.已支付 3.已完成 4.已取消 5.已退款 6:退款中
// if (order.getStatus() != 2) {
// log.error("orderToPay error!", "无法退款,订单状态错误!");
// 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 {
//// log.error("orderToPay error!", "退款失败");
//// 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) {
// log.error("orderToPay error!", "请求超时");
// 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 {
// log.error("orderToPay error!", dataObject.getString("message"));
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, dataObject.getString("message"));
// }
// }
//
// // 积分退款
// if (order.getPayType() == 3) {
//
// if (highUserService.findGoldRepeat(3 , order.getId())) {
// highUserService.goldHandle(order.getUserId(), order.getPayRealPrice().multiply(BigDecimal.valueOf(100)).intValue(), 1, 3, order.getId());
// }else {
// log.error("orderToPay error!", "已有退款记录");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已有退款记录");
// }
//
// }
//
// // 银联退款
// if (order.getPayType() == 4) {
// // 订单退款
// JSONObject refund = UnionPayConfig.zwrefund(UnionPayConfig.MER_ID2, UnionPayConfig.TERM_ID2, order.getOrderNo(), order.getPaySerialNo(), order.getPayRealPrice().multiply(new BigDecimal("100")).longValue());
// if (!refund.getString("resultcode").equals("W6")) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refund.getString("returnmsg"));
// }
//
// order.setStatus(5);
// order.setRefundTime(new Date());
// order.setOutRefundNo(refund.getString("oriwtorderid"));
// order.setRefundFee(order.getPayRealPrice());
// outRechargeOrderService.updateOrder(order);
// }
//
// if (order.getMemDiscountId() != null) {
// HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId());
// if (rel != null) {
// rel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
// rel.setUseTime(null);
// highDiscountUserRelService.updateDiscountUserRel(rel);
//
// HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(rel.getDiscountAgentCodeId());
// code.setStatus(2);
// highDiscountAgentCodeService.updateCode(code);
// }
// }
//
// new Thread(() -> {
// HighUser highUser = highUserService.findByUserId(order.getUserId());
// WxMsgConfig.rechargedFail(
// "订单号:" + order.getOrderNo() + "-" + order.getRechargeName(),
// String.valueOf(order.getPayRealPrice()),
// highUser.getOpenId());
// }).start();
//
// return true;
// } catch (Exception e) {
// log.error("HighOrderController --> getUserOrderList() error!", e);
// return false;
// }
// }
//
//
// 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();
// }
// }
}

@ -383,27 +383,27 @@ public class UnionPayController {
// 转换成JSON格式
JSONObject body = JSONObject.parseObject(paramsStr.substring(0, paramsStr.length() - 1));
if (StringUtils.isNotBlank(body.getString("tradetrace"))) {
OutRechargeOrder order = outRechargeOrderService.findByOrderNo(body.getString("tradetrace"));
if (order == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息");
}
order.setPaySerialNo(body.getString("wtorderid")); // 支付流水号
order.setPayRealPrice(order.getPayPrice()); // 实付金额
order.setStatus(2);
order.setPayType(4);
order.setPayTime(new Date()); // 支付时间
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.updateOrder(order);
}
// if (StringUtils.isNotBlank(body.getString("tradetrace"))) {
// OutRechargeOrder order = outRechargeOrderService.findByOrderNo(body.getString("tradetrace"));
// if (order == null) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息");
// }
//
// order.setPaySerialNo(body.getString("wtorderid")); // 支付流水号
// order.setPayRealPrice(order.getPayPrice()); // 实付金额
//
// order.setStatus(2);
// order.setPayType(4);
// order.setPayTime(new Date()); // 支付时间
// 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.updateOrder(order);
// }
}
BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream());

@ -80,7 +80,7 @@ public class OutRechargePrice implements Serializable {
private Date updateTime;
/**
* 0删除 1上线 2已售空
* 0删除 1上线 2已售空 3:编辑中
*/
private Integer status;
@ -310,4 +310,4 @@ public class OutRechargePrice implements Serializable {
sb.append("]");
return sb.toString();
}
}
}

@ -239,4 +239,34 @@ public interface CommonService {
*/
JSONObject findByLatAndLng( String lng , String lat) throws Exception;
/**
* @Author Sum1Dream
* @name configPayType.java
* @Description // 配置支付方式
* @Date 15:00 2022/5/12
* @Param [com.alibaba.fastjson.JSONObject]
* @return void
*/
void configPayType(JSONObject object);
/**
* @Author Sum1Dream
* @name configIntegralDiscount.java
* @Description // 配置积分折扣比例
* @Date 15:00 2022/5/12
* @Param [com.alibaba.fastjson.JSONObject]
* @return void
*/
void configIntegralDiscount(JSONObject object);
/**
* @Author Sum1Dream
* @name configPlatform.java
* @Description // 配置展示平台
* @Date 15:00 2022/5/12
* @Param [com.alibaba.fastjson.JSONObject]
* @return void
*/
void configPlatform(JSONObject object);
}

@ -1,5 +1,6 @@
package com.hai.service;
import com.alibaba.fastjson.JSONObject;
import com.hai.entity.OutRechargePrice;
import java.util.List;
@ -14,7 +15,7 @@ public interface OutRechargePriceService {
* @Param [map]
* @return java.util.List<com.hai.entity.OutRechargePrice>
**/
List<OutRechargePrice> getListRechargePrice(Map<String , String> map);
List<OutRechargePrice> getListRechargePrice(Map<String , Object> map);
/**
* @Author Sum1Dream
@ -41,7 +42,7 @@ public interface OutRechargePriceService {
* @Param [outRechargePrice]
* @return void
**/
void insertRechargePrice(OutRechargePrice outRechargePrice);
void insertRechargePrice(JSONObject object);
/**
* @Author Sum1Dream

@ -92,11 +92,11 @@ public class HighRefundAuditServiceImpl implements HighRefundAuditService {
if (highRefundAudit.getRefundSource() == 1) {
OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(highRefundAudit.getSourceOrderNo());
highRefundAudit.setRefundPrice(outRechargeOrder.getPayPrice());
// highRefundAudit.setRefundPrice(outRechargeOrder.getPayPrice());
highRefundAudit.setPayType(outRechargeOrder.getPayType());
highRefundAudit.setPayTime(outRechargeOrder.getPayTime());
highRefundAudit.setExt1(String.valueOf(outRechargeOrder.getId()));
outRechargeOrder.setStatus(6);
// outRechargeOrder.setStatus(6);
outRechargeOrderService.updateOrder(outRechargeOrder);
} else {
HighOrder highOrder = highOrderService.getOrderByOrderNo(highRefundAudit.getSourceOrderNo());

@ -78,25 +78,14 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
criteria.andUserIdEqualTo(MapUtils.getLong(map, "userId"));
}
if (MapUtils.getInteger(map, "status") != null) {
criteria.andStatusEqualTo(MapUtils.getInteger(map, "status"));
}
if (MapUtils.getInteger(map, "payType") != null) {
criteria.andPayTypeEqualTo(MapUtils.getInteger(map, "payType"));
}
if (MapUtils.getInteger(map, "code") != null) {
criteria.andIdentificationCodeEqualTo(MapUtils.getLong(map, "code"));
}
if (MapUtils.getString(map, "orderNo") != null) {
criteria.andOrderNoLike("%" + MapUtils.getString(map, "orderNo") + "%");
}
if (MapUtils.getString(map, "idCard") != null) {
criteria.andIdCardLike("%" + MapUtils.getString(map, "idCard") + "%");
}
if (MapUtils.getString(map, "userPhone") != null) {
criteria.andUserPhoneEqualTo(MapUtils.getString(map, "userPhone"));
}
@ -104,17 +93,11 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
if (MapUtils.getString(map, "rechargeContent") != null) {
criteria.andRechargeContentLike("%" + MapUtils.getString(map, "rechargeContent") + "%");
}
if (MapUtils.getString(map, "rechargeType") != null) {
criteria.andRechargeTypeEqualTo(MapUtils.getInteger(map, "rechargeType"));
}
if (MapUtils.getString(map, "phone") != null) {
criteria.andUserPhoneEqualTo(MapUtils.getString(map, "phone"));
}
if (MapUtils.getString(map, "rechargeModel") != null) {
criteria.andRechargeModelEqualTo(Integer.valueOf(MapUtils.getString(map, "rechargeModel")));
}
if (StringUtils.isNotBlank(map.get("payTimeS")) && StringUtils.isNotBlank(map.get("payTimeE"))) {
criteria.andPayTimeBetween(
@ -170,11 +153,11 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
@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());
}
// if (list.getStatus() == 3) {
// outRechargeOrderMapper.updateByPrimaryKey(list);
// } else if (list.getStatus() == 6) {
// rechargeOrderToRefund(list.getId());
// }
}
}
@ -183,25 +166,25 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
@Transactional(propagation= Propagation.REQUIRES_NEW)
public void cancelOrder(Long orderId) {
OutRechargeOrder order = findByOrderId(orderId);
if (order != null && order.getStatus() == 1) {
order.setStatus(4); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已取消 5.已退款
order.setCancelTime(new Date());
if (order.getMemDiscountId() != null) {
HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId());
if (rel != null) {
rel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
rel.setUseTime(null);
highDiscountUserRelService.updateDiscountUserRel(rel);
HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(rel.getDiscountAgentCodeId());
code.setStatus(2);
highDiscountAgentCodeService.updateCode(code);
}
}
updateOrder(order);
}
// if (order != null && order.getStatus() == 1) {
// order.setStatus(4); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已取消 5.已退款
// order.setCancelTime(new Date());
//
// if (order.getMemDiscountId() != null) {
// HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId());
// if (rel != null) {
// rel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
// rel.setUseTime(null);
// highDiscountUserRelService.updateDiscountUserRel(rel);
//
// HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(rel.getDiscountAgentCodeId());
// code.setStatus(2);
// highDiscountAgentCodeService.updateCode(code);
// }
// }
//
// updateOrder(order);
// }
}
@ -210,7 +193,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
public void finishOrder(Long orderId) {
OutRechargeOrder order = findByOrderId(orderId);
if (order != null) {
order.setStatus(3); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已取消 5.已退款
// order.setStatus(3); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已取消 5.已退款
order.setFinishTime(new Date());
updateOrder(order);
}
@ -242,7 +225,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
@Override
public Long CountOrder() {
OutRechargeOrderExample example = new OutRechargeOrderExample();
example.createCriteria().andStatusEqualTo(2);
// example.createCriteria().andStatusEqualTo(2);
return outRechargeOrderMapper.countByExample(example);
}
@ -336,51 +319,51 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
}
String goodsDesc = "充值话费";
String tranDesc = order.getRechargeContent() + "充值" + order.getPayPrice() +"元话费";
// String tranDesc = order.getRechargeContent() + "充值" + order.getPayPrice() +"元话费";
String instCode = "11101290";
String businessType = "hisen_consume";
// 工会卡支付
JSONObject consumption = HuiLianTongUnionCardConfig.consumption(order.getOrderNo(), userCard.getCardNo(), order.getPayPrice(), businessType, instCode, goodsDesc, tranDesc);
System.out.println("工会卡支付响应参数" + consumption.toJSONString());
// JSONObject consumption = HuiLianTongUnionCardConfig.consumption(order.getOrderNo(), userCard.getCardNo(), order.getPayPrice(), businessType, instCode, goodsDesc, tranDesc);
// System.out.println("工会卡支付响应参数" + consumption.toJSONString());
Map<String,Object> dataMap = new HashMap<>();
dataMap.put("orderNo", order.getOrderNo());
dataMap.put("cardType", "ghk");
dataMap.put("cardNo", userCard.getCardNo());
dataMap.put("checkPassword", "N");
dataMap.put("tranAmount", order.getPayPrice());
// dataMap.put("tranAmount", order.getPayPrice());
dataMap.put("tranChannel", "HiSen");
dataMap.put("businessType", businessType);
dataMap.put("instCode", instCode);
dataMap.put("goodsDesc", goodsDesc);
dataMap.put("tranDesc", tranDesc);
// dataMap.put("tranDesc", tranDesc);
HighGasOrderPush payPush = new HighGasOrderPush();
payPush.setType(OrderPushType.type5.getType());
payPush.setOrderNo(order.getOrderNo());
payPush.setCreateTime(new Date());
payPush.setCode(consumption.getString("respCode"));
payPush.setRequestContent(JSON.toJSONString(dataMap));
payPush.setReturnContent(consumption.toJSONString());
// payPush.setCode(consumption.getString("respCode"));
// payPush.setRequestContent(JSON.toJSONString(dataMap));
// payPush.setReturnContent(consumption.toJSONString());
highGasOrderPushMapper.insert(payPush);
if(!consumption.getString("respCode").equals("0000")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumption.getString("respMessage"));
}
JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(consumption.getString("data"));
if (!consumptionResult.getBoolean("success")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumptionResult.getString("message"));
}
order.setPaySerialNo(consumptionResult.getString("orderId")); // 支付流水号
order.setPayRealPrice(order.getPayPrice()); // 实付金额
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"));
}
}
order.setStatus(2);
// if(!consumption.getString("respCode").equals("0000")) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumption.getString("respMessage"));
// }
// JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(consumption.getString("data"));
// if (!consumptionResult.getBoolean("success")) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumptionResult.getString("message"));
// }
// order.setPaySerialNo(consumptionResult.getString("orderId")); // 支付流水号
// order.setPayRealPrice(order.getPayPrice()); // 实付金额
// 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"));
// }
// }
// order.setStatus(2);
order.setPayType(2);
order.setPayTime(new Date()); // 支付时间
updateOrder(order);
@ -389,21 +372,21 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
public void goldPayOrder(Long userId, Long orderId) throws Exception {
OutRechargeOrder order = findByOrderId(orderId);
if(order == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, "");
}
// 查询用户
HighUser highUser = highUserService.findByUserId(userId);
// 金币 1:100
Integer goldNum = new BigDecimal(order.getPayPrice().toString()).multiply(new BigDecimal("100")).intValue();
highUserService.goldHandle(userId, goldNum, 2, 2, order.getId());
order.setPayRealPrice(order.getPayPrice()); // 实付金额
order.setStatus(2);
order.setPayType(3);
order.setPayTime(new Date()); // 支付时间
outRechargeOrderService.updateOrder(order);
// OutRechargeOrder order = findByOrderId(orderId);
// if(order == null) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_FOUND_ORDER, "");
// }
// // 查询用户
// HighUser highUser = highUserService.findByUserId(userId);
//
// // 金币 1:100
// Integer goldNum = new BigDecimal(order.getPayPrice().toString()).multiply(new BigDecimal("100")).intValue();
// highUserService.goldHandle(userId, goldNum, 2, 2, order.getId());
// order.setPayRealPrice(order.getPayPrice()); // 实付金额
// order.setStatus(2);
// order.setPayType(3);
// order.setPayTime(new Date()); // 支付时间
// outRechargeOrderService.updateOrder(order);
}
@Override
@ -444,107 +427,107 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
@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) {
if (highUserService.findGoldRepeat(3 , order.getId())) {
highUserService.goldHandle(order.getUserId(), order.getPayRealPrice().multiply(BigDecimal.valueOf(100)).intValue(), 1, 3, order.getId());
}else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已有退款记录");
}
order.setStatus(5);
order.setRefundTime(new Date());
order.setOutRefundNo("HFR"+new Date().getTime() );
order.setRefundFee(order.getPayRealPrice());
outRechargeOrderService.updateOrder(order);
}
// 银联退款
if (order.getPayType() == 4) {
// 订单退款
JSONObject refund = UnionPayConfig.zwrefund(UnionPayConfig.MER_ID2, UnionPayConfig.TERM_ID2, order.getOrderNo(), order.getPaySerialNo(), order.getPayRealPrice().multiply(new BigDecimal("100")).longValue());
if (!refund.getString("resultcode").equals("W6")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refund.getString("returnmsg"));
}
order.setStatus(5);
order.setRefundTime(new Date());
order.setOutRefundNo(refund.getString("oriwtorderid"));
order.setRefundFee(order.getPayRealPrice());
outRechargeOrderService.updateOrder(order);
}
if (order.getMemDiscountId() != null) {
HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId());
if (rel != null) {
rel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
rel.setUseTime(null);
highDiscountUserRelService.updateDiscountUserRel(rel);
HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(rel.getDiscountAgentCodeId());
code.setStatus(2);
highDiscountAgentCodeService.updateCode(code);
}
}
// 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) {
// if (highUserService.findGoldRepeat(3 , order.getId())) {
// highUserService.goldHandle(order.getUserId(), order.getPayRealPrice().multiply(BigDecimal.valueOf(100)).intValue(), 1, 3, order.getId());
// }else {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已有退款记录");
// }
// order.setStatus(5);
// order.setRefundTime(new Date());
// order.setOutRefundNo("HFR"+new Date().getTime() );
// order.setRefundFee(order.getPayRealPrice());
// outRechargeOrderService.updateOrder(order);
// }
//
// // 银联退款
// if (order.getPayType() == 4) {
// // 订单退款
// JSONObject refund = UnionPayConfig.zwrefund(UnionPayConfig.MER_ID2, UnionPayConfig.TERM_ID2, order.getOrderNo(), order.getPaySerialNo(), order.getPayRealPrice().multiply(new BigDecimal("100")).longValue());
// if (!refund.getString("resultcode").equals("W6")) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refund.getString("returnmsg"));
// }
//
// order.setStatus(5);
// order.setRefundTime(new Date());
// order.setOutRefundNo(refund.getString("oriwtorderid"));
// order.setRefundFee(order.getPayRealPrice());
// outRechargeOrderService.updateOrder(order);
// }
//
// if (order.getMemDiscountId() != null) {
// HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId());
// if (rel != null) {
// rel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用
// rel.setUseTime(null);
// highDiscountUserRelService.updateDiscountUserRel(rel);
//
// HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(rel.getDiscountAgentCodeId());
// code.setStatus(2);
// highDiscountAgentCodeService.updateCode(code);
// }
// }
}

@ -1,13 +1,22 @@
package com.hai.service.impl;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.hai.dao.OutRechargePriceMapper;
import com.hai.entity.*;
import com.hai.service.CommonService;
import com.hai.service.OutRechargePriceService;
import io.swagger.models.auth.In;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Date;
import java.util.List;
import java.util.Map;
@ -17,26 +26,30 @@ public class OutRechargePriceServiceImpl implements OutRechargePriceService {
@Resource
private OutRechargePriceMapper outRechargePriceMapper;
@Resource
private CommonService commonService;
@Override
public List<OutRechargePrice> getListRechargePrice(Map<String , String> map) {
public List<OutRechargePrice> getListRechargePrice(Map<String , Object> map) {
OutRechargePriceExample example = new OutRechargePriceExample();
OutRechargePriceExample.Criteria criteria = example.createCriteria();
if (StringUtils.isNotBlank(map.get("type"))) {
criteria.andTypeEqualTo(Integer.valueOf(map.get("type")));
if (MapUtils.getLong(map , "companyId") != null) {
criteria.andCompanyIdEqualTo(MapUtils.getLong(map , "companyId"));
}
if (StringUtils.isNotBlank(map.get("showType"))) {
criteria.andShowTypeEqualTo(Integer.valueOf(map.get("showType")));
if (MapUtils.getLong(map , "rechargePlatform") != null) {
criteria.andRechargePlatformLike("%-" +MapUtils.getLong(map , "rechargePlatform") + "-%");
}
if (StringUtils.isNotBlank(map.get("companyId"))) {
criteria.andCompanyIdEqualTo(Long.valueOf(map.get("companyId")));
if (MapUtils.getLong(map , "rechargeType") != null) {
criteria.andRechargeTypeEqualTo(MapUtils.getInteger(map , "rechargeType"));
}
if (StringUtils.isNotBlank(map.get("rechargeType"))) {
criteria.andRechargeTypeEqualTo(Integer.valueOf(map.get("rechargeType")));
if (MapUtils.getLong(map , "rechargeType") != null) {
criteria.andRechargeTypeEqualTo(MapUtils.getInteger(map , "rechargeType"));
}
example.setOrderByClause("type asc");
example.setOrderByClause("recharge_price asc");
return outRechargePriceMapper.selectByExample(example);
}
@Override
@ -46,12 +59,6 @@ public class OutRechargePriceServiceImpl implements OutRechargePriceService {
criteria.andStatusNotEqualTo(0);
if (StringUtils.isNotBlank(map.get("type"))) {
criteria.andTypeEqualTo(Integer.valueOf(map.get("type")));
}
if (StringUtils.isNotBlank(map.get("showType"))) {
criteria.andShowTypeEqualTo(Integer.valueOf(map.get("showType")));
}
if (StringUtils.isNotBlank(map.get("companyId"))) {
criteria.andCompanyIdEqualTo(Long.valueOf(map.get("companyId")));
}
@ -70,8 +77,50 @@ public class OutRechargePriceServiceImpl implements OutRechargePriceService {
}
@Override
public void insertRechargePrice(OutRechargePrice outRechargePrice) {
outRechargePriceMapper.insert(outRechargePrice);
@Transactional(propagation= Propagation.REQUIRES_NEW)
public void insertRechargePrice(JSONObject object) {
// 转换金额数组
JSONArray priceArray = object.getJSONArray("rechargePrices");
// 充值金额
OutRechargePrice outRechargePrice;
for (Object price : priceArray) {
SecDictionary dictionary = commonService.mappingSysCode("RECHARGE_AMOUNT", String.valueOf(price));
BigDecimal priceBd = new BigDecimal(dictionary.getCodeName());
outRechargePrice = new OutRechargePrice();
outRechargePrice.setRechargePrice(priceBd);
outRechargePrice.setPayPrice(priceBd.multiply(object.getBigDecimal("discount").divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP)));
outRechargePrice.setDiscount(object.getBigDecimal("discount"));
outRechargePrice.setRechargeType(object.getInteger("rechargeType"));
outRechargePrice.setOperatorType(object.getInteger("operatorType"));
outRechargePrice.setRechargePlatform("-" + StringUtils.join(object.getJSONArray("rechargePlatform") , "-") + "-");
outRechargePrice.setRechargeWay(object.getInteger("rechargeWay"));
outRechargePrice.setCompanyId(object.getLong("companyId"));
outRechargePrice.setCreateTime(new Date());
outRechargePrice.setUpdateTime(new Date());
outRechargePrice.setStatus(3);
outRechargePrice.setSort(1);
outRechargePriceMapper.insert(outRechargePrice);
JSONObject postObject = new JSONObject();
postObject.put("payType", object.getJSONArray("payType"));
postObject.put("integralDiscount", object.getBigDecimal("integralDiscount"));
postObject.put("productPlatform", object.getJSONArray("productPlatform"));
postObject.put("operatorId", object.getLong("operatorId"));
postObject.put("operatorName", object.getString("operatorName"));
postObject.put("sourceId", outRechargePrice.getId());
// 配置支付方式
commonService.configPayType(postObject);
// 配置积分折扣比例
commonService.configIntegralDiscount(postObject);
// 配置展示平台
commonService.configPlatform(postObject);
}
}
@Override

@ -65,28 +65,28 @@ public class RechargeOrderServiceImpl implements PayService {
if (payType.equals("WechatPay")) {
// 查询订单信息
OutRechargeOrder order = outRechargeOrderService.findByOrderNo(map.get("out_trade_no"));
if (order != null && order.getStatus() == 1) {
order.setPaySerialNo(map.get("transaction_id")); // 支付流水号
order.setPayRealPrice(new BigDecimal(map.get("total_fee")).divide(new BigDecimal("100"))); // 实付金额
order.setPayTime(new Date()); // 支付时间
order.setStatus(2); // 订单状态 : 1.待支付 2.已支付 3.已完成 4.已取消 5.已退款
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.updateOrder(order);
// 推送订单记录
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 != null && order.getStatus() == 1) {
// order.setPaySerialNo(map.get("transaction_id")); // 支付流水号
// order.setPayRealPrice(new BigDecimal(map.get("total_fee")).divide(new BigDecimal("100"))); // 实付金额
// order.setPayTime(new Date()); // 支付时间
// order.setStatus(2); // 订单状态 : 1.待支付 2.已支付 3.已完成 4.已取消 5.已退款
// 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.updateOrder(order);
// // 推送订单记录
// 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);
// }
}
}

Loading…
Cancel
Save