合并代码

dev-discount
袁野 3 years ago
parent cb13ed8020
commit a1edf5d198
  1. 2
      hai-bweb/src/main/java/com/bweb/controller/HighTestController.java
  2. 306
      hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java
  3. 164
      hai-bweb/src/main/java/com/bweb/controller/OutRechargePriceController.java
  4. 201
      hai-bweb/src/main/java/com/bweb/controller/TelApiController.java
  5. 2
      hai-cweb/src/main/java/com/cweb/config/AuthConfig.java
  6. 912
      hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java
  7. 45
      hai-cweb/src/main/java/com/cweb/controller/OutRechargePriceController.java
  8. 584
      hai-cweb/src/main/java/com/cweb/controller/pay/CzOrderController.java
  9. 13
      hai-cweb/src/main/java/com/cweb/controller/pay/WechatPayController.java
  10. 32
      hai-service/src/main/java/com/hai/common/utils/WxUtils.java
  11. 77
      hai-service/src/main/java/com/hai/config/CommonSysConfig.java
  12. 147
      hai-service/src/main/java/com/hai/config/RechargeConfig.java
  13. 80
      hai-service/src/main/java/com/hai/config/TelConfig.java
  14. 2
      hai-service/src/main/java/com/hai/dao/OutRechargeOrderRecordMapper.java
  15. 2
      hai-service/src/main/java/com/hai/dao/OutRechargeOrderRecordMapperExt.java
  16. 2
      hai-service/src/main/java/com/hai/dao/OutRechargeOrderRecordSqlProvider.java
  17. 45
      hai-service/src/main/java/com/hai/dao/OutRechargePriceMapperExt.java
  18. 4
      hai-service/src/main/java/com/hai/entity/BsOperationLog.java
  19. 2
      hai-service/src/main/java/com/hai/entity/OutRechargeOrderRecord.java
  20. 2
      hai-service/src/main/java/com/hai/entity/OutRechargeOrderRecordExample.java
  21. 2
      hai-service/src/main/java/com/hai/entity/OutRechargePrice.java
  22. 9
      hai-service/src/main/java/com/hai/enum_type/RechargePayType.java
  23. 40
      hai-service/src/main/java/com/hai/model/OutRechargePriceModel.java
  24. 48
      hai-service/src/main/java/com/hai/service/BsConfigService.java
  25. 36
      hai-service/src/main/java/com/hai/service/BsOperationLogService.java
  26. 45
      hai-service/src/main/java/com/hai/service/BsRequestRecordService.java
  27. 55
      hai-service/src/main/java/com/hai/service/HighTestService.java
  28. 18
      hai-service/src/main/java/com/hai/service/OutRechargeChildOrderService.java
  29. 41
      hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java
  30. 27
      hai-service/src/main/java/com/hai/service/OutRechargePriceService.java
  31. 107
      hai-service/src/main/java/com/hai/service/impl/BsConfigServiceImpl.java
  32. 30
      hai-service/src/main/java/com/hai/service/impl/BsOperationLogServiceImpl.java
  33. 42
      hai-service/src/main/java/com/hai/service/impl/BsRequestRecordServiceImpl.java
  34. 2
      hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java
  35. 176
      hai-service/src/main/java/com/hai/service/impl/HighTestServiceImpl.java
  36. 64
      hai-service/src/main/java/com/hai/service/impl/OutRechargeChildOrderServiceImpl.java
  37. 60
      hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderRecordServiceImpl.java
  38. 387
      hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java
  39. 118
      hai-service/src/main/java/com/hai/service/impl/OutRechargePriceServiceImpl.java
  40. 1
      hai-service/src/main/java/com/hai/service/pay/impl/RechargeOrderServiceImpl.java
  41. 16
      hai-service/src/main/resources/dev/commonConfig.properties
  42. 12
      hai-service/src/main/resources/prod/commonConfig.properties

File diff suppressed because one or more lines are too long

@ -3,12 +3,10 @@ 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.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;
@ -16,21 +14,17 @@ 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.DateUtil;
import com.hai.common.utils.IDGenerator;
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.entity.OutRechargeOrderRecord; import com.hai.entity.OutRechargeOrderRecord;
import com.hai.model.*; import com.hai.model.*;
import com.hai.service.HighRefundAuditService; import com.hai.service.HighRefundAuditService;
import com.hai.service.HighUserService; import com.hai.service.HighUserService;
import com.hai.service.OutRechargeOrderRecordService; import com.hai.service.OutRechargeChildOrderService;
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;
@ -73,7 +67,7 @@ public class OutRechargeOrderController {
private HighUserService highUserService; private HighUserService highUserService;
@Resource @Resource
private OutRechargeOrderRecordService rechargeOrderRecordService; private OutRechargeChildOrderService rechargeOrderRecordService;
@RequestMapping(value = "/getOrderById", method = RequestMethod.GET) @RequestMapping(value = "/getOrderById", method = RequestMethod.GET)
@ -90,74 +84,29 @@ public class OutRechargeOrderController {
} }
} }
@RequestMapping(value = "/cancelOrder", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "取消订单")
public ResponseData cancelOrder(@RequestParam(name = "orderId", required = true) Long orderId) {
try {
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, "");
// }
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("HighOrderController --> cancelOrder() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/finishOrder", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "完成充值")
public ResponseData finishOrder(@RequestParam(name = "orderId", required = true) Long orderId) {
try {
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, "");
// }
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("HighOrderController --> cancelOrder() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/importRechargeOrder",method = RequestMethod.POST) // @RequestMapping(value="/importRechargeOrder",method = RequestMethod.POST)
@ResponseBody // @ResponseBody
@ApiOperation(value = "导入话费充值订单") // @ApiOperation(value = "导入话费充值订单")
public ResponseData importRechargeOrder( @RequestParam(value = "file" , required = true) MultipartFile files, // public ResponseData importRechargeOrder( @RequestParam(value = "file" , required = true) MultipartFile files,
HttpServletRequest request) { // HttpServletRequest request) {
try { // try {
//
ImportRechargeOrderListener importRechargeOrderListener = new ImportRechargeOrderListener(); // ImportRechargeOrderListener importRechargeOrderListener = new ImportRechargeOrderListener();
importRechargeOrderListener.initData(outRechargeOrderService); // importRechargeOrderListener.initData(outRechargeOrderService);
EasyExcel.read(files.getInputStream(), ExportOutRechargeOrder.class, importRechargeOrderListener).sheet().doRead(); // EasyExcel.read(files.getInputStream(), ExportOutRechargeOrder.class, importRechargeOrderListener).sheet().doRead();
//
Map<String, Object> map = new HashMap<>(); // Map<String, Object> map = new HashMap<>();
map.put("errorData", importRechargeOrderListener.getErrorData()); // map.put("errorData", importRechargeOrderListener.getErrorData());
map.put("errorTotal", importRechargeOrderListener.getErrorData().size()); // map.put("errorTotal", importRechargeOrderListener.getErrorData().size());
//
return ResponseMsgUtil.success(map); // return ResponseMsgUtil.success(map);
//
} catch (Exception e) { // } catch (Exception e) {
log.error("HighCouponController -> importStock() error!",e); // log.error("HighCouponController -> importStock() error!",e);
return ResponseMsgUtil.exception(e); // return ResponseMsgUtil.exception(e);
} // }
} // }
@RequestMapping(value = "/getOrderList", method = RequestMethod.GET) @RequestMapping(value = "/getOrderList", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ -226,19 +175,6 @@ public class OutRechargeOrderController {
} }
} }
@RequestMapping(value = "/countOrder", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "完成充值")
public ResponseData countOrder() {
try {
return ResponseMsgUtil.success(outRechargeOrderService.CountOrder());
} catch (Exception e) {
log.error("HighOrderController --> cancelOrder() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/exportOrderList", method = RequestMethod.GET) @RequestMapping(value = "/exportOrderList", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ -284,157 +220,6 @@ public class OutRechargeOrderController {
} }
} }
@RequestMapping(value = "/orderToRefund", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "订单退款")
public ResponseData orderToRefund(@RequestParam(name = "orderId", required = false) Long orderId,
HttpServletRequest request) {
try {
OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId);
HighRefundAudit highRefundAudit = highRefundAuditService.findByOrderNo(order.getOrderNo());
if (order == null) {
log.error("orderToPay error!", "未找到充值订单");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到充值订单");
}
// 订单状态 : 1.待支付 2.已支付 3.已完成 4.已取消 5.已退款 6:退款中
// if (order.getStatus() != 6) {
// 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);
// 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 (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"));
//
// 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 (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());
highRefundAudit.setStatus(1);
highRefundAuditService.updateRefundAudit(highRefundAudit);
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());
highRefundAudit.setStatus(1);
highRefundAuditService.updateRefundAudit(highRefundAudit);
outRechargeOrderService.updateOrder(order);
}
return ResponseMsgUtil.success("退款成功");
} catch (Exception e) {
log.error("HighOrderController --> getUserOrderList() error!", e);
return ResponseMsgUtil.exception(e);
}
}
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 = "/getOrderCountList", method = RequestMethod.GET) @RequestMapping(value = "/getOrderCountList", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "查询时间订单统计") @ApiOperation(value = "查询时间订单统计")
@ -576,47 +361,4 @@ public class OutRechargeOrderController {
} }
} }
@RequestMapping(value = "/getMobileRechargeByOrderId", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "话费再次充值充值")
public ResponseData getMobileRechargeByOrderId(
@RequestParam(name = "orderId", required = true) Long orderId) {
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());
// }
// }
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("HighUserCardController --> getHuiLianTongCardInfo() error!", e);
return ResponseMsgUtil.exception(e);
}
}
} }

@ -1,6 +1,5 @@
package com.bweb.controller; package com.bweb.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
@ -10,16 +9,21 @@ import com.hai.common.exception.SysCode;
import com.hai.common.security.SessionObject; import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter; import com.hai.common.security.UserCenter;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.RechargeConfig;
import com.hai.entity.BsOperationLog;
import com.hai.entity.OutRechargePrice; import com.hai.entity.OutRechargePrice;
import com.hai.entity.SecDictionary; import com.hai.model.OutRechargePriceModel;
import com.hai.model.ResponseData; import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel; import com.hai.model.UserInfoModel;
import com.hai.service.BsConfigService;
import com.hai.service.BsOperationLogService;
import com.hai.service.CommonService; import com.hai.service.CommonService;
import com.hai.service.OutRechargePriceService; import com.hai.service.OutRechargePriceService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -27,11 +31,7 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.util.*;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Controller @Controller
@RequestMapping(value = "/outRechargePrice") @RequestMapping(value = "/outRechargePrice")
@ -47,7 +47,10 @@ public class OutRechargePriceController {
private OutRechargePriceService outRechargePriceService; private OutRechargePriceService outRechargePriceService;
@Resource @Resource
private CommonService commonService; private BsConfigService bsConfigService;
@Resource
private BsOperationLogService bsOperationLogService;
@RequestMapping(value = "/getListOutRechargePrice", method = RequestMethod.GET) @RequestMapping(value = "/getListOutRechargePrice", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ -69,7 +72,7 @@ public class OutRechargePriceController {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("operatorType", operatorType); map.put("operatorType", operatorType);
map.put("rechargePlatform", rechargePlatform); map.put("rechargePlatform", "-" + rechargePlatform + "-");
map.put("rechargeType", rechargeType); map.put("rechargeType", rechargeType);
map.put("rechargeWay", rechargeWay); map.put("rechargeWay", rechargeWay);
map.put("status", status); map.put("status", status);
@ -80,7 +83,25 @@ public class OutRechargePriceController {
List<OutRechargePrice> outRechargePrices = outRechargePriceService.getListRechargePrice(map); List<OutRechargePrice> outRechargePrices = outRechargePriceService.getListRechargePrice(map);
return ResponseMsgUtil.success(new PageInfo<>(outRechargePrices)); Map<String, Object> listMap;
List<OutRechargePriceModel> outRechargePriceModelList = new ArrayList<>();
for (OutRechargePrice list : outRechargePrices) {
OutRechargePriceModel outRechargePriceModel = new OutRechargePriceModel();
listMap = new HashMap<>();
listMap.put("returnType", 2);
listMap.put("productType", "3");
listMap.put("sourceId", list.getId());
BeanUtils.copyProperties(list, outRechargePriceModel);
outRechargePriceModel.setIntegralDiscount(bsConfigService.getProductDiscountByMap(listMap).getDiscount());
outRechargePriceModel.setProductPayTypeString(bsConfigService.getProductPayTypeByMap(listMap));
outRechargePriceModel.setProductPlatformString(bsConfigService.getProductPlatformByMap(listMap));
outRechargePriceModelList.add(outRechargePriceModel);
}
return ResponseMsgUtil.success(new PageInfo<>(outRechargePriceModelList));
} catch (Exception e) { } catch (Exception e) {
log.error("OutRechargePriceController --> getListUser() error!", e); log.error("OutRechargePriceController --> getListUser() error!", e);
return ResponseMsgUtil.exception(e); return ResponseMsgUtil.exception(e);
@ -104,19 +125,33 @@ public class OutRechargePriceController {
object.getJSONArray("productPlatform") == null || object.getJSONArray("productPlatform") == null ||
object.getInteger("rechargeType") == null || object.getInteger("rechargeType") == null ||
object.getJSONArray("payType") == null || object.getJSONArray("payType") == null ||
object.getInteger("rechargeWay") == null || object.getInteger("rechargeWay") == null
object.getBigDecimal("integralDiscount") == null
) { ) {
log.error("OutRechargePriceController -> insertPrice() error!"); log.error("OutRechargePriceController -> insertPrice() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
} }
if (object.getBigDecimal("integralDiscount") == null) {
object.put("integralDiscount" , new BigDecimal(0));
}
object.put("operatorId", userInfoModel.getSecUser().getId()); object.put("operatorId", userInfoModel.getSecUser().getId());
object.put("operatorName", userInfoModel.getSecUser().getLoginName()); object.put("operatorName", userInfoModel.getSecUser().getLoginName());
object.put("companyId", userInfoModel.getBsCompany().getId()); object.put("companyId", userInfoModel.getBsCompany().getId());
outRechargePriceService.insertRechargePrice(object); outRechargePriceService.insertRechargePrice(object);
BsOperationLog bsOperationLog = new BsOperationLog();
bsOperationLog.setOperationType(1);
bsOperationLog.setBeforeContent(String.valueOf(object));
bsOperationLog.setAfterContent("新增数据");
bsOperationLog.setOperatorId(userInfoModel.getSecUser().getId());
bsOperationLog.setOperatorName(userInfoModel.getSecUser().getUserName());
bsOperationLog.setEntityName("OutRechargePrice");
bsOperationLogService.insertOperationLog(bsOperationLog);
return ResponseMsgUtil.success("新增成功"); return ResponseMsgUtil.success("新增成功");
} catch (Exception e) { } catch (Exception e) {
@ -135,52 +170,46 @@ public class OutRechargePriceController {
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject(); UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (object == null || if (object == null ||
object.getString("rechargePrices") == null ||
object.getLong("id") == null || object.getLong("id") == null ||
object.getJSONArray("rechargePrices") == null ||
object.getBigDecimal("discount") == null || object.getBigDecimal("discount") == null ||
object.getString("operatorType") == null || object.getString("operatorType") == null ||
object.getString("rechargePlatform") == null || object.getJSONArray("rechargePlatform") == null ||
object.getJSONArray("productPlatform") == null ||
object.getInteger("rechargeType") == null || object.getInteger("rechargeType") == null ||
object.getString("payType") == null || object.getJSONArray("payType") == null ||
object.getString("rechargeWay") == null || object.getInteger("rechargeWay") == null
object.getString("platformType") == null ||
object.getBigDecimal("integralDiscount") == null
) { ) {
log.error("OutRechargePriceController -> insertPrice() error!"); log.error("OutRechargePriceController -> insertPrice() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
} }
OutRechargePrice outRechargePrice = outRechargePriceService.findById(object.getLong("id")); if (object.getBigDecimal("integralDiscount") == null) {
object.put("integralDiscount" , new BigDecimal(0));
}
OutRechargePriceModel outRechargePrice = outRechargePriceService.findById(object.getLong("id"));
if (outRechargePrice == null) { if (outRechargePrice == null) {
log.error("OutRechargePriceController -> updatePrice() error!"); log.error("OutRechargePriceController -> updatePrice() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.UPDATE_DATA_ERROR, ""); throw ErrorHelp.genException(SysCode.System, ErrorCode.UPDATE_DATA_ERROR, "");
} }
outRechargePrice.setPayPrice(outRechargePrice.getRechargePrice().multiply(object.getBigDecimal("discount").divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_UP))); object.put("operatorId", userInfoModel.getSecUser().getId());
outRechargePrice.setRechargeType(object.getInteger("rechargeType")); object.put("operatorName", userInfoModel.getSecUser().getLoginName());
outRechargePrice.setOperatorType(object.getInteger("operatorType")); object.put("companyId", userInfoModel.getBsCompany().getId());
outRechargePrice.setRechargePlatform(object.getString("rechargePlatform")); outRechargePriceService.updateRechargePrice(object);
outRechargePrice.setRechargeWay(object.getInteger("rechargeWay"));
outRechargePrice.setUpdateTime(new Date()); BsOperationLog bsOperationLog = new BsOperationLog();
outRechargePrice.setStatus(3);
bsOperationLog.setOperationType(2);
outRechargePriceService.updateRechargePrice(outRechargePrice); bsOperationLog.setBeforeContent(String.valueOf(outRechargePrice));
bsOperationLog.setAfterContent(String.valueOf(object));
JSONObject postObject = new JSONObject(); bsOperationLog.setOperatorId(userInfoModel.getSecUser().getId());
postObject.put("payType", object.getString("payType")); bsOperationLog.setOperatorName(userInfoModel.getSecUser().getUserName());
postObject.put("integralDiscount", object.getBigDecimal("integralDiscount")); bsOperationLog.setEntityName("OutRechargePrice");
postObject.put("productPlatform", object.getString("productPlatform"));
postObject.put("operatorId", userInfoModel.getSecUser().getId()); bsOperationLogService.insertOperationLog(bsOperationLog);
postObject.put("operatorName", userInfoModel.getSecUser().getLoginName());
postObject.put("sourceId", outRechargePrice.getId());
// 配置支付方式
commonService.configPayType(postObject);
// 配置积分折扣比例
commonService.configPayType(postObject);
// 配置展示平台
commonService.configPlatform(postObject);
return ResponseMsgUtil.success("修改成功"); return ResponseMsgUtil.success("修改成功");
@ -196,8 +225,8 @@ public class OutRechargePriceController {
public ResponseData findById(@RequestParam(value = "id", required = true) Long id) { public ResponseData findById(@RequestParam(value = "id", required = true) Long id) {
try { try {
OutRechargePrice outRechargePrice = outRechargePriceService.findById(id); OutRechargePriceModel outRechargePriceModel = outRechargePriceService.findById(id);
return ResponseMsgUtil.success(outRechargePrice); return ResponseMsgUtil.success(outRechargePriceModel);
} catch (Exception e) { } catch (Exception e) {
log.error("OutRechargePriceController --> findById() error!", e); log.error("OutRechargePriceController --> findById() error!", e);
@ -220,16 +249,34 @@ public class OutRechargePriceController {
} }
} }
@RequestMapping(value = "/editPriceStatus", method = RequestMethod.GET) @RequestMapping(value = "/editPriceStatus", method = RequestMethod.POST)
@ResponseBody @ResponseBody
@ApiOperation(value = "修改价格状态") @ApiOperation(value = "修改价格状态")
public ResponseData editPriceStatus(@RequestParam(value = "id", required = true) Long id, public ResponseData editPriceStatus(@RequestBody JSONObject object, HttpServletRequest request) {
@RequestParam(value = "status", required = true) Integer status) {
try { try {
OutRechargePrice outRechargePrice = outRechargePriceService.findById(id); SessionObject sessionObject = userCenter.getSessionObject(request);
outRechargePrice.setStatus(status); UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
outRechargePriceService.updateRechargePrice(outRechargePrice);
OutRechargePrice outRechargePrice = outRechargePriceService.findById(object.getLong("id"));
if (object.getInteger("status") == 1 && outRechargePrice.getRechargePlatform().contains("-2-") && outRechargePrice.getGoodsId() == null) {
log.error("OutRechargePriceController -> editPriceStatus() error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "龙阅平台需要输入商品编码!");
}
outRechargePrice.setStatus(object.getInteger("status"));
outRechargePriceService.editPriceStatus(outRechargePrice);
BsOperationLog bsOperationLog = new BsOperationLog();
bsOperationLog.setOperationType(2);
bsOperationLog.setBeforeContent(String.valueOf(outRechargePrice));
bsOperationLog.setAfterContent(String.valueOf(object));
bsOperationLog.setOperatorId(userInfoModel.getSecUser().getId());
bsOperationLog.setOperatorName(userInfoModel.getSecUser().getUserName());
bsOperationLog.setEntityName("OutRechargePrice");
bsOperationLogService.insertOperationLog(bsOperationLog);
return ResponseMsgUtil.success("修改成功"); return ResponseMsgUtil.success("修改成功");
@ -239,4 +286,19 @@ public class OutRechargePriceController {
} }
} }
@RequestMapping(value = "/getProductsList", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取产品")
public ResponseData getProductsList() {
try {
return ResponseMsgUtil.success(RechargeConfig.getProductsListByLy());
} catch (Exception e) {
log.error("HighOrderController --> unionStagingPay() error!", e);
return ResponseMsgUtil.exception(e);
}
}
} }

@ -1,201 +0,0 @@
package com.bweb.controller;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.pay.util.IOUtil;
import com.hai.common.pay.util.XmlUtil;
import com.hai.common.utils.*;
import com.hai.config.TelConfig;
import com.hai.entity.*;
import com.hai.enum_type.GoodsType;
import com.hai.enum_type.PayType;
import com.hai.model.ResponseData;
import com.hai.service.HighOrderService;
import com.hai.service.HighUserService;
import com.hai.service.TelApiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.SortedMap;
import java.util.regex.Pattern;
@RestController
@RequestMapping(value = "/telApi")
@Api(value = "电话费充值数据接口")
public class TelApiController {
private static Logger log = LoggerFactory.getLogger(TelApiController.class);
@Resource
private TelApiService telApiService;
@Resource
private HighOrderService highOrderService;
@Resource
private HighUserService highUserService;
/**
* 中国电信号码格式验证 手机段 133,153,180,181,189,177,1700,173,199
**/
private static final String CHINA_TELECOM_PATTERN = "(^1(33|53|77|73|99|8[019])\\d{8}$)|(^1700\\d{7}$)";
/**
* 中国联通号码格式验证 手机段130,131,132,155,156,185,186,145,176,1709
**/
private static final String CHINA_UNICOM_PATTERN = "(^1(3[0-2]|4[5]|5[56]|7[6]|8[56])\\d{8}$)|(^1709\\d{7}$)";
/**
* 中国移动号码格式验证
* 手机段134,135,136,137,138,139,150,151,152,157,158,159,182,183,184,187,188,147,178,1705
**/
private static final String CHINA_MOBILE_PATTERN = "(^1(3[4-9]|4[7]|5[0-27-9]|7[8]|8[2-478])\\d{8}$)|(^1705\\d{7}$)";
@RequestMapping(value = "/telPay", method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "充值话费")
public ResponseData certification(@RequestBody HighTelOrder highTelOrder) {
try {
if (StringUtils.isBlank(highTelOrder.getTel()) ||
highTelOrder.getPrice() == null
) {
log.error("telApi -> telPay() error!", "参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
int random = (int) (1 + Math.random() * (999999 - 100000 + 1));
Map<String, Object> map = new HashMap<>();
String mchid = "HFb44f8_10004";
String tel = highTelOrder.getTel();
String orderid = "HF" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5);
BigDecimal price = BigDecimal.valueOf(highTelOrder.getPrice());
String teltype = isChinaMobilePhoneNum(highTelOrder.getTel()).toString();
int timeout = 300;
String notify = "notify";
String time = String.valueOf(new Date().getTime());
String APIKEY = "483e5a68fe9bda2f7ab3f2665a0006cd";
String sign = mchid + tel + price + orderid + teltype + notify + time + random + APIKEY;
String param = "mchid=" + mchid +
"&tel=" + tel +
"&orderid=" + orderid +
"&price=" + price +
"&teltype=" + teltype +
"&notify=" + notify +
"&time=" + time +
"&rand=" + random +
"&sign=" + MD5Util.encode(sign.getBytes());
map.put("from", param);
JSONObject object = HttpsUtils.doSmsPost("http://45.130.154.125:9998/api/telpay", map, new HashMap<>());
return ResponseMsgUtil.success(object);
} catch (Exception e) {
log.error("HighMerchantController -> insertMerchant() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/notify", method = RequestMethod.POST)
@ApiOperation(value = "话费充值 -> 异步回调")
public void wechatNotify(HttpServletRequest request, HttpServletResponse response) {
try {
log.info("话费充值 -> 异步通知:处理开始");
String notifyXml = null; // 话费充值系统发送的数据(<![CDATA[product_001]]>格式)
notifyXml = IOUtil.inputStreamToString(request.getInputStream(), "UTF-8");
log.info("话费充值系统发送的数据:" + notifyXml);
SortedMap<String, String> map = XmlUtil.parseXmlToTreeMap(notifyXml, "UTF-8");
// resXml = notifyService.wechatNotify(map);
//
//
// BufferedOutputStream out = new BufferedOutputStream(response.getOutputStream());
// out.write(resXml.getBytes());
// out.flush();
// out.close();
log.info("话费充值 -> 异步通知:处理完成");
} catch (Exception e) {
log.error("WechatPayController --> wechatNotify() error!", e);
}
}
/**
* 查询电话属于哪个运营商
*
* @param tel 手机号码
* @return 0不属于任何一个运营商0:移动1联通2电信 99: 什么都不是
*/
public Integer isChinaMobilePhoneNum(String tel) {
boolean b1 = tel != null && !tel.trim().equals("") && match(CHINA_MOBILE_PATTERN, tel);
if (b1) {
return 0;
}
b1 = tel != null && !tel.trim().equals("") && match(CHINA_UNICOM_PATTERN, tel);
if (b1) {
return 1;
}
b1 = tel != null && !tel.trim().equals("") && match(CHINA_TELECOM_PATTERN, tel);
if (b1) {
return 2;
}
return 99;
}
/**
* 匹配函数
*
* @param regex
* @param tel
* @return
*/
private static boolean match(String regex, String tel) {
return Pattern.matches(regex, tel);
}
@RequestMapping(value = "/getMemberGoods", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取渠道商获取关联商品")
public ResponseData getMemberGoods() {
try {
JSONObject data = TelConfig.getMemberGoods();
return ResponseMsgUtil.success(data);
} catch (Exception e) {
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/getTest", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "测试接口")
public ResponseData getTest() {
try {
return ResponseMsgUtil.success("1");
} catch (Exception e) {
return ResponseMsgUtil.exception(e);
}
}
}

@ -135,7 +135,7 @@ public class AuthConfig implements WebMvcConfigurer {
.excludePathPatterns("/sms/*") .excludePathPatterns("/sms/*")
.excludePathPatterns("/SendSms/*") .excludePathPatterns("/SendSms/*")
.excludePathPatterns("/czOrder/*") .excludePathPatterns("/czOrder/*")
.excludePathPatterns("/outRechargeOrder/*") .excludePathPatterns("/outRechargePrice/*")
.excludePathPatterns("/userDiscount/*") .excludePathPatterns("/userDiscount/*")
; ;
} }

@ -1,46 +1,23 @@
package com.cweb.controller; package com.cweb.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.cweb.config.SysConst;
import com.cweb.config.WxMsgConfig;
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;
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.WechatPayUtil;
import com.hai.common.pay.entity.WeChatPayReqInfo;
import com.hai.common.pay.util.HttpReqUtil;
import com.hai.common.pay.util.MD5Util;
import com.hai.common.pay.util.XmlUtil;
import com.hai.common.pay.util.sdk.WXPayConstants;
import com.hai.common.security.AESEncodeUtil; import com.hai.common.security.AESEncodeUtil;
import com.hai.common.security.SessionObject; import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter; import com.hai.common.security.UserCenter;
import com.hai.common.utils.*; import com.hai.common.utils.*;
import com.hai.config.CommonSysConst; import com.hai.config.RechargeConfig;
import com.hai.config.UnionPayConfig;
import com.hai.dao.SecDictionaryMapper;
import com.hai.entity.*; import com.hai.entity.*;
import com.hai.enum_type.DiscountUseScope; import com.hai.enum_type.DiscountUseScope;
import com.hai.enum_type.GoodsType; import com.hai.model.*;
import com.hai.enum_type.PayType;
import com.hai.model.HighUserModel;
import com.hai.model.OrderRefundModel;
import com.hai.model.ResponseData;
import com.hai.model.ResultProfitSharing;
import com.hai.service.*; import com.hai.service.*;
import com.hai.service.pay.impl.GoodsOrderServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
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.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -50,8 +27,8 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*; import java.util.*;
import java.util.concurrent.ThreadLocalRandom;
@Controller @Controller
@RequestMapping(value = "/outRechargeOrder") @RequestMapping(value = "/outRechargeOrder")
@ -65,645 +42,278 @@ public class OutRechargeOrderController {
@Resource @Resource
private OutRechargeOrderService outRechargeOrderService; private OutRechargeOrderService outRechargeOrderService;
@Resource
private HighOrderService highOrderService;
@Resource @Resource
private OutRechargePriceService outRechargePriceService; private OutRechargePriceService outRechargePriceService;
@Resource @Resource
private WechatPayUtil wechatPayUtil; private SecConfigService secConfigService;
@Resource @Resource
private GoodsOrderServiceImpl goodsOrderService; private HighUserCardService highUserCardService;
@Resource @Resource
private HighProfitSharingRecordService highProfitSharingRecordService; private HighUserPayPasswordService highUserPayPasswordService;
@Resource @Resource
private SecConfigService secConfigService; private HighDiscountUserRelService highDiscountUserRelService;
@Resource @Resource
private HighUserCardService highUserCardService; private BsConfigService bsConfigService;
@Resource @Resource
private HighUserPayPasswordService highUserPayPasswordService; private RechargeConfig rechargeConfig;
@RequestMapping(value="/addOrder",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "增加订单")
public ResponseData addOrder(@RequestBody JSONObject object, HttpServletRequest request) {
try {
// 用户
SessionObject sessionObject = userCenter.getSessionObject(request);
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
if (StringUtils.isBlank(object.getString("rechargeContent")) ||
StringUtils.isBlank(object.getString("regionId")) ||
object.getLong("goodsId") == null
) {
log.error("addOrder error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
OutRechargeOrder outRechargeOrder = new OutRechargeOrder();
// 产品id
Long goodsId = object.getLong("goodsId");
// 充值内容
String rechargeContent = object.getString("rechargeContent");
// 查询产品详情
OutRechargePriceModel outRechargePrice = outRechargePriceService.findById(goodsId);
Map<String, Object> listMap = new HashMap<>();
listMap.put("productType", "3");
listMap.put("returnType", 1);
listMap.put("sourceId", goodsId);
// 查询产品积分抵扣比例
BsProductDiscount bsProductDiscount = bsConfigService.getProductDiscountByMap(listMap);
// 判断充值系统是否关闭
if (!secConfigService.isConfig("RECHARGE" , "1")) {
log.error("addOrder error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.RECHARGE_CLOSE, "");
}
HighDiscountUserRel highDiscountUserRel = null;
// 判断是否有优惠券
if (object.getLong("memDiscountId") != null) {
// 卡优惠券信息
highDiscountUserRel = highDiscountUserRelService.getRelById(object.getLong("memDiscountId"));
if (highDiscountUserRel == null || highDiscountUserRel.getStatus() != 1) {
log.error("HighOrderController --> addOrder() error!", "优惠券状态错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券状态错误");
}
if (!highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type1.getType())
&& !highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type3.getType())) {
log.error("HighOrderController --> addOrder() error!", "无法使用此优惠券");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法使用此优惠券");
}
}
// 优惠券抵扣
if (highDiscountUserRel != null) {
outRechargeOrder.setMemDiscountName(highDiscountUserRel.getHighDiscount().getDiscountName());
// 卡卷类型 1:满减 2:抵扣 3:折扣
if (highDiscountUserRel.getHighDiscount().getDiscountType() == 1) {
// 如果商品支付总额 小于 满减价格
if (outRechargePrice.getPayPrice().compareTo(highDiscountUserRel.getHighDiscount().getDiscountCondition()) > 1) {
log.error("HighOrderController --> addOrder() error!", "订单未达到满减额度");
throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "订单未达到"+highDiscountUserRel.getHighDiscount().getDiscountCondition()+"元,无法使用此优惠券");
}
// 计算支付金额 = 商品支付总额 - 满减额度
BigDecimal payPrice = outRechargePrice.getPayPrice().subtract(highDiscountUserRel.getHighDiscount().getDiscountPrice());
outRechargeOrder.setDiscountDeductionPrice(highDiscountUserRel.getHighDiscount().getDiscountPrice());
// 如果总额小于0
if (payPrice.compareTo(new BigDecimal("0")) < 0) {
outRechargeOrder.setPayRealPrice(new BigDecimal("0"));
} else {
outRechargeOrder.setPayRealPrice(payPrice);
}
}
// 卡卷类型 1:满减 2:抵扣 3:折扣
if (highDiscountUserRel.getHighDiscount().getDiscountType() == 2) {
// 计算支付金额 = 商品支付总额 - 满减额度
BigDecimal payPrice = outRechargePrice.getPayPrice().subtract(highDiscountUserRel.getHighDiscount().getDiscountPrice());
outRechargeOrder.setDiscountDeductionPrice(highDiscountUserRel.getHighDiscount().getDiscountPrice());
// 如果总额小于0
if (payPrice.compareTo(new BigDecimal("0")) < 0) {
outRechargeOrder.setPayRealPrice(new BigDecimal("0"));
} else {
outRechargeOrder.setPayRealPrice(payPrice);
}
}
// 卡卷类型 1:满减 2:抵扣 3:折扣
if (highDiscountUserRel.getHighDiscount().getDiscountType() == 3) {
BigDecimal discountPrice = highDiscountUserRel.getHighDiscount().getDiscountPrice();
// 订单总额 * 折扣
BigDecimal payPrice = outRechargePrice.getPayPrice().multiply(discountPrice);
outRechargeOrder.setDiscountDeductionPrice(outRechargePrice.getPayPrice().subtract(payPrice));
outRechargeOrder.setPayRealPrice(payPrice);
}
}
// 判断积分数量是否大于0
if (object.getLong("integralNum") > 0 && bsProductDiscount.getDiscount().compareTo(new BigDecimal("0")) > 0) {
// 积分抵扣金额
BigDecimal integralDeductionPrice = BigDecimal.valueOf(object.getLong("integralNum") / 100);
// 最高可抵扣金额
BigDecimal maxIntegralDeductionPrice = outRechargeOrder.getPayRealPrice().multiply(bsProductDiscount.getDiscount()).divide(new BigDecimal(100)).setScale(2, RoundingMode.HALF_DOWN);
// 判读积分是否大于限制额度
if (maxIntegralDeductionPrice.compareTo(integralDeductionPrice) > 0) {
log.error("HighOrderController --> addOrder() error!", "积分大于限制额度");
throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "订单最大抵扣积分数量" + object.getLong("integralNum"));
}
// 判断积分抵扣比例是否为100% 并且积分数量是否可以抵扣最后的支付金额
if (bsProductDiscount.getDiscount().compareTo(new BigDecimal(100)) == 0 && integralDeductionPrice.compareTo(outRechargeOrder.getPayRealPrice()) == 0) {
// 查询用户支付密码
HighUserPayPassword userPayPassword = highUserPayPasswordService.getDetailByUser(userInfoModel.getHighUser().getId());
if (userPayPassword == null) {
log.error("orderToPay error!", "未设置支付密码");
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_SET_USER_PAY_PWD, "");
}
if (StringUtils.isBlank(object.getString("password"))) {
log.error("orderToPay error!", "未输入支付密码");
throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_ENTER_USER_PAY_PWD, "");
}
// 校验支付密码
if (!AESEncodeUtil.aesEncrypt(object.getString("password")).equals(userPayPassword.getPassword())) {
log.error("orderToPay error!", "");
throw ErrorHelp.genException(SysCode.System, ErrorCode.USER_PAY_PWD_ERROR, "");
}
}
outRechargeOrder.setIntegralDeductionPrice(integralDeductionPrice);
outRechargeOrder.setPayRealPrice(outRechargeOrder.getPayRealPrice().subtract(outRechargeOrder.getIntegralDeductionPrice()));
}
outRechargeOrder.setUserId(userInfoModel.getHighUser().getId());
outRechargeOrder.setRechargeContent(rechargeContent);
outRechargeOrder.setRegionId(object.getString("regionId"));
outRechargeOrder.setUserName(userInfoModel.getHighUser().getName());
outRechargeOrder.setRechargeType(outRechargePrice.getRechargeType());
outRechargeOrder.setUserPhone(userInfoModel.getHighUser().getPhone());
outRechargeOrder.setOrderNo("RCG" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5));
outRechargeOrder.setCreateTimed(new Date());
// 判断积分支付是否扣完金额
if (outRechargeOrder.getPayRealPrice().compareTo(new BigDecimal(0)) == 0) {
// 201:充值中 202:充值成功 203:充值失败 204:未充值
outRechargeOrder.setRechargeStatus(201);
// 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
outRechargeOrder.setPayStatus(102);
} else {
// 201:充值中 202:充值成功 203:充值失败 204:未充值
outRechargeOrder.setRechargeStatus(204);
// 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
outRechargeOrder.setPayStatus(101);
}
outRechargeOrderService.insertOrder(outRechargeOrder);
return ResponseMsgUtil.success(outRechargeOrder);
} catch (Exception e) {
log.error("HighOrderController -> addOrder() error!",e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/getOrderById", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据id查询订单详情")
public ResponseData getOrderById(@RequestParam(name = "orderId", required = true) Long orderId) {
try {
return ResponseMsgUtil.success(outRechargeOrderService.findByOrderId(orderId));
} catch (Exception e) {
log.error("HighOrderController --> getOrderById() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/cancelOrder", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "取消订单")
public ResponseData cancelOrder(@RequestParam(name = "orderId", required = true) Long orderId) {
try {
OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderId(orderId);
if (outRechargeOrder.getRechargeStatus() == 1) {
outRechargeOrderService.cancelOrder(orderId);
} else {
log.error("orderToPay error!");
throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, "");
}
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("HighOrderController --> cancelOrder() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/getUserOrderList", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取用户订单")
public ResponseData getUserOrderList(
@RequestParam(name = "status", required = false) Integer status,
@RequestParam(name = "orderNo", required = false) String orderNo,
@RequestParam(name = "rechargeModel", required = false) String rechargeModel,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize,
HttpServletRequest request) {
try {
// 用户
SessionObject sessionObject = userCenter.getSessionObject(request);
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
Map<String,String> map = new HashMap<>();
map.put("userId", userInfoModel.getHighUser().getId().toString());
if (status != null) {
map.put("status", status.toString());
}
if (StringUtils.isNotBlank(orderNo)) {
map.put("orderNo", orderNo);
}
if (StringUtils.isNotBlank(rechargeModel)) {
map.put("rechargeModel", rechargeModel);
}
PageHelper.startPage(pageNum,pageSize);
return ResponseMsgUtil.success(new PageInfo<>(outRechargeOrderService.getListRechargeOrder(map)));
} catch (Exception e) {
log.error("HighOrderController --> getUserOrderList() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@Resource
private UnionPayConfig unionPayConfig;
@Resource
private HighDiscountUserRelService highDiscountUserRelService;
//
// @RequestMapping(value="/addOrder",method = RequestMethod.POST)
// @ResponseBody
// @ApiOperation(value = "增加订单")
// public ResponseData addOrder(@RequestBody OutRechargeOrder outRechargeOrder, HttpServletRequest request) {
// try {
//
// // 用户
// SessionObject sessionObject = userCenter.getSessionObject(request);
// HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
// if (StringUtils.isBlank(outRechargeOrder.getRechargeContent()) ||
// outRechargeOrder.getPayPrice() == null ||
// outRechargeOrder.getObjectId() == null ||
// outRechargeOrder.getOrderPrice() == null
// ) {
// log.error("addOrder error!");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
// }
//
// if (!secConfigService.isConfig("RECHARGE" , "1")) {
// log.error("addOrder error!");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.RECHARGE_CLOSE, "");
// }
//
// String remarks = "";
// // 支付类型 1.微信支付
// outRechargeOrder.setPayType(1);
// // 判断充值模式:1 电信 2. 移动 3. 联通
// // 拼接内容
// remarks = outRechargeOrder.getRechargeContent() + "充值" + outRechargeOrder.getOrderPrice() + "元";
//
// HighDiscountUserRel highDiscountUserRel = null;
// if (outRechargeOrder.getMemDiscountId() != null) {
// // 卡优惠券信息
// highDiscountUserRel = highDiscountUserRelService.getRelById(outRechargeOrder.getMemDiscountId());
// if (highDiscountUserRel == null || highDiscountUserRel.getStatus() != 1) {
// log.error("HighOrderController --> addOrder() error!", "优惠券状态错误");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "优惠券状态错误");
// }
// if (!highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type1.getType())
// && !highDiscountUserRel.getHighDiscount().getUseScope().equals(DiscountUseScope.type3.getType())) {
// log.error("HighOrderController --> addOrder() error!", "无法使用此优惠券");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法使用此优惠券");
// }
// }
//
// // 优惠券抵扣
// if (highDiscountUserRel != null) {
// outRechargeOrder.setMemDiscountName(highDiscountUserRel.getHighDiscount().getDiscountName());
//
// // 卡卷类型 1:满减 2:抵扣 3:折扣
// if (highDiscountUserRel.getHighDiscount().getDiscountType() == 1) {
// // 如果订单总额 小于 满减价格
// if (outRechargeOrder.getOrderPrice().compareTo(highDiscountUserRel.getHighDiscount().getDiscountCondition()) > 1) {
// log.error("HighOrderController --> addOrder() error!", "订单未达到满减额度");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.UN_MEMBER_ERROR, "订单未达到"+highDiscountUserRel.getHighDiscount().getDiscountCondition()+"元,无法使用此优惠券");
// }
// // 订单总额 - 满减额度
// BigDecimal payPrice = outRechargeOrder.getOrderPrice().subtract(highDiscountUserRel.getHighDiscount().getDiscountPrice());
//
// outRechargeOrder.setDeductionPrice(highDiscountUserRel.getHighDiscount().getDiscountPrice());
// // 如果总额小于0
// if (payPrice.compareTo(new BigDecimal("0")) == -1) {
// outRechargeOrder.setPayPrice(new BigDecimal("0"));
// } else {
// outRechargeOrder.setPayPrice(payPrice);
// }
// }
//
// // 卡卷类型 1:满减 2:抵扣 3:折扣
// if (highDiscountUserRel.getHighDiscount().getDiscountType() == 2) {
// // 订单总额 - 满减额度
// BigDecimal payPrice = outRechargeOrder.getOrderPrice().subtract(highDiscountUserRel.getHighDiscount().getDiscountPrice());
// outRechargeOrder.setDeductionPrice(highDiscountUserRel.getHighDiscount().getDiscountPrice());
//
// // 如果总额小于0
// if (payPrice.compareTo(new BigDecimal("0")) == -1) {
// outRechargeOrder.setPayPrice(new BigDecimal("0"));
// } else {
// outRechargeOrder.setPayPrice(payPrice);
// }
// }
//
// // 卡卷类型 1:满减 2:抵扣 3:折扣
// if (highDiscountUserRel.getHighDiscount().getDiscountType() == 3) {
// BigDecimal discountPrice = highDiscountUserRel.getHighDiscount().getDiscountPrice();
// // 订单总额 * 折扣
// BigDecimal payPrice = outRechargeOrder.getOrderPrice().multiply(discountPrice);
// outRechargeOrder.setDeductionPrice(outRechargeOrder.getOrderPrice().subtract(payPrice));
// outRechargeOrder.setPayPrice(payPrice);
// }
// }
//
// OutRechargePrice outRechargePrice = outRechargePriceService.findById(outRechargeOrder.getObjectId().longValue());
//
// HighUserCard highUserCard = highUserCardService.getUserHtlCardNo(userInfoModel.getHighUser().getId());
// if (highUserCard != null) {
// outRechargeOrder.setIdCard(highUserCard.getCardNo());
// }
// outRechargeOrder.setRemarks(remarks);
// outRechargeOrder.setRechargeName(remarks);
// outRechargeOrder.setOrderNo("CZ" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5));
// outRechargeOrder.setUserId(userInfoModel.getHighUser().getId());
// outRechargeOrder.setUserName(userInfoModel.getHighUser().getName());
// outRechargeOrder.setRechargeType(outRechargePrice.getRechargeType());
// outRechargeOrder.setUserPhone(userInfoModel.getHighUser().getPhone());
//
// outRechargeOrder.setCreateTimed(new Date());
// outRechargeOrder.setStatus(1);
// outRechargeOrderService.insertOrder(outRechargeOrder);
// return ResponseMsgUtil.success(outRechargeOrder);
//
// } catch (Exception e) {
// log.error("HighOrderController -> addOrder() error!",e);
// return ResponseMsgUtil.exception(e);
// }
// }
//
//
// @RequestMapping(value = "/getOrderById", method = RequestMethod.GET)
// @ResponseBody
// @ApiOperation(value = "根据id查询订单详情")
// public ResponseData getOrderById(@RequestParam(name = "orderId", required = true) Long orderId) {
// try {
//
// return ResponseMsgUtil.success(outRechargeOrderService.findByOrderId(orderId));
//
// } catch (Exception e) {
// log.error("HighOrderController --> getOrderById() error!", e);
// return ResponseMsgUtil.exception(e);
// }
// }
//
// @RequestMapping(value = "/cancelOrder", method = RequestMethod.GET)
// @ResponseBody
// @ApiOperation(value = "取消订单")
// public ResponseData cancelOrder(@RequestParam(name = "orderId", required = true) Long orderId) {
// try {
//
// 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, "");
// }
//
// return ResponseMsgUtil.success("操作成功");
//
// } catch (Exception e) {
// log.error("HighOrderController --> cancelOrder() error!", e);
// return ResponseMsgUtil.exception(e);
// }
// }
//
// @RequestMapping(value = "/getUserOrderList", method = RequestMethod.GET)
// @ResponseBody
// @ApiOperation(value = "获取用户订单")
// public ResponseData getUserOrderList(
// @RequestParam(name = "status", required = false) Integer status,
// @RequestParam(name = "orderNo", required = false) String orderNo,
// @RequestParam(name = "rechargeModel", required = false) String rechargeModel,
// @RequestParam(name = "pageNum", required = true) Integer pageNum,
// @RequestParam(name = "pageSize", required = true) Integer pageSize,
// HttpServletRequest request) {
// try {
//
// // 用户
// SessionObject sessionObject = userCenter.getSessionObject(request);
// HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
//
// Map<String,String> map = new HashMap<>();
// map.put("userId", userInfoModel.getHighUser().getId().toString());
// if (status != null) {
// map.put("status", status.toString());
// }
// if (StringUtils.isNotBlank(orderNo)) {
// map.put("orderNo", orderNo);
// }
// if (StringUtils.isNotBlank(rechargeModel)) {
// map.put("rechargeModel", rechargeModel);
// }
//
// PageHelper.startPage(pageNum,pageSize);
// return ResponseMsgUtil.success(new PageInfo<>(outRechargeOrderService.getListRechargeOrder(map)));
//
// } catch (Exception e) {
// log.error("HighOrderController --> getUserOrderList() error!", e);
// return ResponseMsgUtil.exception(e);
// }
// }
//
//
// @RequestMapping(value="/orderToPay",method = RequestMethod.POST)
// @ResponseBody
// @ApiOperation(value = "订单支付发起支付")
// public ResponseData orderToPay(@RequestBody String reqBodyStr) {
// try {
// if (StringUtils.isBlank(reqBodyStr)) {
// log.error("orderToPay error!", "参数错误");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
// }
// JSONObject jsonObject = JSONObject.parseObject(reqBodyStr);
// Long orderId = jsonObject.getLong("orderId");
// Integer openIdType = jsonObject.getInteger("openIdType"); // openId类型 1:小程序 2:公众号
// String openId = jsonObject.getString("openId"); // openId
// if (orderId == null || StringUtils.isBlank(openId)) {
// log.error("orderToPay error!", "参数错误");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
// }
//
// // 订单
// OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId);
// if (order == null) {
// log.error("orderToPay error!", "未找到订单信息");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息");
// }
//
// // 订单状态 : 1.待支付 2.已支付 3.已完成 4.已退款 5.已取消
// if (order.getStatus() != 1) {
// log.error("orderToPay error!", "无法支付,订单不处于待支付状态");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态");
// }
//
// Map<String,Object> map = new HashMap<>();
// map.put("orderNo", order.getOrderNo());
// map.put("payPrice", order.getPayPrice());
// map.put("orderScene", "RECHARGE_ORDER");
// map.put("body","充值话费");
// map.put("subject","充值话费");
//
// //微信支付
// String nonce_str = MD5Util.MD5Encode(String.valueOf(ThreadLocalRandom.current().nextInt(10000)), "UTF-8");
// int total_fee = MathUtils.objectConvertBigDecimal(map.get("payPrice")).multiply(new BigDecimal("100")).intValue();
// WeChatPayReqInfo weChatPayReqInfo = new WeChatPayReqInfo();
// weChatPayReqInfo.setAppid(SysConst.getSysConfig().getWxMchAppId()); //公众号id
// weChatPayReqInfo.setMch_id(SysConst.getSysConfig().getWxMchId()); //商户号
// if (openIdType != null && openIdType.equals(2)) {
// weChatPayReqInfo.setSub_appid("wxa075e8509802f826"); //商户号公众号
// } else {
// weChatPayReqInfo.setSub_appid(SysConst.getSysConfig().getWxSubAppId());//小程序
// }
// weChatPayReqInfo.setSub_mch_id("1614670195");
// weChatPayReqInfo.setSub_openid(openId);
// weChatPayReqInfo.setNonce_str(nonce_str); //随机字符串
// weChatPayReqInfo.setBody(map.get("body").toString()); //商品描述
// weChatPayReqInfo.setOut_trade_no(map.get("orderNo").toString()); //商户订单号
// weChatPayReqInfo.setTotal_fee(total_fee); //总金额
// weChatPayReqInfo.setSpbill_create_ip("139.159.177.244"); //终端ip
// weChatPayReqInfo.setNotify_url(SysConst.getSysConfig().getNotifyUrl()); //通知url
// weChatPayReqInfo.setTrade_type("JSAPI"); //交易类型
// weChatPayReqInfo.setAttach(map.get("orderScene").toString());
// weChatPayReqInfo.setProfit_sharing("N");
// //附加数据,区分订单类型
// Map<String,String> payMap = new HashMap<>();
//
// payMap.put("app_id", weChatPayReqInfo.getSub_appid());
// payMap.put("api_key",SysConst.getSysConfig().getWxApiKey());
// payMap.put("unified_order_url",SysConst.getSysConfig().getWxUnifiedOrderUrl());
// SortedMap<Object, Object> sortedMap = wechatPayUtil.goWechatPay(weChatPayReqInfo,payMap);
// return ResponseMsgUtil.success(sortedMap);
// } catch (Exception e) {
// log.error("orderToPay error!", e);
// return ResponseMsgUtil.exception(e);
// }
// }
//
// @RequestMapping(value="/hltUnionCardPay",method = RequestMethod.POST)
// @ResponseBody
// @ApiOperation(value = "工会卡支付")
// public ResponseData hltUnionCardPay(@RequestBody JSONObject body,HttpServletRequest request) {
// try {
// // 用户
// SessionObject sessionObject = userCenter.getSessionObject(request);
// HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
//
// if (body == null
// || body.getLong("orderId") == null
// || StringUtils.isBlank(body.getString("cardNo"))
// ) {
// log.error("orderToPay error!", "参数错误");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
// }
//
// // 查询用户支付密码
// HighUserPayPassword userPayPassword = highUserPayPasswordService.getDetailByUser(userInfoModel.getHighUser().getId());
// if (userPayPassword == null) {
// log.error("orderToPay error!", "未设置支付密码");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_SET_USER_PAY_PWD, "");
// }
// if (StringUtils.isBlank(body.getString("password"))) {
// log.error("hltUnionCardPay error!", "未输入支付密码");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_ENTER_USER_PAY_PWD, "");
// }
// // 校验支付密码是否一直
// if (!AESEncodeUtil.aesEncrypt(body.getString("password")).equals(userPayPassword.getPassword())) {
// log.error("hltUnionCardPay error!", "");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.USER_PAY_PWD_ERROR, "");
// }
//
// // 查询用户与卡号的关系
// HighUserCard userCard = highUserCardService.getDetailByUserCardNo(userInfoModel.getHighUser().getId(), body.getString("cardNo"));
// if (userCard == null) {
// log.error("hltUnionCardPay() ERROR", "未绑定卡号");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未绑定卡号");
// }
//
// // 订单
// OutRechargeOrder order = outRechargeOrderService.findByOrderId(body.getLong("orderId"));
// if (order == null) {
// log.error("hltUnionCardPay error!", "未找到订单信息");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息");
// }
//
// // 订单状态 : 1.待支付 2.已支付 3.已完成 4.已退款 5.已取消
// if (order.getStatus() != 1) {
// log.error("hltUnionCardPay error!", "无法支付,订单不处于待支付状态");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态");
// }
//
// outRechargeOrderService.hltUnionCardPay(userCard.getId(), order.getId());
//
// return ResponseMsgUtil.success(outRechargeOrderService.findByOrderId(body.getLong("orderId")));
// } catch (Exception e) {
// log.error("hltUnionCardPay error!", e);
// return ResponseMsgUtil.exception(e);
// }
// }
//
// @RequestMapping(value="/orderToGoldPay",method = RequestMethod.POST)
// @ResponseBody
// @ApiOperation(value = "订单支付发起金币支付")
// public ResponseData orderToGoldPay(@RequestBody String reqBodyStr,HttpServletRequest request) {
// try {
// // 用户
// SessionObject sessionObject = userCenter.getSessionObject(request);
// HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
//
// if (StringUtils.isBlank(reqBodyStr)) {
// log.error("orderToPay error!", "参数错误");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
// }
// JSONObject jsonObject = JSONObject.parseObject(reqBodyStr);
// Long orderId = jsonObject.getLong("orderId");
// String password = jsonObject.getString("password");
//
// if (orderId == null) {
// log.error("orderToPay error!", "参数错误");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
// }
//
// // 查询用户支付密码
// HighUserPayPassword userPayPassword = highUserPayPasswordService.getDetailByUser(userInfoModel.getHighUser().getId());
// if (userPayPassword == null) {
// log.error("orderToPay error!", "未设置支付密码");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_SET_USER_PAY_PWD, "");
// }
// if (StringUtils.isBlank(password)) {
// log.error("orderToPay error!", "未输入支付密码");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.NOT_ENTER_USER_PAY_PWD, "");
// }
// // 校验支付密码是否一直
// if (!AESEncodeUtil.aesEncrypt(password).equals(userPayPassword.getPassword())) {
// log.error("orderToPay error!", "");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.USER_PAY_PWD_ERROR, "");
// }
//
// // 订单
// OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId);
// if (order == null) {
// log.error("hltUnionCardPay error!", "未找到订单信息");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息");
// }
//
// // 订单状态 : 1.待支付 2.已支付 3.已完成 4.已退款 5.已取消
// if (order.getStatus() != 1) {
// log.error("hltUnionCardPay error!", "无法支付,订单不处于待支付状态");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态");
// }
//
// outRechargeOrderService.goldPayOrder(userInfoModel.getHighUser().getId(), order.getId());
//
// 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.setStatus(2);
// order.setPayType(3);
// order.setPayTime(new Date()); // 支付时间
// order.setAbnormalMsg(object.getString("message"));
// outRechargeOrderService.updateOrder(order);
// }
// }
//
// return ResponseMsgUtil.success("充值成功");
// } catch (Exception e) {
// log.error("orderToPay error!", e);
// return ResponseMsgUtil.exception(e);
// }
// }
//
//
//
//
// @RequestMapping(value="/orderToUnionPay",method = RequestMethod.POST)
// @ResponseBody
// @ApiOperation(value = "订单支付发起银联支付")
// public ResponseData orderToUnionPay(@RequestBody String reqBodyStr,HttpServletRequest request) {
// try {
// // 用户
// SessionObject sessionObject = userCenter.getSessionObject(request);
// HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
//
// if (StringUtils.isBlank(reqBodyStr)) {
// log.error("orderToPay error!", "参数错误");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
// }
// JSONObject jsonObject = JSONObject.parseObject(reqBodyStr);
// Long orderId = jsonObject.getLong("orderId");
//
// if (orderId == null) {
// log.error("orderToPay error!", "参数错误");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
// }
// // 订单
// OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId);
// if (order == null) {
// log.error("hltUnionCardPay error!", "未找到订单信息");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息");
// }
//
// // 订单状态 : 1.待支付 2.已支付 3.已完成 4.已退款 5.已取消
// if (order.getStatus() != 1) {
// log.error("hltUnionCardPay error!", "无法支付,订单不处于待支付状态");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态");
// }
//
// return ResponseMsgUtil.success(unionPayConfig.upPreOrder(UnionPayConfig.MER_ID2, UnionPayConfig.TERM_ID2, order.getOrderNo(), order.getPayPrice(), "话费充值", CommonSysConst.getSysConfig().getUnionPayTelNotifyUrl(), request));
//
// } catch (Exception e) {
// log.error("orderToPay error!", e);
// return ResponseMsgUtil.exception(e);
// }
// }
//
//
// @RequestMapping(value = "/wxProfitsharing", method = RequestMethod.GET)
// @ResponseBody
// @ApiOperation(value = "分账")
// public ResponseData wxProfitsharing() {
// try {
// HighOrder order = highOrderService.getOrderByOrderNo("20211019173044475879505");
// BigDecimal rake = new BigDecimal("0.01");
// // 计算微信收取的手续费 支付金额 * 0.002 注:如果与两个相邻数字的距离相等,则为上舍入的舍入模式。
// BigDecimal wxHandlingFee = order.getPayPrice().multiply(new BigDecimal("0.002")).setScale(2,BigDecimal.ROUND_HALF_DOWN);
// BigDecimal price = order.getPayPrice().subtract(wxHandlingFee);
//
// Map<String,String> param = new LinkedHashMap<>();
// param.put("appid", "wx637bd6f7314daa46");
// param.put("mch_id", "1289663601");
// param.put("sub_mch_id" , "1609882817"); // 个体户黎杨珍
// param.put("transaction_id" , order.getPaySerialNo());
// param.put("out_order_no" , order.getOrderNo());
// param.put("nonce_str" , WxUtils.makeNonStr());
//
// // 计算分账金额 手续费后的价格 * 0.01 注:如果与两个相邻数字的距离相等,则为上舍入的舍入模式。
// BigDecimal porofitSharingAmount = price.multiply(rake).setScale(2,BigDecimal.ROUND_DOWN);
//
// List<Map<String,Object>> receiversList = new ArrayList<>();
// Map<String,Object> receiversMap = new LinkedHashMap<>();
// receiversMap.put("type", "MERCHANT_ID");
// receiversMap.put("account", "1603942866");
// receiversMap.put("amount", porofitSharingAmount.multiply(new BigDecimal("100")).intValue());
// receiversMap.put("description", "分给商户【惠昕石化】");
// receiversList.add(receiversMap);
// param.put("receivers" , JSONObject.toJSONString(receiversList));
// String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256);
// param.put("sign" , signStr);
// String resultXmL = this.doRefundRequest(param.get("mch_id"),null, WxUtils.mapToXml(param));
//
// // 请求分账返回的结果
// ResultProfitSharing resultProfitSharing = XmlUtil.getObjectFromXML(resultXmL, ResultProfitSharing.class);
//
// HighProfitSharingRecord sharingRecord = new HighProfitSharingRecord();
// sharingRecord.setOutOrderNo(resultProfitSharing.getOut_order_no());
// sharingRecord.setTransactionId(resultProfitSharing.getTransaction_id());
// sharingRecord.setOrderId(resultProfitSharing.getOrder_id());
// sharingRecord.setStatus(resultProfitSharing.getResult_code());
// sharingRecord.setPrice(porofitSharingAmount);
// sharingRecord.setCreateTime(new Date());
// sharingRecord.setContent(resultXmL);
// highProfitSharingRecordService.insert(sharingRecord);
//
// return ResponseMsgUtil.success("操作成功");
//
// } catch (Exception e) {
// log.error("CmsContentController --> getCorporateAdvertising() error!", e);
// return ResponseMsgUtil.success(e);
// }
// }
//
// @RequestMapping(value = "/wxEndProfitsharing", method = RequestMethod.GET)
// @ResponseBody
// @ApiOperation(value = "完结分账")
// public ResponseData wxEndProfitsharing(String transaction_id,String out_order_no, BigDecimal amount) {
// try {
//
// HighOrder orderNo = highOrderService.getOrderByOrderNo("HF2021101812025050304");
// Map<String,String> param = new LinkedHashMap<>();
// param.put("appid", "wx637bd6f7314daa46");
// param.put("mch_id", "1289663601");
// param.put("sub_mch_id" , "1609882817"); // 个体户黎杨珍
// param.put("nonce_str" , WxUtils.makeNonStr());
// param.put("transaction_id" , orderNo.getPaySerialNo());
// param.put("out_order_no" , orderNo.getOrderNo());
// param.put("description" , "系统自动完结分账");
// String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256);
// param.put("sign" , signStr);
//
// String resultXmL = this.doRefundRequest2(param.get("mch_id"),"https://api.mch.weixin.qq.com/secapi/pay/profitsharingfinish", WxUtils.mapToXml(param));
// // 请求分账返回的结果
// ResultProfitSharing resultProfitSharing = XmlUtil.getObjectFromXML(resultXmL, ResultProfitSharing.class);
// return ResponseMsgUtil.success(resultXmL);
//
// } catch (Exception e) {
// log.error("CmsContentController --> getCorporateAdvertising() error!", e);
// return ResponseMsgUtil.success(e);
// }
// }
//
// @RequestMapping(value = "/wxSelectProfitsharing", method = RequestMethod.GET)
// @ResponseBody
// @ApiOperation(value = "查询剩余分账金额")
// public ResponseData wxSelectProfitsharing(String transaction_id,String out_order_no, BigDecimal amount) {
// try {
// Map<String,String> param = new LinkedHashMap<>();
// param.put("mch_id", "1289663601");
// //param.put("sub_mch_id" , "1609882817"); // 个体户黎杨珍
// param.put("transaction_id" , "4200001175202108102870717911");
// ///param.put("out_order_no" , String.valueOf(new Date().getTime()));
// param.put("nonce_str" , WxUtils.makeNonStr());
// String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256);
// param.put("sign", signStr);
// String unifiedXmL = WxUtils.mapToXml(param);
// return ResponseMsgUtil.success(HttpReqUtil.HttpsDefaultExecute("POST", "https://api.mch.weixin.qq.com/pay/profitsharingorderamountquery", null, unifiedXmL, null));
//
// } catch (Exception e) {
// log.error("CmsContentController --> getCorporateAdvertising() error!", e);
// return ResponseMsgUtil.success(e);
// }
// }
//
// public String doRefundRequest(String mchId, String url, String data) throws Exception {
//
// //小程序退款需要调用双向证书的认证
// CloseableHttpClient httpClient = goodsOrderService.readCertificate(mchId);
// try {
// HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/profitsharing"); // 设置响应头信息
// 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();
// }
// }
//
// public String doRefundRequest2(String mchId, String url, String data) throws Exception {
//
// //小程序退款需要调用双向证书的认证
// CloseableHttpClient httpClient = goodsOrderService.readCertificate(mchId);
// try {
// HttpPost httpost = new HttpPost(url); // 设置响应头信息
// 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();
// }
// }
} }

@ -12,6 +12,7 @@ import com.hai.entity.BsCompany;
import com.hai.entity.HighAgent; import com.hai.entity.HighAgent;
import com.hai.entity.OutRechargePrice; import com.hai.entity.OutRechargePrice;
import com.hai.entity.SecRegion; import com.hai.entity.SecRegion;
import com.hai.model.OutRechargePriceModel;
import com.hai.model.ResponseData; import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel; import com.hai.model.UserInfoModel;
import com.hai.service.BsCompanyService; import com.hai.service.BsCompanyService;
@ -36,7 +37,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
@Controller @Controller
@RequestMapping(value = "/outRechargePrice") @RequestMapping(value = "/outRechargePrice")
@Api(value = "查询充值金额接口") @Api(value = "查询充值金额接口")
public class OutRechargePriceController { public class OutRechargePriceController {
@ -54,39 +55,47 @@ public class OutRechargePriceController {
@Resource @Resource
private CommonService commonService; private CommonService commonService;
@RequestMapping(value = "/getListOutRechargePrice", method = RequestMethod.GET) @RequestMapping(value = "/getRechargePriceByList", method = RequestMethod.GET)
@ResponseBody @ResponseBody
@ApiOperation(value = "查询充值金额列表") @ApiOperation(value = "查询充值金额列表")
public ResponseData getListOutRechargePrice( public ResponseData getRechargePriceByList(
@RequestParam(value = "type", required = false) Integer type, @RequestParam(name = "platformId", required = true) Integer platformId,
@RequestParam(name = "regionId", required = true) String regionId, @RequestParam(name = "regionId", required = true) String regionId,
@RequestParam(name = "showType", required = true) Integer showType, @RequestParam(name = "operatorType", required = true) Integer operatorType,
@RequestParam(name = "rechargeType", required = false) Integer rechargeType @RequestParam(name = "rechargeType", required = true) Integer rechargeType
) { ) {
try { try {
Map<String, String> map = new HashMap<>();
Map<String, Object> map = new HashMap<>();
SecRegion region = commonService.getParentByRegion(Long.parseLong(regionId)); SecRegion region = commonService.getParentByRegion(Long.parseLong(regionId));
if (region != null) { if (region != null) {
BsCompany bsCompany = bsCompanyService.selectCompanyByRegion(region.getRegionId().toString()); BsCompany bsCompany = bsCompanyService.selectCompanyByRegion(region.getRegionId().toString());
map.put("companyId", String.valueOf(bsCompany.getId())); map.put("companyId", String.valueOf(bsCompany.getId()));
} }
map.put("platformId", platformId);
map.put("operatorType", operatorType);
map.put("rechargeType", rechargeType);
if (showType != null ) {
map.put("showType", String.valueOf(showType));
}
if (rechargeType != null ) { return ResponseMsgUtil.success( outRechargePriceService.getRechargePriceByList(map));
map.put("rechargeType", String.valueOf(rechargeType)); } catch (Exception e) {
} log.error("OutRechargePriceController --> getListUser() error!", e);
return ResponseMsgUtil.exception(e);
}
}
if (type != null ) { @RequestMapping(value = "/findById", method = RequestMethod.GET)
map.put("type", String.valueOf(type)); @ResponseBody
} @ApiOperation(value = "根据id查询详情")
public ResponseData findById(@RequestParam(value = "id", required = true) Long id) {
try {
OutRechargePriceModel outRechargePriceModel = outRechargePriceService.findById(id);
return ResponseMsgUtil.success(outRechargePriceModel);
return ResponseMsgUtil.success( outRechargePriceService.getListRechargePriceC(map));
} catch (Exception e) { } catch (Exception e) {
log.error("OutRechargePriceController --> getListUser() error!", e); log.error("OutRechargePriceController --> findById() error!", e);
return ResponseMsgUtil.exception(e); return ResponseMsgUtil.exception(e);
} }
} }

@ -1,38 +1,29 @@
package com.cweb.controller.pay; package com.cweb.controller.pay;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.cweb.config.SysConst;
import com.cweb.config.WxMsgConfig; import com.cweb.config.WxMsgConfig;
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.WechatPayUtil;
import com.hai.common.pay.util.sdk.WXPayConstants; import com.hai.common.pay.entity.WeChatPayReqInfo;
import com.hai.common.security.AESEncodeUtil; import com.hai.common.pay.util.MD5Util;
import com.hai.common.utils.DateUtil; import com.hai.common.security.SessionObject;
import com.hai.common.utils.IDGenerator; import com.hai.common.security.UserCenter;
import com.hai.common.utils.ResponseMsgUtil; import com.hai.common.utils.*;
import com.hai.common.utils.WxUtils;
import com.hai.config.CommonSysConst; import com.hai.config.CommonSysConst;
import com.hai.config.HuiLianTongUnionCardConfig;
import com.hai.config.UnionPayConfig; import com.hai.config.UnionPayConfig;
import com.hai.config.WxOrderConfig;
import com.hai.dao.HighGasOrderRefundMapper; import com.hai.dao.HighGasOrderRefundMapper;
import com.hai.entity.*; import com.hai.entity.*;
import com.hai.enum_type.GoodsType;
import com.hai.enum_type.PayType;
import com.hai.enum_type.RechargePayType; import com.hai.enum_type.RechargePayType;
import com.hai.model.OrderRefundModel; import com.hai.model.HighUserModel;
import com.hai.model.ResponseData; import com.hai.model.ResponseData;
import com.hai.service.*; import com.hai.service.*;
import com.hai.service.pay.impl.GoodsOrderServiceImpl; import com.hai.service.pay.impl.GoodsOrderServiceImpl;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.http.HttpEntity; import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -43,10 +34,8 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.Date; import java.util.*;
import java.util.HashMap; import java.util.concurrent.ThreadLocalRandom;
import java.util.Map;
import java.util.Objects;
@Controller @Controller
@RequestMapping(value = "/czOrder") @RequestMapping(value = "/czOrder")
@ -55,6 +44,9 @@ public class CzOrderController {
private static Logger log = LoggerFactory.getLogger(TuanYouController.class); private static Logger log = LoggerFactory.getLogger(TuanYouController.class);
@Resource
private UserCenter userCenter;
@Resource @Resource
private HighGasOrderRefundMapper highGasOrderRefundMapper; private HighGasOrderRefundMapper highGasOrderRefundMapper;
@ -62,262 +54,312 @@ public class CzOrderController {
private OutRechargeOrderService outRechargeOrderService; private OutRechargeOrderService outRechargeOrderService;
@Resource @Resource
private GoodsOrderServiceImpl goodsOrderService; private OutRechargeChildOrderService outRechargeChildOrderService;
@Resource
private BsRequestRecordService bsRequestRecordService;
@Resource @Resource
private HighUserService highUserService; private HighUserService highUserService;
@Resource @Resource
private HighDiscountUserRelService highDiscountUserRelService; private UnionPayConfig unionPayConfig;
@Resource @Resource
private HighDiscountAgentCodeService highDiscountAgentCodeService; private HighUserCardService highUserCardService;
@Resource @Resource
private OutRechargeOrderRecordService rechargeOrderRecordService; private WechatPayUtil wechatPayUtil;
// @RequestMapping(value = "/rechargeCallback", method = RequestMethod.POST) @RequestMapping(value = "/rechargeCallbackByJj", method = RequestMethod.POST)
// @ApiOperation(value = "话费充值回调") @ApiOperation(value = "尖椒充值回调")
// @ResponseBody @ResponseBody
// public void rechargeCallback(@RequestBody String reqBodyStr, HttpServletRequest request, HttpServletResponse response) { public void rechargeCallbackByJj(@RequestBody String reqBodyStr, HttpServletRequest request, HttpServletResponse response) {
// try { try {
//
// JSONObject dataObject = JSONObject.parseObject(reqBodyStr, JSONObject.class);
// JSONObject dataObject = JSONObject.parseObject(reqBodyStr, JSONObject.class); // 1 尖椒 2 龙阅
// dataObject.put("orderNo" , dataObject.getString("out_order_id"));
// HighGasOrderRefund highGasOrderRefund = new HighGasOrderRefund();
// highGasOrderRefund.setCreateTime(new Date()); OutRechargeChildOrder childOrder = outRechargeChildOrderService.findByOrderNo(dataObject.getString("out_order_id"));
// highGasOrderRefund.setReturnContent(String.valueOf(dataObject));
// OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderId(childOrder.getParentOrderId());
// highGasOrderRefundMapper.insert(highGasOrderRefund);
// BsRequestRecord bsRequestRecord = bsRequestRecordService.findRequestRecordByOrderNo(childOrder.getOrderNo());
// if (dataObject.getInteger("status") == 3) {
// OutRechargeOrder order; bsRequestRecord.setReturnContent(String.valueOf(dataObject));
// OutRechargeOrderRecord rechargeOrderRecord = rechargeOrderRecordService.findByOrderNo(dataObject.getString("out_order_id")); bsRequestRecord.setUpdateTime(new Date());
// if (rechargeOrderRecord == null) { bsRequestRecordService.updateRequestRecord(bsRequestRecord);
// // 查询订单
// order = outRechargeOrderService.findByOrderNo(dataObject.getString("out_order_id")); // 判断是否充值成功
// order.setStatus(3); if (dataObject.getInteger("status") == 3) {
// order.setFinishTime(new Date()); new Thread(() -> {
// outRechargeOrderService.updateOrder(order); HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId());
// } else { WxMsgConfig.rechargedSuccess(
// // 查询订单 rechargeOrder.getRechargeContent() + "充值成功",
// order = outRechargeOrderService.findByOrderId(rechargeOrderRecord.getRechargeOrderId()); String.valueOf(rechargeOrder.getPayRealPrice()),
// order.setStatus(3); rechargeOrder.getOrderNo(),
// order.setFinishTime(new Date()); rechargeOrder.getFinishTime(),
// outRechargeOrderService.updateOrder(order); RechargePayType.getNameByType(rechargeOrder.getPayType()),
// } highUser.getOpenId());
// }).start();
// new Thread(() -> { } else {
// HighUser highUser = highUserService.findByUserId(order.getUserId()); callbackResult(childOrder , rechargeOrder);
// WxMsgConfig.rechargedSuccess( }
// order.getRechargeName() + "充值成功",
// String.valueOf(order.getPayRealPrice()), response.setCharacterEncoding("UTF-8");
// order.getOrderNo(), response.setContentType("text/html;charset=utf-8");
// order.getFinishTime(), PrintWriter writer= response.getWriter();
// RechargePayType.getNameByType(order.getPayType()), writer.write("SUCCESS");
// highUser.getOpenId());
// }).start();
// } catch (Exception e) {
// } else { log.error("WechatPayController --> wechatNotify() error!", e);
// OutRechargeOrderRecord rechargeOrderRecord = rechargeOrderRecordService.findByOrderNo(dataObject.getString("out_order_id")); }
// if (rechargeOrderRecord == null) { }
// rechargeOrderRecord = new OutRechargeOrderRecord();
// // 查询订单 @RequestMapping(value = "/rechargeCallbackByLy", method = RequestMethod.POST)
// OutRechargeOrder order = outRechargeOrderService.findByOrderNo(dataObject.getString("out_order_id")); @ApiOperation(value = "龙阅充值回调")
// if (order.getStatus() == 2) { @ResponseBody
// if (order.getRechargeType() == 1) { public void rechargeCallbackByLy(@RequestBody String reqBodyStr, HttpServletRequest request, HttpServletResponse response) {
// String orderNo = "CZ" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5); try {
// JSONObject object = outRechargeOrderService.getMobile(order.getRechargeContent() , order.getOrderPrice().intValue() , orderNo , order.getRechargeType()); JSONObject dataObject = JSONObject.parseObject(reqBodyStr, JSONObject.class);
// if (object.getInteger("code") != 200) { // 1 尖椒 2 龙阅
// order.setRechargeStatus(1); dataObject.put("orderNo" , dataObject.getString("out_trade_num"));
// order.setAbnormalMsg(object.getString("message")); OutRechargeChildOrder childOrder = outRechargeChildOrderService.findByOrderNo(dataObject.getString("out_order_id"));
// }
// outRechargeOrderService.updateOrder(order); OutRechargeOrder rechargeOrder = outRechargeOrderService.findByOrderId(childOrder.getParentOrderId());
// rechargeOrderRecord.setRechargeOrderId(order.getId());
// rechargeOrderRecord.setRechargeOrderNo(orderNo); BsRequestRecord bsRequestRecord = bsRequestRecordService.findRequestRecordByOrderNo(childOrder.getOrderNo());
// rechargeOrderRecord.setCreateTime(new Date());
// rechargeOrderRecord.setStatus(1); bsRequestRecord.setReturnContent(String.valueOf(dataObject));
// rechargeOrderRecordService.insertOrder(rechargeOrderRecord); bsRequestRecord.setUpdateTime(new Date());
// } bsRequestRecordService.updateRequestRecord(bsRequestRecord);
// }
// // 判断是否充值成功
// } else { if (dataObject.getInteger("status") == 3) {
// // 查询订单 new Thread(() -> {
// OutRechargeOrder order = outRechargeOrderService.findByOrderId(rechargeOrderRecord.getRechargeOrderId()); HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId());
// if (order.getStatus() == 2) { WxMsgConfig.rechargedSuccess(
// orderToRefund(order.getId()); rechargeOrder.getRechargeContent() + "充值成功",
// order.setStatus(5); String.valueOf(rechargeOrder.getPayRealPrice()),
// outRechargeOrderService.updateOrder(order); rechargeOrder.getOrderNo(),
// } rechargeOrder.getFinishTime(),
// } RechargePayType.getNameByType(rechargeOrder.getPayType()),
// highUser.getOpenId());
// } }).start();
// } else {
// response.setCharacterEncoding("UTF-8"); callbackResult(childOrder , rechargeOrder);
// response.setContentType("text/html;charset=utf-8"); }
// PrintWriter writer= response.getWriter();
// writer.write("SUCCESS"); response.setCharacterEncoding("UTF-8");
// response.setContentType("text/html;charset=utf-8");
// PrintWriter writer= response.getWriter();
// } catch (Exception e) { writer.write("SUCCESS");
// log.error("WechatPayController --> wechatNotify() error!", e);
// }
// } } catch (Exception e) {
// log.error("WechatPayController --> wechatNotify() error!", e);
// }
// public Boolean orderToRefund(Long orderId) { }
// try {
// // 回调结果处理
// OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId); private void callbackResult(OutRechargeChildOrder childOrder , OutRechargeOrder rechargeOrder) throws Exception {
//
// // 101:充值成功 102: 充值中 103:充值失败 104 未充值
// // 订单状态 : 1.待支付 2.已支付 3.已完成 4.已取消 5.已退款 6:退款中 // 订单支付状态 : 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
// if (order.getStatus() != 2) { if (childOrder.getStatus() == 102 && rechargeOrder.getPayStatus() == 102) {
// log.error("orderToPay error!", "无法退款,订单状态错误!");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态"); Date rechargeTime = rechargeOrder.getCreateTimed();
// } Date currentTime = new Date();
// int hours = (int) ((rechargeTime.getTime() - currentTime.getTime()) / (1000 * 60 * 60));
// // 微信退款
// if (order.getPayType() == 1) { // 判断快充 并且 充值时间小于6
// Map<String,String> param = new HashMap<>(); if (rechargeOrder.getRechargeType() == 1 && hours < 6) {
// param.put("appid", "wx637bd6f7314daa46"); outRechargeOrderService.pollRequest(rechargeOrder);
// param.put("mch_id", "1289663601"); return;
// param.put("sub_mch_id" , "1614670195"); }
// param.put("nonce_str", WxUtils.makeNonStr()); // 判断慢充 并且 充值时间小于72
// param.put("transaction_id", order.getPaySerialNo()); if (rechargeOrder.getRechargeType() == 2 && hours < 72) {
// param.put("out_refund_no", "HFR"+new Date().getTime()); outRechargeOrderService.pollRequest(rechargeOrder);
// param.put("total_fee", String.valueOf(order.getPayRealPrice().multiply(new BigDecimal("100")).intValue())); return;
// param.put("refund_fee", String.valueOf(order.getPayRealPrice().multiply(new BigDecimal("100")).intValue())); }
// param.put("sign_type", "HMAC-SHA256");
// outRechargeOrderService.rechargeOrderToRefund(rechargeOrder.getId());
// String signStr = WxUtils.generateSignature(param, "Skufk5oi85wDFGl888i6wsRSTkdd5df5" , WXPayConstants.SignType.HMACSHA256);
// param.put("sign", signStr); new Thread(() -> {
// HighUser highUser = highUserService.findByUserId(rechargeOrder.getUserId());
// String resultXmL = doRefundRequest(param.get("mch_id"), WxUtils.mapToXml(param)); WxMsgConfig.rechargedFail(
// OrderRefundModel orderRefundModel = XmlUtil.getObjectFromXML(resultXmL, OrderRefundModel.class); rechargeOrder.getRechargeContent() + "充值失败",
// String.valueOf(rechargeOrder.getPayRealPrice()),
//// if(orderRefundModel.getResult_code().equals("SUCCESS")) { highUser.getOpenId());
//// order.setStatus(5); }).start();
//// 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()); @RequestMapping(value="/orderToPayByWx",method = RequestMethod.POST)
//// } @ResponseBody
// } @ApiOperation(value = "微信订单支付发起支付")
// public ResponseData orderToPayByWx(@RequestBody String reqBodyStr) {
// // 工会卡退款 try {
// if (order.getPayType() == 2) { if (StringUtils.isBlank(reqBodyStr)) {
// JSONObject jsonObject = HuiLianTongUnionCardConfig.refund( "HFR"+new Date().getTime() , order.getOrderNo()); log.error("orderToPay error!", "参数错误");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
// if (jsonObject == null) { }
// log.error("orderToPay error!", "请求超时"); JSONObject jsonObject = JSONObject.parseObject(reqBodyStr);
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "请求超时,请重新点击"); Long orderId = jsonObject.getLong("orderId");
// } Integer openIdType = jsonObject.getInteger("openIdType"); // openId类型 1:小程序 2:公众号
// String openId = jsonObject.getString("openId"); // openId
// JSONObject dataObject = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data")); if (orderId == null || StringUtils.isBlank(openId)) {
// log.error("orderToPay error!", "参数错误");
// if (dataObject.getBoolean("success") || Objects.equals(dataObject.getString("message"), "原交易已撤销,不可再次操作")) { throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
// order.setStatus(5); }
// order.setRefundTime(new Date());
// order.setOutRefundNo("HFR"+new Date().getTime() ); // 订单
// order.setRefundFee(order.getPayRealPrice()); OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId);
// order.setRefundId(dataObject.getString("orderId")); if (order == null) {
// outRechargeOrderService.updateOrder(order); log.error("orderToPay error!", "未找到订单信息");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息");
// } else { }
// log.error("orderToPay error!", dataObject.getString("message"));
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, dataObject.getString("message")); // 订单状态 : 1.待支付 2.已支付 3.已完成 4.已退款 5.已取消
// } if (order.getRechargeStatus() != 1) {
// } log.error("orderToPay error!", "无法支付,订单不处于待支付状态");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态");
// // 积分退款 }
// if (order.getPayType() == 3) {
// Map<String,Object> map = new HashMap<>();
// if (highUserService.findGoldRepeat(3 , order.getId())) { map.put("orderNo", order.getOrderNo());
// highUserService.goldHandle(order.getUserId(), order.getPayRealPrice().multiply(BigDecimal.valueOf(100)).intValue(), 1, 3, order.getId()); map.put("payPrice", order.getPayRealPrice());
// }else { map.put("orderScene", "RECHARGE_ORDER");
// log.error("orderToPay error!", "已有退款记录"); map.put("body","充值话费");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "已有退款记录"); map.put("subject","充值话费");
// }
// //微信支付
// } String nonce_str = MD5Util.MD5Encode(String.valueOf(ThreadLocalRandom.current().nextInt(10000)), "UTF-8");
// int total_fee = MathUtils.objectConvertBigDecimal(map.get("payPrice")).multiply(new BigDecimal("100")).intValue();
// // 银联退款 WeChatPayReqInfo weChatPayReqInfo = new WeChatPayReqInfo();
// if (order.getPayType() == 4) { weChatPayReqInfo.setAppid(SysConst.getSysConfig().getWxMchAppId()); //公众号id
// // 订单退款 weChatPayReqInfo.setMch_id(SysConst.getSysConfig().getWxMchId()); //商户号
// JSONObject refund = UnionPayConfig.zwrefund(UnionPayConfig.MER_ID2, UnionPayConfig.TERM_ID2, order.getOrderNo(), order.getPaySerialNo(), order.getPayRealPrice().multiply(new BigDecimal("100")).longValue()); if (openIdType != null && openIdType.equals(2)) {
// if (!refund.getString("resultcode").equals("W6")) { weChatPayReqInfo.setSub_appid("wxa075e8509802f826"); //商户号公众号
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, refund.getString("returnmsg")); } else {
// } weChatPayReqInfo.setSub_appid(SysConst.getSysConfig().getWxSubAppId());//小程序
// }
// order.setStatus(5); weChatPayReqInfo.setSub_mch_id("1614670195");
// order.setRefundTime(new Date()); weChatPayReqInfo.setSub_openid(openId);
// order.setOutRefundNo(refund.getString("oriwtorderid")); weChatPayReqInfo.setNonce_str(nonce_str); //随机字符串
// order.setRefundFee(order.getPayRealPrice()); weChatPayReqInfo.setBody(map.get("body").toString()); //商品描述
// outRechargeOrderService.updateOrder(order); weChatPayReqInfo.setOut_trade_no(map.get("orderNo").toString()); //商户订单号
// } weChatPayReqInfo.setTotal_fee(total_fee); //总金额
// weChatPayReqInfo.setSpbill_create_ip("139.159.177.244"); //终端ip
// if (order.getMemDiscountId() != null) { weChatPayReqInfo.setNotify_url(SysConst.getSysConfig().getNotifyUrl()); //通知url
// HighDiscountUserRel rel = highDiscountUserRelService.getRelById(order.getMemDiscountId()); weChatPayReqInfo.setTrade_type("JSAPI"); //交易类型
// if (rel != null) { weChatPayReqInfo.setAttach(map.get("orderScene").toString());
// rel.setStatus(1); // 状态 0:已过期 1:未使用 2:已使用 weChatPayReqInfo.setProfit_sharing("N");
// rel.setUseTime(null); //附加数据,区分订单类型
// highDiscountUserRelService.updateDiscountUserRel(rel); Map<String,String> payMap = new HashMap<>();
//
// HighDiscountAgentCode code = highDiscountAgentCodeService.getCodeById(rel.getDiscountAgentCodeId()); payMap.put("app_id", weChatPayReqInfo.getSub_appid());
// code.setStatus(2); payMap.put("api_key",SysConst.getSysConfig().getWxApiKey());
// highDiscountAgentCodeService.updateCode(code); payMap.put("unified_order_url",SysConst.getSysConfig().getWxUnifiedOrderUrl());
// } SortedMap<Object, Object> sortedMap = wechatPayUtil.goWechatPay(weChatPayReqInfo,payMap);
// } return ResponseMsgUtil.success(sortedMap);
// } catch (Exception e) {
// new Thread(() -> { log.error("orderToPay error!", e);
// HighUser highUser = highUserService.findByUserId(order.getUserId()); return ResponseMsgUtil.exception(e);
// WxMsgConfig.rechargedFail( }
// "订单号:" + order.getOrderNo() + "-" + order.getRechargeName(), }
// String.valueOf(order.getPayRealPrice()),
// highUser.getOpenId()); @RequestMapping(value="/hltUnionCardPay",method = RequestMethod.POST)
// }).start(); @ResponseBody
// @ApiOperation(value = "工会卡支付")
// return true; public ResponseData hltUnionCardPay(@RequestBody JSONObject body,HttpServletRequest request) {
// } catch (Exception e) { try {
// log.error("HighOrderController --> getUserOrderList() error!", e); // 用户
// return false; SessionObject sessionObject = userCenter.getSessionObject(request);
// } HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
// }
// if (body == null
// || body.getLong("orderId") == null
// public String doRefundRequest(String mchId,String data) throws Exception { || StringUtils.isBlank(body.getString("cardNo"))
// ) {
// //小程序退款需要调用双向证书的认证 log.error("orderToPay error!", "参数错误");
// CloseableHttpClient httpClient = goodsOrderService.readCertificate(mchId); throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
// try { }
// HttpPost httpost = new HttpPost("https://api.mch.weixin.qq.com/secapi/pay/refund"); // 设置响应头信息
// httpost.addHeader("Connection", "keep-alive"); // 查询用户与卡号的关系
// httpost.addHeader("Accept", "*/*"); HighUserCard userCard = highUserCardService.getDetailByUserCardNo(userInfoModel.getHighUser().getId(), body.getString("cardNo"));
// httpost.addHeader("Content-Type", "text/xml"); if (userCard == null) {
// httpost.addHeader("Host", "api.mch.weixin.qq.com"); log.error("hltUnionCardPay() ERROR", "未绑定卡号");
// httpost.addHeader("X-Requested-With", "XMLHttpRequest"); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未绑定卡号");
// 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); OutRechargeOrder order = outRechargeOrderService.findByOrderId(body.getLong("orderId"));
// try {
// HttpEntity entity = response.getEntity(); if (order == null) {
// String jsonStr = EntityUtils.toString(response.getEntity(), "UTF-8"); log.error("hltUnionCardPay error!", "未找到订单信息");
// EntityUtils.consume(entity); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息");
// return jsonStr; }
// } finally {
// response.close(); // 订单状态 : 1.待支付 2.已支付 3.已完成 4.已退款 5.已取消
// } if (order.getRechargeStatus() != 1) {
// } catch (Exception e){ log.error("hltUnionCardPay error!", "无法支付,订单不处于待支付状态");
// throw new RuntimeException(e); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态");
// } finally { }
// httpClient.close();
// } outRechargeOrderService.hltUnionCardPay(userCard, order);
// }
return ResponseMsgUtil.success(outRechargeOrderService.findByOrderId(body.getLong("orderId")));
} catch (Exception e) {
log.error("hltUnionCardPay error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/orderToUnionPay",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "订单支付发起银联支付")
public ResponseData orderToUnionPay(@RequestBody String reqBodyStr,HttpServletRequest request) {
try {
// 用户
SessionObject sessionObject = userCenter.getSessionObject(request);
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
if (StringUtils.isBlank(reqBodyStr)) {
log.error("orderToPay error!", "参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
JSONObject jsonObject = JSONObject.parseObject(reqBodyStr);
Long orderId = jsonObject.getLong("orderId");
if (orderId == null) {
log.error("orderToPay error!", "参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 订单
OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId);
if (order == null) {
log.error("hltUnionCardPay error!", "未找到订单信息");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息");
}
// 订单状态 : 1.待支付 2.已支付 3.已完成 4.已退款 5.已取消
if (order.getPayStatus() != 1) {
log.error("hltUnionCardPay error!", "无法支付,订单不处于待支付状态");
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法支付,订单不处于待支付状态");
}
return ResponseMsgUtil.success(unionPayConfig.upPreOrder(UnionPayConfig.MER_ID2, UnionPayConfig.TERM_ID2, order.getOrderNo(), order.getPayRealPrice(), "话费充值", CommonSysConst.getSysConfig().getUnionPayTelNotifyUrl(), request));
} catch (Exception e) {
log.error("orderToPay error!", e);
return ResponseMsgUtil.exception(e);
}
}
} }

@ -209,17 +209,4 @@ public class WechatPayController {
+ body + ""; + body + "";
} }
@RequestMapping(value = "/telApi", method = RequestMethod.GET)
@ApiOperation(value = "电话查询")
@ResponseBody
public ResponseData addLedgerReceiver(@RequestParam(value = "tel", required = true) String tel) {
try {
JSONObject jsonObject = telApiService.outApiTel(tel);
return ResponseMsgUtil.success(jsonObject.get("result"));
} catch (Exception e) {
log.error("WechatPayController --> wechatNotify() error!", e);
return ResponseMsgUtil.exception(e);
}
}
} }

@ -406,5 +406,37 @@ public class WxUtils {
} }
} }
/**
* 生成龙阅签名. 注意若含有sign_type字段必须和signType参数保持一致
*
* @param data 待签名数据
* @param key API密钥
* @param signType 签名方式
* @return 签名
*/
public static String generateSignatureLy(final Map<String, Object> data, String key, WXPayConstants.SignType signType) throws Exception {
Set<String> keySet = data.keySet();
String[] keyArray = keySet.toArray(new String[keySet.size()]);
Arrays.sort(keyArray);
StringBuilder sb = new StringBuilder();
for (String k : keyArray) {
if (k.equals(WXPayConstants.FIELD_SIGN)) {
continue;
}
if (data.get(k) != null) // 参数值为空,则不参与签名
sb.append(k).append("=").append(data.get(k)).append("&");
}
sb.append("apikey=").append(key);
if (WXPayConstants.SignType.MD5.equals(signType)) {
return MD5(sb.toString() , true);
}
else if (WXPayConstants.SignType.HMACSHA256.equals(signType)) {
return HMACSHA256(sb.toString(), key);
}
else {
throw new Exception(String.format("Invalid sign_type: %s", signType));
}
}
} }

@ -60,10 +60,15 @@ public class CommonSysConfig {
private String telUrl; private String telUrl;
private String czOrderNotify; private String czOrderNotify;
private String CzNotifyUrl; private String lyApiKey;
private String CzAppKey; private String lyNotifyUrl;
private String CzUrl; private String lyMemberId;
private String CzAppSecret; private String LyPostUrl;
private String JjNotifyUrl;
private String JjAppKey;
private String JjUrl;
private String JjAppSecret;
private String unionAppId; private String unionAppId;
private String unionSecret; private String unionSecret;
@ -397,36 +402,36 @@ public class CommonSysConfig {
HltMembershipLevelSignCode = hltMembershipLevelSignCode; HltMembershipLevelSignCode = hltMembershipLevelSignCode;
} }
public String getCzNotifyUrl() { public String getJjNotifyUrl() {
return CzNotifyUrl; return JjNotifyUrl;
} }
public void setCzNotifyUrl(String czNotifyUrl) { public void setJjNotifyUrl(String jjNotifyUrl) {
CzNotifyUrl = czNotifyUrl; JjNotifyUrl = jjNotifyUrl;
} }
public String getCzAppKey() { public String getJjAppKey() {
return CzAppKey; return JjAppKey;
} }
public void setCzAppKey(String czAppKey) { public void setJjAppKey(String jjAppKey) {
CzAppKey = czAppKey; JjAppKey = jjAppKey;
} }
public String getCzUrl() { public String getJjUrl() {
return CzUrl; return JjUrl;
} }
public void setCzUrl(String czUrl) { public void setJjUrl(String jjUrl) {
CzUrl = czUrl; JjUrl = jjUrl;
} }
public String getCzAppSecret() { public String getJjAppSecret() {
return CzAppSecret; return JjAppSecret;
} }
public void setCzAppSecret(String czAppSecret) { public void setJjAppSecret(String jjAppSecret) {
CzAppSecret = czAppSecret; JjAppSecret = jjAppSecret;
} }
public String getHsgDomainName() { public String getHsgDomainName() {
@ -436,4 +441,36 @@ public class CommonSysConfig {
public void setHsgDomainName(String hsgDomainName) { public void setHsgDomainName(String hsgDomainName) {
this.hsgDomainName = hsgDomainName; this.hsgDomainName = hsgDomainName;
} }
public String getLyApiKey() {
return lyApiKey;
}
public void setLyApiKey(String lyApiKey) {
this.lyApiKey = lyApiKey;
}
public String getLyMemberId() {
return lyMemberId;
}
public void setLyMemberId(String lyMemberId) {
this.lyMemberId = lyMemberId;
}
public String getLyPostUrl() {
return LyPostUrl;
}
public void setLyPostUrl(String lyPostUrl) {
LyPostUrl = lyPostUrl;
}
public String getLyNotifyUrl() {
return lyNotifyUrl;
}
public void setLyNotifyUrl(String lyNotifyUrl) {
this.lyNotifyUrl = lyNotifyUrl;
}
} }

@ -0,0 +1,147 @@
package com.hai.config;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.pay.util.sdk.WXPayConstants;
import com.hai.common.utils.HttpsUtils;
import com.hai.common.utils.MD5Util;
import com.hai.common.utils.WxUtils;
import com.hai.entity.OutRechargeChildOrder;
import com.hai.entity.OutRechargeOrder;
import com.hai.entity.OutRechargePrice;
import com.hai.service.OutRechargeChildOrderService;
import com.hai.service.OutRechargeOrderService;
import com.hai.service.OutRechargePriceService;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @ClassName TelConfig
* @Author Sum1Dream
* @Version 1.0.0
* @Description // 充值接口
* @Date 2021/7/18 14:18
**/
@Component
public class RechargeConfig {
/**
* @Author Sum1Dream
* @name getProductsList.java
* @Description // 获取龙阅产品
* @Date 10:03 2022/5/24
* @Param []
* @return com.alibaba.fastjson.JSONObject
*/
public static JSONObject getProductsListByLy() throws Exception {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("userid" , CommonSysConst.getSysConfig().getLyMemberId());
paramMap.put("sign", WxUtils.generateSignatureLy(paramMap , CommonSysConst.getSysConfig().getLyApiKey() , WXPayConstants.SignType.MD5));
return HttpsUtils.doPost(CommonSysConst.getSysConfig().getLyPostUrl()+ "index/product", paramMap);
}
/**
* @Author Sum1Dream
* @name rechargeOrderByLy.java
* @Description // 龙阅订单充值
* @Date 09:57 2022/5/25
* @Param [com.alibaba.fastjson.JSONObject]
* @return com.alibaba.fastjson.JSONObject
*/
public static JSONObject rechargeOrderByLy(JSONObject object) throws Exception {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("out_trade_num" , object.getString("out_trade_num"));
paramMap.put("product_id" , object.getString("product_id"));
paramMap.put("mobile" , object.getString("mobile"));
paramMap.put("notify_url" , CommonSysConst.getSysConfig().getJjNotifyUrl());
paramMap.put("userid" , CommonSysConst.getSysConfig().getLyMemberId());
paramMap.put("sign", WxUtils.generateSignatureLy(paramMap , CommonSysConst.getSysConfig().getLyApiKey() , WXPayConstants.SignType.MD5));
return HttpsUtils.doPost(CommonSysConst.getSysConfig().getLyPostUrl()+ "index/recharge", paramMap);
}
/**
* @Author Sum1Dream
* @name checkOrderByLy.java
* @Description // 龙阅查询订单结果
* @Date 14:05 2022/5/24
* @Param [com.alibaba.fastjson.JSONObject]
* @return com.alibaba.fastjson.JSONObject
*/
public static JSONObject checkOrderByLy(JSONObject object) throws Exception {
Map<String,Object> paramMap = new HashMap<>();
paramMap.put("userid" , CommonSysConst.getSysConfig().getLyMemberId());
paramMap.put("out_trade_nums" , object.getString("out_trade_nums"));
paramMap.put("sign", WxUtils.generateSignatureLy(paramMap , CommonSysConst.getSysConfig().getLyApiKey() , WXPayConstants.SignType.MD5));
return HttpsUtils.doPost(CommonSysConst.getSysConfig().getLyPostUrl()+ "index/check", paramMap);
}
/**
* @Author Sum1Dream
* @name rechargeOrderByJj.java
* @Description // 尖椒订单充值
* @Date 09:57 2022/5/25
* @Param [com.alibaba.fastjson.JSONObject]
* @return com.alibaba.fastjson.JSONObject
*/
public static JSONObject rechargeOrderByJj(JSONObject object) throws Exception {
String timestamp = String.valueOf(System.currentTimeMillis());
Map<String , Object> map = new HashMap<>();
map.put("mobile" , object.getString("mobile"));
map.put("amount" , object.getString("amount"));
map.put("out_order_id" , object.getString("out_order_id"));
map.put("app_key" , CommonSysConst.getSysConfig().getJjAppKey());
map.put("timestamp" , timestamp.substring(0,timestamp.length()-3));
map.put("is_fast" , object.getString("is_fast"));
map.put("notify_url" , CommonSysConst.getSysConfig().getJjNotifyUrl());
String signStr = WxUtils.generateSignatureAppSecret(map, CommonSysConst.getSysConfig().getJjAppSecret() , WXPayConstants.SignType.MD5);
map.put("sign" , signStr);
return HttpsUtils.doPost(CommonSysConst.getSysConfig().getJjUrl() + "createOrder" , map);
}
/**
* @Author Sum1Dream
* @name checkOrderByJj.java
* @Description // 尖椒查询订单详情
* @Date 09:57 2022/5/25
* @Param [com.alibaba.fastjson.JSONObject]
* @return com.alibaba.fastjson.JSONObject
*/
public static JSONObject checkOrderByJj(JSONObject object) throws Exception {
String timestamp = String.valueOf(System.currentTimeMillis());
Map<String , Object> map = new HashMap<>();
map.put("out_order_id" , object.getString("out_order_id"));
map.put("app_key" , CommonSysConst.getSysConfig().getJjAppKey());
map.put("timestamp" , timestamp.substring(0,timestamp.length()-3));
map.put("notify_url" , CommonSysConst.getSysConfig().getLyNotifyUrl());
String signStr = WxUtils.generateSignatureAppSecret(map, CommonSysConst.getSysConfig().getJjAppSecret() , WXPayConstants.SignType.MD5);
map.put("sign" , signStr);
return HttpsUtils.doPost(CommonSysConst.getSysConfig().getJjUrl() + "queryOrder" , map);
}
}

@ -1,80 +0,0 @@
package com.hai.config;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.utils.HttpsUtils;
import com.hai.common.utils.MD5Util;
import com.hai.entity.OutRechargeOrder;
import com.hai.entity.OutRechargePrice;
import com.hai.service.OutRechargeOrderService;
import com.hai.service.OutRechargePriceService;
import org.springframework.web.bind.annotation.RequestBody;
import javax.annotation.Resource;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* @ClassName TelConfig
* @Author Sum1Dream
* @Version 1.0.0
* @Description // 话费接口配置
* @Date 2021/7/18 14:18
**/
public class TelConfig {
public static JSONObject getMemberGoods() throws Exception {
Map<String,Object> map = new HashMap<>();
Long time = new Date().getTime();
String sign = CommonSysConst.getSysConfig().getTelApiSecret() + "_" + time;
map.put("apiKey", CommonSysConst.getSysConfig().getTelApiKey());
map.put("memberId", CommonSysConst.getSysConfig().getTelMemberId());
map.put("time", time);
map.put("sign", MD5Util.encode(sign.getBytes()).toLowerCase());
return HttpsUtils.doGet(CommonSysConst.getSysConfig().getTelUrl()+ "/getMemberGoods", map);
}
public static JSONObject order(Map<String,Object> mapOrder) throws Exception {
Map<String,Object> map = new HashMap<>();
Long time = new Date().getTime();
String sign = CommonSysConst.getSysConfig().getTelApiSecret() + "_" + time;
for (Map.Entry<String, Object> entry : mapOrder.entrySet()) {
map.put(entry.getKey(), entry.getValue().toString());
}
map.put("apiKey", CommonSysConst.getSysConfig().getTelApiKey());
map.put("memberId", CommonSysConst.getSysConfig().getTelMemberId());
map.put("time", time);
map.put("sign", MD5Util.encode(sign.getBytes()).toLowerCase());
return HttpsUtils.doGet(CommonSysConst.getSysConfig().getTelUrl()+ "/getMemberGoods", map);
}
public static JSONObject checkingOrder(Map<String,Object> mapOrder) throws Exception {
Map<String,Object> map = new HashMap<>();
Long time = new Date().getTime();
String sign = CommonSysConst.getSysConfig().getTelApiSecret() + "_" + time;
for (Map.Entry<String, Object> entry : mapOrder.entrySet()) {
map.put(entry.getKey(), entry.getValue().toString());
}
map.put("apiKey", CommonSysConst.getSysConfig().getTelApiKey());
map.put("memberId", CommonSysConst.getSysConfig().getTelMemberId());
map.put("time", time);
map.put("sign", MD5Util.encode(sign.getBytes()).toLowerCase());
return HttpsUtils.doGet(CommonSysConst.getSysConfig().getTelUrl()+ "/order", map);
}
}

@ -106,4 +106,4 @@ public interface OutRechargeOrderRecordMapper extends OutRechargeOrderRecordMapp
"where id = #{id,jdbcType=BIGINT}" "where id = #{id,jdbcType=BIGINT}"
}) })
int updateByPrimaryKey(OutRechargeOrderRecord record); int updateByPrimaryKey(OutRechargeOrderRecord record);
} }

@ -4,4 +4,4 @@ package com.hai.dao;
* mapper扩展类 * mapper扩展类
*/ */
public interface OutRechargeOrderRecordMapperExt { public interface OutRechargeOrderRecordMapperExt {
} }

@ -273,4 +273,4 @@ public class OutRechargeOrderRecordSqlProvider {
sql.WHERE(sb.toString()); sql.WHERE(sb.toString());
} }
} }
} }

@ -1,7 +1,50 @@
package com.hai.dao; package com.hai.dao;
import com.hai.entity.OutRechargePrice;
import com.hai.entity.OutRechargePriceExample;
import com.hai.entity.SecPermission;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.type.JdbcType;
import java.util.List;
import java.util.Map;
/** /**
* mapper扩展类 * mapper扩展类
*/ */
public interface OutRechargePriceMapperExt { public interface OutRechargePriceMapperExt {
}
@Select({"<script>" +
"SELECT * from out_recharge_price orp " +
"join bs_product_platform bpp on orp.id = bpp.source_id " +
"where status in (1,2) and platform_id = #{param.platformId} " +
"and recharge_type = #{param.rechargeType} " +
"and operator_type = #{param.operatorType} " +
"and company_id = #{param.companyId} " +
"order by sort asc; " +
" </script>"})
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="discount", property="discount", jdbcType=JdbcType.DECIMAL),
@Result(column="operator_type", property="operatorType", jdbcType=JdbcType.INTEGER),
@Result(column="recharge_ platform", property="rechargePlatform", jdbcType=JdbcType.VARCHAR),
@Result(column="recharge_type", property="rechargeType", jdbcType=JdbcType.INTEGER),
@Result(column="recharge_way", property="rechargeWay", jdbcType=JdbcType.INTEGER),
@Result(column="company_id", property="companyId", jdbcType=JdbcType.BIGINT),
@Result(column="sort", property="sort", jdbcType=JdbcType.INTEGER),
@Result(column="recharge_price", property="rechargePrice", jdbcType=JdbcType.DECIMAL),
@Result(column="pay_price", property="payPrice", jdbcType=JdbcType.DECIMAL),
@Result(column="goods_id", property="goodsId", jdbcType=JdbcType.BIGINT),
@Result(column="create_time", property="createTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
@Result(column="status", property="status", jdbcType=JdbcType.INTEGER),
@Result(column="ext_1", property="ext1", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_2", property="ext2", jdbcType=JdbcType.VARCHAR),
@Result(column="ext_3", property="ext3", jdbcType=JdbcType.VARCHAR)
})
List<OutRechargePrice> getUserByPrice(@Param("param") Map<String, Object> param);
}

@ -24,7 +24,7 @@ public class BsOperationLog implements Serializable {
private String entityName; private String entityName;
/** /**
* 操作类型1新增 2:修改 3删除 * 操作类型1新增 2:修改 3查询 4删除
*/ */
private Integer operationType; private Integer operationType;
@ -238,4 +238,4 @@ public class BsOperationLog implements Serializable {
sb.append("]"); sb.append("]");
return sb.toString(); return sb.toString();
} }
} }

@ -174,4 +174,4 @@ public class OutRechargeOrderRecord implements Serializable {
sb.append("]"); sb.append("]");
return sb.toString(); return sb.toString();
} }
} }

@ -740,4 +740,4 @@ public class OutRechargeOrderRecordExample {
this(condition, value, secondValue, null); this(condition, value, secondValue, null);
} }
} }
} }

@ -30,7 +30,7 @@ public class OutRechargePrice implements Serializable {
private Integer operatorType; private Integer operatorType;
/** /**
* 充值平台 1尖椒 2龙阅 多个平台用隔开 * 充值平台 1尖椒 2龙阅 多个平台用-隔开
*/ */
private String rechargePlatform; private String rechargePlatform;

@ -4,10 +4,11 @@ import java.util.Objects;
public enum RechargePayType { public enum RechargePayType {
payType1(1 , "微信"), payType1(1 , "支付宝"),
payType2(2 , "工会卡"), payType2(2 , "微信"),
payType3(3 , "积分"), payType3(3 , "汇联通工会卡"),
payType4(4 , "银联") payType4(4 , "银联"),
payType5(5 , "银联分期")
; ;
private Integer type; private Integer type;

@ -0,0 +1,40 @@
package com.hai.model;
import com.hai.entity.OutRechargePrice;
import java.math.BigDecimal;
public class OutRechargePriceModel extends OutRechargePrice {
// 抵扣比例
private BigDecimal integralDiscount;
// 产品展示平台
private String productPlatformString;
// 产品支付方式
private String productPayTypeString;
public BigDecimal getIntegralDiscount() {
return integralDiscount;
}
public void setIntegralDiscount(BigDecimal integralDiscount) {
this.integralDiscount = integralDiscount;
}
public String getProductPlatformString() {
return productPlatformString;
}
public void setProductPlatformString(String productPlatformString) {
this.productPlatformString = productPlatformString;
}
public String getProductPayTypeString() {
return productPayTypeString;
}
public void setProductPayTypeString(String productPayTypeString) {
this.productPayTypeString = productPayTypeString;
}
}

@ -0,0 +1,48 @@
package com.hai.service;
import com.hai.entity.BsProductDiscount;
import com.hai.entity.BsProductPayType;
import com.hai.entity.BsProductPlatform;
import java.util.Map;
/**
* @author Sum1Dream
* @version 1.0.0
* @serviceName BsProductDiscountService.java
* @Description // 查询配置参数
* @createTime 14:14 2022/5/23
**/
public interface BsConfigService {
/**
* @return com.hai.entity.BsProductDiscount
* @Author Sum1Dream
* @name getProductDiscountByMap.java
* @Description // 查询积分配置
* @Date 14:16 2022/5/23
* @Param [java.util.Map<java.lang.String, java.lang.Object>]
*/
BsProductDiscount getProductDiscountByMap(Map<String, Object> map);
/**
* @return com.hai.entity.BsProductPlatform
* @Author Sum1Dream
* @name getProductPlatformByMap.java
* @Description // 查询展示平台
* @Date 14:18 2022/5/23
* @Param [java.util.Map<java.lang.String, java.lang.Object>]
*/
String getProductPlatformByMap(Map<String, Object> map);
/**
* @Author Sum1Dream
* @name geProductPayTypeByMap.java
* @Description // 查询支付方式
* @Date 14:20 2022/5/23
* @Param [java.util.Map<java.lang.String,java.lang.Object>]
* @return java.lang.String
*/
String getProductPayTypeByMap(Map<String, Object> map);
}

@ -0,0 +1,36 @@
package com.hai.service;
import com.alibaba.fastjson.JSONObject;
import com.hai.entity.BsOperationLog;
import com.hai.entity.OutRechargePrice;
import java.util.List;
import java.util.Map;
/**
* @serviceName BsOperationLogService.java
* @author Sum1Dream
* @version 1.0.0
* @Description // 操作日志
* @createTime 11:02 2022/5/24
**/
public interface BsOperationLogService {
/**
* @Author Sum1Dream
* @Description //查询列表 Administrator
* @Date 17:38 2021/6/12
* @Param [map]
* @return java.util.List<com.hai.entity.OutRechargePrice>
**/
List<BsOperationLog> getListOperationLog(Map<String , Object> map);
/**
* @Author Sum1Dream
* @Description //新增 Administrator
* @Date 17:40 2021/6/12
* @Param [outRechargePrice]
* @return void
**/
void insertOperationLog(BsOperationLog bsOperationLog);
}

@ -0,0 +1,45 @@
package com.hai.service;
import com.hai.entity.BsRequestRecord;
/**
* @serviceName BsRequestRecordService.java
* @author Sum1Dream
* @version 1.0.0
* @Description // 请求记录
* @createTime 11:02 2022/5/25
**/
public interface BsRequestRecordService {
/**
* @Author Sum1Dream
* @name insertRequestRecord.java
* @Description // 插入请求记录
* @Date 11:03 2022/5/25
* @Param [com.hai.entity.BsRequestRecord]
* @return void
*/
void insertRequestRecord(BsRequestRecord bsRequestRecord);
/**
* @Author Sum1Dream
* @name updateRequestRecord.java
* @Description // 更新请求记录
* @Date 11:03 2022/5/25
* @Param [com.hai.entity.BsRequestRecord]
* @return void
*/
void updateRequestRecord(BsRequestRecord bsRequestRecord);
/**
* @Author Sum1Dream
* @name findRequestRecordBySourceId.java
* @Description // 查询请求详情
* @Date 15:25 2022/5/25
* @Param [java.String.String]
* @return com.hai.entity.BsRequestRecord
*/
BsRequestRecord findRequestRecordByOrderNo(String orderNo);
}

@ -1,55 +0,0 @@
package com.hai.service;
import com.alibaba.fastjson.JSONObject;
/**
* @serviceName HltMerchantService.java
* @author Sum1Dream
* @version 1.0.0
* @Description // 测试接口
* @createTime 11:46 上午 2021/12/15
**/
public interface HighTestService {
/**
* @Author Sum1Dream
* @name getReadFile.java
* @Description //读取文件
* @Date 5:31 下午 2021/12/16
* @Param []
* @return void
*/
void getReadFile() throws Exception;
/**
* @Author Sum1Dream
* @name getUserDiscount.java
* @Description // 赠送用户卡券
* @Date 7:14 下午 2021/12/24
* @Param []
* @return void
*/
void getUserDiscount(Long id) throws Exception;
/**
* @Author Sum1Dream
* @name getMobile.java
* @Description // 请求话费
* @Date 5:02 下午 2022/1/17
* @Param [java.lang.String]
* @return com.alibaba.fastjson.JSONObject
*/
JSONObject getMobile(String phone , Integer amount , String orderNo) throws Exception;
/**
* @Author Sum1Dream
* @name findByLatAndLng.java
* @Description // 获取定位信息
* @Date 10:59 2022/4/2
* @Param [java.lang.String, java.lang.String]
* @return com.alibaba.fastjson.JSONObject
*/
JSONObject findByLatAndLng( String lng , String lat) throws Exception;
}

@ -1,11 +1,13 @@
package com.hai.service; package com.hai.service;
import com.hai.entity.OutRechargeChildOrder;
import com.hai.entity.OutRechargeOrder; import com.hai.entity.OutRechargeOrder;
import com.hai.entity.OutRechargeOrderRecord; import com.hai.entity.OutRechargeOrderRecord;
import java.util.List; import java.util.List;
import java.util.Map;
public interface OutRechargeOrderRecordService { public interface OutRechargeChildOrderService {
/** /**
* @Author Sum1Dream * @Author Sum1Dream
@ -15,7 +17,7 @@ public interface OutRechargeOrderRecordService {
* @Param [] * @Param []
* @return java.util.List<com.hai.entity.OutRechargeOrderRecord> * @return java.util.List<com.hai.entity.OutRechargeOrderRecord>
*/ */
List<OutRechargeOrderRecord> getListRechargeOrderRecord(); List<OutRechargeChildOrder> getListRechargeChildOrder(Map<String, Object> map);
/** /**
* @Author Sum1Dream * @Author Sum1Dream
@ -25,17 +27,17 @@ public interface OutRechargeOrderRecordService {
* @Param [Long id] * @Param [Long id]
* @return com.hai.entity.OutRechargeOrderRecord * @return com.hai.entity.OutRechargeOrderRecord
*/ */
OutRechargeOrderRecord findById(Long id); OutRechargeChildOrder findById(Long id);
/** /**
* @Author Sum1Dream * @Author Sum1Dream
* @name findById.java * @name findById.java
* @Description // 根据订单ID查询 * @Description // 根据订单查询
* @Date 2:32 下午 2022/2/11 * @Date 2:32 下午 2022/2/11
* @Param [Long id] * @Param [Long id]
* @return com.hai.entity.OutRechargeOrderRecord * @return com.hai.entity.OutRechargeOrderRecord
*/ */
OutRechargeOrderRecord findByOrderNo(String orderNo); OutRechargeChildOrder findByOrderNo(String orderNo);
/** /**
* @Author Sum1Dream * @Author Sum1Dream
@ -45,7 +47,7 @@ public interface OutRechargeOrderRecordService {
* @Param [Long id] * @Param [Long id]
* @return com.hai.entity.OutRechargeOrderRecord * @return com.hai.entity.OutRechargeOrderRecord
*/ */
OutRechargeOrderRecord findByOrderId(Long orderId); OutRechargeChildOrder findByOrderId(Long orderId);
/*** /***
* @Author Sum1Dream * @Author Sum1Dream
@ -54,7 +56,7 @@ public interface OutRechargeOrderRecordService {
* @Param [rechargeOrderRecord] * @Param [rechargeOrderRecord]
* @return void * @return void
**/ **/
void insertOrder(OutRechargeOrderRecord rechargeOrderRecord); void insertOrder(OutRechargeChildOrder rechargeChildOrder);
/*** /***
* @Author Sum1Dream * @Author Sum1Dream
@ -63,6 +65,6 @@ public interface OutRechargeOrderRecordService {
* @Param [rechargeOrderRecord] * @Param [rechargeOrderRecord]
* @return void * @return void
**/ **/
void updateOrder(OutRechargeOrderRecord rechargeOrderRecord); void updateOrder(OutRechargeChildOrder rechargeChildOrder);
} }

@ -1,6 +1,7 @@
package com.hai.service; package com.hai.service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hai.entity.HighUserCard;
import com.hai.entity.OutRechargeOrder; import com.hai.entity.OutRechargeOrder;
import com.hai.model.OrderCountModel; import com.hai.model.OrderCountModel;
import com.hai.model.OutOrderModel; import com.hai.model.OutOrderModel;
@ -48,7 +49,7 @@ public interface OutRechargeOrderService {
* @Param [outRechargeOrder] * @Param [outRechargeOrder]
* @return void * @return void
**/ **/
void insertOrder(OutRechargeOrder outRechargeOrder); void insertOrder(OutRechargeOrder outRechargeOrder) throws Exception;
/*** /***
* @Author Sum1Dream * @Author Sum1Dream
@ -114,17 +115,15 @@ public interface OutRechargeOrderService {
List<OutUserOrderModel> getUserCountList(Map<String , String> map) throws Exception; List<OutUserOrderModel> getUserCountList(Map<String , String> map) throws Exception;
/** /**
* 汇联通支付 * @Author Sum1Dream
* @param orderId * @name hltUnionCardPay.java
*/ * @Description // 汇联通支付
void hltUnionCardPay(Long userCardId, Long orderId) throws Exception; * @Date 17:21 2022/5/25
* @Param [java.lang.Long, com.hai.entity.OutRechargeOrder]
* @return void
*/
void hltUnionCardPay(HighUserCard userCard, OutRechargeOrder order) throws Exception;
/**
* 积分支付
* @param userId
* @param orderId
*/
void goldPayOrder(Long userId, Long orderId) throws Exception;
/** /**
* @Author Sum1Dream * @Author Sum1Dream
@ -146,16 +145,6 @@ public interface OutRechargeOrderService {
*/ */
OrderCountModel rechargeOrderByIndex(Integer code); OrderCountModel rechargeOrderByIndex(Integer code);
/**
* @Author Sum1Dream
* @name getMobile.java
* @Description // 请求话费充值
* @Date 5:02 下午 2022/1/17
* @Param [java.lang.String]
* @return com.alibaba.fastjson.JSONObject
*/
JSONObject getMobile(String phone , Integer amount , String orderNo , Integer isFast) throws Exception;
/** /**
* @Author Sum1Dream * @Author Sum1Dream
* @name orderToRefund.java * @name orderToRefund.java
@ -166,4 +155,14 @@ public interface OutRechargeOrderService {
*/ */
void rechargeOrderToRefund(Long orderId) throws Exception; void rechargeOrderToRefund(Long orderId) throws Exception;
/**
* @Author Sum1Dream
* @name pollRequest.java
* @Description // 充值轮询
* @Date 16:32 2022/5/25
* @Param [com.hai.entity.OutRechargeOrder]
* @return void
*/
void pollRequest(OutRechargeOrder outRechargeOrder) throws Exception;
} }

@ -2,6 +2,7 @@ package com.hai.service;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hai.entity.OutRechargePrice; import com.hai.entity.OutRechargePrice;
import com.hai.model.OutRechargePriceModel;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -24,7 +25,7 @@ public interface OutRechargePriceService {
* @Param [map] * @Param [map]
* @return java.util.List<com.hai.entity.OutRechargePrice> * @return java.util.List<com.hai.entity.OutRechargePrice>
**/ **/
List<OutRechargePrice> getListRechargePriceC(Map<String , String> map); List<OutRechargePrice> getRechargePriceByList(Map<String , Object> map);
/** /**
* @Author Sum1Dream * @Author Sum1Dream
@ -33,7 +34,7 @@ public interface OutRechargePriceService {
* @Param [id] * @Param [id]
* @return com.hai.entity.OutRechargePrice * @return com.hai.entity.OutRechargePrice
**/ **/
OutRechargePrice findById(Long id); OutRechargePriceModel findById(Long id);
/** /**
* @Author Sum1Dream * @Author Sum1Dream
@ -51,7 +52,17 @@ public interface OutRechargePriceService {
* @Param [outRechargePrice] * @Param [outRechargePrice]
* @return void * @return void
**/ **/
void updateRechargePrice(OutRechargePrice outRechargePrice); void updateRechargePrice(JSONObject object);
/**
* @Author Sum1Dream
* @name editPriceStatus.java
* @Description // 修改价格状态
* @Date 18:18 2022/5/23
* @Param [com.hai.entity.OutRechargePrice]
* @return void
*/
void editPriceStatus(OutRechargePrice outRechargePrice);
/** /**
* @Author Sum1Dream * @Author Sum1Dream
@ -61,4 +72,14 @@ public interface OutRechargePriceService {
* @return void * @return void
**/ **/
void deletePrice(Long id); void deletePrice(Long id);
/**
* @Author Sum1Dream
* @name getProductList.java
* @Description // 获取商品列表
* @Date 09:56 2022/5/24
* @Param []
* @return com.alibaba.fastjson.JSONObject
*/
JSONObject getProductList();
} }

@ -0,0 +1,107 @@
package com.hai.service.impl;
import com.hai.dao.BsProductDiscountMapper;
import com.hai.dao.BsProductPayTypeMapper;
import com.hai.dao.BsProductPlatformMapper;
import com.hai.entity.*;
import com.hai.service.BsConfigService;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@Service(value = "bsConfigService")
public class BsConfigServiceImpl implements BsConfigService {
@Resource
private BsProductDiscountMapper bsProductDiscountMapper;
@Resource
private BsProductPayTypeMapper bsProductPayTypeMapper;
@Resource
private BsProductPlatformMapper bsProductPlatformMapper;
@Override
public BsProductDiscount getProductDiscountByMap(Map<String, Object> map) {
BsProductDiscountExample example = new BsProductDiscountExample();
BsProductDiscountExample.Criteria criteria = example.createCriteria();
if (MapUtils.getInteger(map , "productType") != null) {
criteria.andProductTypeEqualTo(MapUtils.getInteger(map , "productType"));
}
if (MapUtils.getLong(map , "sourceId") != null) {
criteria.andSourceIdEqualTo(MapUtils.getLong(map , "sourceId"));
}
if (bsProductDiscountMapper.selectByExample(example) == null) {
return null;
}
return bsProductDiscountMapper.selectByExample(example).get(0);
}
@Override
public String getProductPlatformByMap(Map<String, Object> map) {
BsProductPlatformExample example = new BsProductPlatformExample();
BsProductPlatformExample.Criteria criteria = example.createCriteria();
if (MapUtils.getInteger(map , "productType") != null) {
criteria.andProductTypeEqualTo(MapUtils.getInteger(map , "productType"));
}
if (MapUtils.getLong(map , "sourceId") != null) {
criteria.andSourceIdEqualTo(MapUtils.getLong(map , "sourceId"));
}
List<BsProductPlatform> list = bsProductPlatformMapper.selectByExample(example);
StringBuilder string = new StringBuilder();
StringBuilder stringName = new StringBuilder();
for (BsProductPlatform productPlatform : list) {
stringName.append(productPlatform.getPlatformName()).append(",");
string.append(productPlatform.getPlatformId()).append(",");
}
if (MapUtils.getInteger(map , "returnType") == 1) {
return string.toString();
} else {
return stringName.toString();
}
}
@Override
public String getProductPayTypeByMap(Map<String, Object> map) {
BsProductPayTypeExample example = new BsProductPayTypeExample();
BsProductPayTypeExample.Criteria criteria = example.createCriteria();
if (MapUtils.getInteger(map , "productType") != null) {
criteria.andProductTypeEqualTo(MapUtils.getInteger(map , "productType"));
}
if (MapUtils.getLong(map , "sourceId") != null) {
criteria.andSourceIdEqualTo(MapUtils.getLong(map , "sourceId"));
}
List<BsProductPayType> list = bsProductPayTypeMapper.selectByExample(example);
StringBuilder stringName = new StringBuilder();
StringBuilder string = new StringBuilder();
for (BsProductPayType productPayType : list) {
stringName.append(productPayType.getPayTypeName()).append(",");
string.append(productPayType.getPayTypeId()).append(",");
}
if (MapUtils.getInteger(map , "returnType") == 1) {
return string.toString();
} else {
return stringName.toString();
}
}
}

@ -0,0 +1,30 @@
package com.hai.service.impl;
import com.hai.dao.BsOperationLogMapper;
import com.hai.entity.BsOperationLog;
import com.hai.service.BsOperationLogService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;
@Service("bsOperationLogService")
public class BsOperationLogServiceImpl implements BsOperationLogService {
@Resource
private BsOperationLogMapper bsOperationLogMapper;
@Override
public List<BsOperationLog> getListOperationLog(Map<String, Object> map) {
return null;
}
@Override
public void insertOperationLog(BsOperationLog bsOperationLog) {
bsOperationLog.setCreateTime(new Date());
bsOperationLog.setUpdateTime(new Date());
bsOperationLogMapper.insert(bsOperationLog);
}
}

@ -0,0 +1,42 @@
package com.hai.service.impl;
import com.hai.dao.BsRequestRecordMapper;
import com.hai.entity.BsRequestRecord;
import com.hai.entity.BsRequestRecordExample;
import com.hai.service.BsRequestRecordService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service("bsRequestRecordService")
public class BsRequestRecordServiceImpl implements BsRequestRecordService {
@Resource
private BsRequestRecordMapper bsRequestRecordMapper;
@Override
public void insertRequestRecord(BsRequestRecord bsRequestRecord) {
bsRequestRecordMapper.insert(bsRequestRecord);
}
@Override
public void updateRequestRecord(BsRequestRecord bsRequestRecord) {
bsRequestRecordMapper.updateByPrimaryKey(bsRequestRecord);
}
@Override
public BsRequestRecord findRequestRecordByOrderNo(String orderNo) {
BsRequestRecordExample example = new BsRequestRecordExample();
example.createCriteria().andOrderNoEqualTo(orderNo);
List<BsRequestRecord> list = bsRequestRecordMapper.selectByExample(example);
if (list.size() > 0) {
return list.get(0);
}
return null;
}
}

@ -659,7 +659,7 @@ public class CommonServiceImpl implements CommonService {
if (list.size() > 0) { if (list.size() > 0) {
for (BsProductPlatform productPlatform : list) { for (BsProductPlatform productPlatform : list) {
bsProductDiscountMapper.deleteByPrimaryKey(productPlatform.getId()); bsProductPlatformMapper.deleteByPrimaryKey(productPlatform.getId());
} }
} }

@ -1,176 +0,0 @@
package com.hai.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.pay.util.sdk.WXPayConstants;
import com.hai.common.utils.*;
import com.hai.config.CommonSysConst;
import com.hai.dao.HighUserEtcMapper;
import com.hai.entity.HighDiscountAgentCode;
import com.hai.entity.HighUser;
import com.hai.entity.HighUserEtc;
import com.hai.service.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service("highTestService")
public class HighTestServiceImpl implements HighTestService {
private static Logger log = LoggerFactory.getLogger(HighTestService.class);
@Resource
private HighUserService highUserService;
@Resource
private HighUserEtcMapper highUserEtcMapper;
@Resource
private HighDiscountAgentCodeService highDiscountAgentCodeService;
@Resource
private HighDiscountUserRelService highDiscountUserRelService;
@Autowired
private RedisUtil redisUtil;
@Override
@Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW)
public void getReadFile() throws Exception {
// BufferedReader bufferedReader = null;
//
// Map<String , String> mapUser = new HashMap<>();
//
// //cookie过期时间为7天
// int EXPIRE = 3600*24*7;
//
// List<HighUser> highUsers = highUserService.getListUser(mapUser);
//
// for (HighUser user: highUsers) {
// redisUtil.set(user.getPhone(), user.getPhone(), EXPIRE);
// }
//
// FileReader fileReader = new FileReader("/home/project/hsg/readFile/etccq.txt");
// if (fileReader == null) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "读取空数据");
// }
//
// bufferedReader = new BufferedReader(fileReader);
// String temp = bufferedReader.readLine();
// int i = 0;
// while (temp != null) {
// i++;
// String[] arr = temp.split(";");
//
// String phone = (String) redisUtil.get(arr[3]);
//
// if (phone == null || highUsers.size() == 0) {
// HighUser user = new HighUser();
//
// user.setStatus(1);
// user.setInfoCompleteStatus(1);
// user.setGold(0);
// user.setRegTime(new Date());
// user.setName(arr[2]);
// user.setPhone(arr[3]);
// user.setExt4("1");
//
// highUserService.insertUser(user);
//
// HighUserEtc userEtc = new HighUserEtc();
//
// userEtc.setCreateTime(new Date());
// userEtc.setStatus(1);
// userEtc.setUserId(user.getId());
// userEtc.setCustomerName(arr[2]);
// userEtc.setCustomerTel(arr[3]);
// userEtc.setVehicleId(arr[0]);
// userEtc.setVehiclePlate(arr[1]);
//
// highUserEtcMapper.insert(userEtc);
//
//// Map<String , Object> map = new HashMap<>();
//// map.put("userId" , user.getId());
//// map.put("userPhone" , user.getPhone());
//// map.put("discountPackageId" , 48);
//
//// highDiscountPackageService.freeUserDiscountPackage(map);
// }
//
// temp = bufferedReader.readLine();
// }
}
@Override
@Transactional(rollbackFor=Exception.class,propagation= Propagation.REQUIRES_NEW)
public void getUserDiscount(Long id) throws Exception{
List<HighDiscountAgentCode> codeList = highDiscountAgentCodeService.getDiscountCodeByStatus(id , 1);
Map<String , String> map = new HashMap<>();
map.put("ext4" , "1");
List<HighUser> userList = highUserService.getListUser(map);
int num = 0;
for (HighUser user : userList) {
// 领取优惠券
highDiscountUserRelService.receiveDiscount(user.getId(), codeList.get(num).getId());
num++;
}
}
@Override
public JSONObject getMobile(String phone , Integer amount , String orderNo) throws Exception {
String timestamp = String.valueOf(System.currentTimeMillis());
Map<String , Object> map = new HashMap<>();
map.put("mobile" , phone);
map.put("amount" , amount);
map.put("out_order_id" , orderNo);
map.put("app_key" , CommonSysConst.getSysConfig().getCzAppKey());
map.put("timestamp" , timestamp.substring(0,timestamp.length()-3));
map.put("is_fast" , "1");
map.put("notify_url" , CommonSysConst.getSysConfig().getCzNotifyUrl());
String signStr = WxUtils.generateSignatureAppSecret(map, CommonSysConst.getSysConfig().getTelApiSecret() , WXPayConstants.SignType.MD5);
map.put("sign" , signStr);
return HttpsUtils.doPost(CommonSysConst.getSysConfig().getCzUrl() , map);
}
@Override
public JSONObject findByLatAndLng(String lng, String lat) throws Exception {
Map<String,Object> map = new HashMap<>();//参数
map.put("ak", "SfrwGH7INvjPq7BwCrYrioBQZm9XXxrR");//申请百度开放平台KEY(ak)
map.put("output", "json");// 输出Json数据
map.put("extensions_town", "true");// 行政区划返回乡镇级数据(town),仅国内召回乡镇数据
map.put("coordtype", "wgs84ll"); // GPS 经纬度类型
map.put("location", lat+","+lng+"");//百度经纬度
String url = "http://api.map.baidu.com/reverse_geocoding/v3/";
return HttpsUtils.doGet(url , map);
}
}

@ -0,0 +1,64 @@
package com.hai.service.impl;
import com.hai.dao.OutRechargeChildOrderMapper;
import com.hai.dao.OutRechargeOrderRecordMapper;
import com.hai.entity.OutRechargeChildOrder;
import com.hai.entity.OutRechargeChildOrderExample;
import com.hai.entity.OutRechargeOrderRecord;
import com.hai.entity.OutRechargeOrderRecordExample;
import com.hai.service.OutRechargeChildOrderService;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@Service("outRechargeChildOrderService")
public class OutRechargeChildOrderServiceImpl implements OutRechargeChildOrderService {
@Resource
private OutRechargeChildOrderMapper rechargeChildOrderMapper;
@Override
public List<OutRechargeChildOrder> getListRechargeChildOrder(Map<String, Object> map) {
OutRechargeChildOrderExample example = new OutRechargeChildOrderExample();
OutRechargeChildOrderExample.Criteria criteria = example.createCriteria();
if (MapUtils.getLong(map , "parent_order_id") != null) {
criteria.andParentOrderIdEqualTo(MapUtils.getLong(map , "parent_order_id"));
}
if (MapUtils.getInteger(map , "status") != null) {
criteria.andStatusEqualTo(MapUtils.getInteger(map , "status"));
}
return rechargeChildOrderMapper.selectByExample(example);
}
@Override
public OutRechargeChildOrder findById(Long id) {
return rechargeChildOrderMapper.selectByPrimaryKey(id);
}
@Override
public OutRechargeChildOrder findByOrderNo(String orderNo) {
return null;
}
@Override
public OutRechargeChildOrder findByOrderId(Long orderId) {
return null;
}
@Override
public void insertOrder(OutRechargeChildOrder rechargeChildOrder) {
rechargeChildOrderMapper.insert(rechargeChildOrder);
}
@Override
public void updateOrder(OutRechargeChildOrder rechargeChildOrder) {
rechargeChildOrderMapper.updateByPrimaryKey(rechargeChildOrder);
}
}

@ -1,60 +0,0 @@
package com.hai.service.impl;
import com.hai.dao.OutRechargeOrderRecordMapper;
import com.hai.entity.OutRechargeOrderRecord;
import com.hai.entity.OutRechargeOrderRecordExample;
import com.hai.service.OutRechargeOrderRecordService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
@Service("outRechargeOrderRecordService")
public class OutRechargeOrderRecordServiceImpl implements OutRechargeOrderRecordService {
@Resource
private OutRechargeOrderRecordMapper rechargeOrderRecordMapper;
@Override
public List<OutRechargeOrderRecord> getListRechargeOrderRecord() {
return null;
}
@Override
public OutRechargeOrderRecord findById(Long id) {
return null;
}
@Override
public OutRechargeOrderRecord findByOrderNo(String orderNo) {
OutRechargeOrderRecordExample example = new OutRechargeOrderRecordExample();
example.createCriteria().andRechargeOrderNoEqualTo(orderNo);
if (rechargeOrderRecordMapper.selectByExample(example).size() == 0) {
return null;
} else {
return rechargeOrderRecordMapper.selectByExample(example).get(0);
}
}
@Override
public OutRechargeOrderRecord findByOrderId(Long orderId) {
OutRechargeOrderRecordExample example = new OutRechargeOrderRecordExample();
example.createCriteria().andRechargeOrderIdEqualTo(orderId);
if (rechargeOrderRecordMapper.selectByExample(example).size() == 0) {
return null;
} else {
return rechargeOrderRecordMapper.selectByExample(example).get(0);
}
}
@Override
public void insertOrder(OutRechargeOrderRecord rechargeOrderRecord) {
rechargeOrderRecordMapper.insert(rechargeOrderRecord);
}
@Override
public void updateOrder(OutRechargeOrderRecord rechargeOrderRecord) {
rechargeOrderRecordMapper.updateByPrimaryKey(rechargeOrderRecord);
}
}

@ -8,15 +8,13 @@ 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.utils.*; import com.hai.common.utils.*;
import com.hai.config.CommonSysConfig; import com.hai.config.*;
import com.hai.config.CommonSysConst;
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.enum_type.RechargePayType;
import com.hai.model.*; import com.hai.model.*;
import com.hai.service.*; import com.hai.service.*;
import com.hai.service.pay.impl.GoodsOrderServiceImpl; import com.hai.service.pay.impl.GoodsOrderServiceImpl;
@ -60,6 +58,9 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
@Resource @Resource
private OutRechargeOrderService outRechargeOrderService; private OutRechargeOrderService outRechargeOrderService;
@Resource
private OutRechargePriceService outRechargePriceService;
@Resource @Resource
private GoodsOrderServiceImpl goodsOrderService; private GoodsOrderServiceImpl goodsOrderService;
@ -69,6 +70,12 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
@Resource @Resource
private HighDiscountAgentCodeService highDiscountAgentCodeService; private HighDiscountAgentCodeService highDiscountAgentCodeService;
@Resource
private OutRechargeChildOrderService outRechargeChildOrderService;
@Resource
private BsRequestRecordService bsRequestRecordService;
@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();
@ -128,7 +135,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
@Override @Override
@Transactional(propagation= Propagation.REQUIRES_NEW) @Transactional(propagation= Propagation.REQUIRES_NEW)
public void insertOrder(OutRechargeOrder outRechargeOrder) { public void insertOrder(OutRechargeOrder outRechargeOrder) throws Exception {
// 使用优惠券 // 使用优惠券
if (outRechargeOrder.getMemDiscountId() != null) { if (outRechargeOrder.getMemDiscountId() != null) {
HighDiscountUserRel discountUserRel = highDiscountUserRelService.getRelById(outRechargeOrder.getMemDiscountId()); HighDiscountUserRel discountUserRel = highDiscountUserRelService.getRelById(outRechargeOrder.getMemDiscountId());
@ -141,6 +148,11 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
highDiscountAgentCodeService.updateCode(code); highDiscountAgentCodeService.updateCode(code);
} }
outRechargeOrderMapper.insert(outRechargeOrder); outRechargeOrderMapper.insert(outRechargeOrder);
if (outRechargeOrder.getRechargeStatus() == 201 && outRechargeOrder.getPayStatus() == 102) {
pollRequest(outRechargeOrder);
}
} }
@Override @Override
@ -308,87 +320,55 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
} }
@Override @Override
public void hltUnionCardPay(Long userCardId, Long orderId) throws Exception { public void hltUnionCardPay(HighUserCard userCard, OutRechargeOrder order) throws Exception {
HighUserCard userCard = highUserCardService.getDetailById(userCardId);
if(userCard == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到用户绑定的卡号信息");
}
OutRechargeOrder order = findByOrderId(orderId);
if (order == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "未找到订单信息");
}
String goodsDesc = "充值话费"; String goodsDesc = "充值话费";
// String tranDesc = order.getRechargeContent() + "充值" + order.getPayPrice() +"元话费"; String tranDesc = order.getRechargeContent() + "充值" + order.getPayRealPrice() +"元话费";
String instCode = "11101290"; String instCode = "11101290";
String businessType = "hisen_consume"; String businessType = "hisen_consume";
// 工会卡支付 // 工会卡支付
// JSONObject consumption = HuiLianTongUnionCardConfig.consumption(order.getOrderNo(), userCard.getCardNo(), order.getPayPrice(), businessType, instCode, goodsDesc, tranDesc); JSONObject consumption = HuiLianTongUnionCardConfig.consumption(order.getOrderNo(), userCard.getCardNo(), order.getPayRealPrice(), businessType, instCode, goodsDesc, tranDesc);
// System.out.println("工会卡支付响应参数" + consumption.toJSONString()); System.out.println("工会卡支付响应参数" + consumption.toJSONString());
Map<String,Object> dataMap = new HashMap<>(); Map<String,Object> dataMap = new HashMap<>();
dataMap.put("orderNo", order.getOrderNo()); dataMap.put("orderNo", order.getOrderNo());
dataMap.put("cardType", "ghk"); dataMap.put("cardType", "ghk");
dataMap.put("cardNo", userCard.getCardNo()); dataMap.put("cardNo", userCard.getCardNo());
dataMap.put("checkPassword", "N"); dataMap.put("checkPassword", "N");
// dataMap.put("tranAmount", order.getPayPrice()); dataMap.put("tranAmount", order.getPayRealPrice());
dataMap.put("tranChannel", "HiSen"); dataMap.put("tranChannel", "HiSen");
dataMap.put("businessType", businessType); dataMap.put("businessType", businessType);
dataMap.put("instCode", instCode); dataMap.put("instCode", instCode);
dataMap.put("goodsDesc", goodsDesc); dataMap.put("goodsDesc", goodsDesc);
// dataMap.put("tranDesc", tranDesc); dataMap.put("tranDesc", tranDesc);
HighGasOrderPush payPush = new HighGasOrderPush(); HighGasOrderPush payPush = new HighGasOrderPush();
payPush.setType(OrderPushType.type5.getType()); payPush.setType(OrderPushType.type5.getType());
payPush.setOrderNo(order.getOrderNo()); payPush.setOrderNo(order.getOrderNo());
payPush.setCreateTime(new Date()); payPush.setCreateTime(new Date());
// payPush.setCode(consumption.getString("respCode")); payPush.setCode(consumption.getString("respCode"));
// payPush.setRequestContent(JSON.toJSONString(dataMap)); payPush.setRequestContent(JSON.toJSONString(dataMap));
// payPush.setReturnContent(consumption.toJSONString()); payPush.setReturnContent(consumption.toJSONString());
highGasOrderPushMapper.insert(payPush); highGasOrderPushMapper.insert(payPush);
// if(!consumption.getString("respCode").equals("0000")) { if(!consumption.getString("respCode").equals("0000")) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumption.getString("respMessage")); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumption.getString("respMessage"));
// } }
// JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(consumption.getString("data")); JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(consumption.getString("data"));
// if (!consumptionResult.getBoolean("success")) { if (!consumptionResult.getBoolean("success")) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumptionResult.getString("message")); throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumptionResult.getString("message"));
// } }
// order.setPaySerialNo(consumptionResult.getString("orderId")); // 支付流水号 order.setPaySerialNo(consumptionResult.getString("orderId")); // 支付流水号
// order.setPayRealPrice(order.getPayPrice()); // 实付金额 order.setPayRealPrice(order.getPayRealPrice()); // 实付金额
// if (order.getRechargeType() == 1) { outRechargeOrderService.pollRequest(order);
// JSONObject object = outRechargeOrderService.getMobile(order.getRechargeContent() , order.getOrderPrice().intValue() , order.getOrderNo() ,order.getRechargeType()); order.setPayStatus(102);
// if (object.getInteger("code") != 200) { order.setRechargeStatus(201);
// order.setRechargeStatus(1); order.setLaborUnionCard(userCard.getCardNo());
// order.setAbnormalMsg(object.getString("message")); order.setPayType(3);
// }
// }
// order.setStatus(2);
order.setPayType(2);
order.setPayTime(new Date()); // 支付时间 order.setPayTime(new Date()); // 支付时间
updateOrder(order); updateOrder(order);
} }
@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);
}
@Override @Override
public List<OutRechargeOrder> getOutRechargeOrderList() { public List<OutRechargeOrder> getOutRechargeOrderList() {
return outRechargeOrderMapper.getCloseOrder(); return outRechargeOrderMapper.getCloseOrder();
@ -399,137 +379,102 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
return outRechargeOrderMapper.rechargeOrderByIndex(code); return outRechargeOrderMapper.rechargeOrderByIndex(code);
} }
@Override @Override
public JSONObject getMobile(String phone , Integer amount , String orderNo , Integer isFast) throws Exception { @Transactional(propagation= Propagation.REQUIRES_NEW)
public void rechargeOrderToRefund(Long orderId) throws Exception {
OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId);
if (isFast == 2) { // 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
isFast = 0; if (order.getPayStatus() != 102) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态");
} }
String timestamp = String.valueOf(System.currentTimeMillis()); // 微信退款
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.setPayStatus(105);
order.setRechargeStatus(203);
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());
}
}
Map<String , Object> map = new HashMap<>(); // 工会卡退款
map.put("mobile" , phone); if (order.getPayType() == 2) {
map.put("amount" , amount); JSONObject jsonObject = HuiLianTongUnionCardConfig.refund( "HFR"+new Date().getTime() , order.getOrderNo());
map.put("out_order_id" , orderNo);
map.put("app_key" , CommonSysConst.getSysConfig().getCzAppKey());
map.put("timestamp" , timestamp.substring(0,timestamp.length()-3));
map.put("is_fast" , isFast);
map.put("notify_url" , CommonSysConst.getSysConfig().getCzNotifyUrl());
String signStr = WxUtils.generateSignatureAppSecret(map, CommonSysConst.getSysConfig().getCzAppSecret() , WXPayConstants.SignType.MD5); if (jsonObject == null) {
jsonObject = HuiLianTongUnionCardConfig.refund( "HFR"+new Date().getTime() , order.getOrderNo());
}
map.put("sign" , signStr); JSONObject dataObject = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data"));
return HttpsUtils.doPost(CommonSysConst.getSysConfig().getCzUrl() + "createOrder" , map); if (dataObject.getBoolean("success") || Objects.equals(dataObject.getString("message"), "原交易已撤销,不可再次操作")) {
} order.setPayStatus(105);
order.setRechargeStatus(203);
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"));
}
}
@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);
// }
// }
// 银联退款
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.setPayStatus(105);
order.setRechargeStatus(203);
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);
}
}
} }
public String doRefundRequest(String mchId,String data) throws Exception { public String doRefundRequest(String mchId,String data) throws Exception {
@ -561,4 +506,88 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
httpClient.close(); httpClient.close();
} }
} }
@Override
@Transactional(propagation = Propagation.REQUIRED, rollbackFor = Exception.class)
public void pollRequest(OutRechargeOrder outRechargeOrder) throws Exception {
// 查询充值产品
OutRechargePriceModel outRechargePrice = outRechargePriceService.findById(outRechargeOrder.getGoodsId());
// 查询充值子订单
Map<String, Object> childOrderMap = new HashMap<>();
childOrderMap.put("parent_order_id" , outRechargeOrder.getId());
childOrderMap.put("status" , 102);
List<OutRechargeChildOrder> childOrderList = outRechargeChildOrderService.getListRechargeChildOrder(childOrderMap);
OutRechargeChildOrder childOrder = new OutRechargeChildOrder();
// 1:尖椒 2:龙阅 3:畅停
int type = 0;
int rechargePlatformType = 0;
// 判断子订单是否存在充值中订单
if (childOrderList.size() > 0) {
childOrder = childOrderList.get(0);
childOrder.setStatus(103);
childOrder.setUpdateTime(new Date());
outRechargeChildOrderService.updateOrder(childOrder);
type = childOrder.getRechargePlatform();
}
JSONObject object = new JSONObject();
String orderNo = "CZ" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5);
String[] rechargePlatform = outRechargePrice.getRechargePlatform().split("-");
for (String s : rechargePlatform) {
// 尖椒充值
if (s.equals("1") && type == 2) {
object.put("out_order_id" ,orderNo );
object.put("amount" , outRechargePrice.getRechargePrice());
object.put("mobile" , outRechargeOrder.getRechargeContent());
if (outRechargePrice.getRechargeType() == 1) {
object.put("is_fast" , 1);
}
RechargeConfig.rechargeOrderByJj(object);
rechargePlatformType = 1;
break;
}
if (s.equals("2") && (type == 1 || type == 0)) {
object.put("out_trade_num" , orderNo);
object.put("product_id" , outRechargePrice.getGoodsId());
object.put("mobile" , outRechargeOrder.getRechargeContent());
RechargeConfig.rechargeOrderByLy(object);
rechargePlatformType = 2;
break;
}
}
childOrder.setOrderNo(orderNo);
childOrder.setCreateTime(new Date());
childOrder.setParentOrderId(outRechargeOrder.getId());
childOrder.setStatus(102);
childOrder.setRechargePlatform(rechargePlatformType);
childOrder.setUpdateTime(new Date());
outRechargeChildOrderService.insertOrder(childOrder);
// 创建提交记录
BsRequestRecord requestRecord = new BsRequestRecord();
requestRecord.setCreateTime(new Date());
requestRecord.setUpdateTime(new Date());
requestRecord.setOrderNo(orderNo);
requestRecord.setRequestContent(String.valueOf(object));
requestRecord.setOperatorId(0L);
requestRecord.setOperatorName("系统生成");
requestRecord.setSourceId(childOrder.getId().toString());
requestRecord.setSourceType(1);
bsRequestRecordService.insertRequestRecord(requestRecord);
}
} }

@ -4,11 +4,14 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.hai.dao.OutRechargePriceMapper; import com.hai.dao.OutRechargePriceMapper;
import com.hai.entity.*; import com.hai.entity.*;
import com.hai.model.OutRechargePriceModel;
import com.hai.service.BsConfigService;
import com.hai.service.CommonService; import com.hai.service.CommonService;
import com.hai.service.OutRechargePriceService; import com.hai.service.OutRechargePriceService;
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.springframework.beans.BeanUtils;
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;
@ -16,9 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.util.Date; import java.util.*;
import java.util.List;
import java.util.Map;
@Service("outRechargePriceServiceImpl") @Service("outRechargePriceServiceImpl")
public class OutRechargePriceServiceImpl implements OutRechargePriceService { public class OutRechargePriceServiceImpl implements OutRechargePriceService {
@ -29,55 +30,67 @@ public class OutRechargePriceServiceImpl implements OutRechargePriceService {
@Resource @Resource
private CommonService commonService; private CommonService commonService;
@Resource
private BsConfigService bsConfigService;
@Override @Override
public List<OutRechargePrice> getListRechargePrice(Map<String , Object> map) { public List<OutRechargePrice> getListRechargePrice(Map<String, Object> map) {
OutRechargePriceExample example = new OutRechargePriceExample(); OutRechargePriceExample example = new OutRechargePriceExample();
OutRechargePriceExample.Criteria criteria = example.createCriteria(); OutRechargePriceExample.Criteria criteria = example.createCriteria();
if (MapUtils.getLong(map , "companyId") != null) { if (MapUtils.getLong(map, "companyId") != null) {
criteria.andCompanyIdEqualTo(MapUtils.getLong(map , "companyId")); criteria.andCompanyIdEqualTo(MapUtils.getLong(map, "companyId"));
} }
if (MapUtils.getLong(map , "rechargePlatform") != null) { if (MapUtils.getLong(map, "rechargePlatform") != null) {
criteria.andRechargePlatformLike("%-" +MapUtils.getLong(map , "rechargePlatform") + "-%"); criteria.andRechargePlatformLike("%" + MapUtils.getLong(map, "rechargePlatform") + "%");
} }
if (MapUtils.getLong(map , "rechargeType") != null) { if (MapUtils.getLong(map, "operatorType") != null) {
criteria.andRechargeTypeEqualTo(MapUtils.getInteger(map , "rechargeType")); criteria.andOperatorTypeEqualTo(MapUtils.getInteger(map, "operatorType"));
} }
if (MapUtils.getLong(map , "rechargeType") != null) { if (MapUtils.getLong(map, "rechargeType") != null) {
criteria.andRechargeTypeEqualTo(MapUtils.getInteger(map , "rechargeType")); criteria.andRechargeTypeEqualTo(MapUtils.getInteger(map, "rechargeType"));
} }
if (MapUtils.getLong(map, "status") != null) {
example.setOrderByClause("recharge_price asc"); criteria.andStatusEqualTo(MapUtils.getInteger(map, "status"));
return outRechargePriceMapper.selectByExample(example);
}
@Override
public List<OutRechargePrice> getListRechargePriceC(Map<String , String> map) {
OutRechargePriceExample example = new OutRechargePriceExample();
OutRechargePriceExample.Criteria criteria = example.createCriteria();
criteria.andStatusNotEqualTo(0);
if (StringUtils.isNotBlank(map.get("companyId"))) {
criteria.andCompanyIdEqualTo(Long.valueOf(map.get("companyId")));
} }
if (StringUtils.isNotBlank(map.get("rechargeType"))) { if (MapUtils.getLong(map, "rechargeWay") != null) {
criteria.andRechargeTypeEqualTo(Integer.valueOf(map.get("rechargeType"))); criteria.andRechargeWayEqualTo(MapUtils.getInteger(map, "rechargeWay"));
} }
example.setOrderByClause("sort asc"); example.setOrderByClause("sort asc");
return outRechargePriceMapper.selectByExample(example); return outRechargePriceMapper.selectByExample(example);
} }
@Override
public List<OutRechargePrice> getRechargePriceByList(Map<String, Object> map) {
return outRechargePriceMapper.getUserByPrice(map);
}
@Override @Override
public OutRechargePrice findById(Long id) { public OutRechargePriceModel findById(Long id) {
return outRechargePriceMapper.selectByPrimaryKey(id);
OutRechargePrice outRechargePrice = outRechargePriceMapper.selectByPrimaryKey(id);
OutRechargePriceModel outRechargePriceModel = new OutRechargePriceModel();
BeanUtils.copyProperties(outRechargePrice, outRechargePriceModel);
Map<String, Object> listMap = new HashMap<>();
listMap.put("productType", "3");
listMap.put("returnType", 1);
listMap.put("sourceId", outRechargePrice.getId());
outRechargePriceModel.setIntegralDiscount(bsConfigService.getProductDiscountByMap(listMap).getDiscount());
outRechargePriceModel.setProductPayTypeString(bsConfigService.getProductPayTypeByMap(listMap));
outRechargePriceModel.setProductPlatformString(bsConfigService.getProductPlatformByMap(listMap));
return outRechargePriceModel;
} }
@Override @Override
@Transactional(propagation= Propagation.REQUIRES_NEW) @Transactional(propagation = Propagation.REQUIRES_NEW)
public void insertRechargePrice(JSONObject object) { public void insertRechargePrice(JSONObject object) {
// 转换金额数组 // 转换金额数组
@ -95,7 +108,7 @@ public class OutRechargePriceServiceImpl implements OutRechargePriceService {
outRechargePrice.setDiscount(object.getBigDecimal("discount")); outRechargePrice.setDiscount(object.getBigDecimal("discount"));
outRechargePrice.setRechargeType(object.getInteger("rechargeType")); outRechargePrice.setRechargeType(object.getInteger("rechargeType"));
outRechargePrice.setOperatorType(object.getInteger("operatorType")); outRechargePrice.setOperatorType(object.getInteger("operatorType"));
outRechargePrice.setRechargePlatform("-" + StringUtils.join(object.getJSONArray("rechargePlatform") , "-") + "-"); outRechargePrice.setRechargePlatform("-" + StringUtils.join(object.getJSONArray("rechargePlatform"), "-") + "-");
outRechargePrice.setRechargeWay(object.getInteger("rechargeWay")); outRechargePrice.setRechargeWay(object.getInteger("rechargeWay"));
outRechargePrice.setCompanyId(object.getLong("companyId")); outRechargePrice.setCompanyId(object.getLong("companyId"));
outRechargePrice.setCreateTime(new Date()); outRechargePrice.setCreateTime(new Date());
@ -119,17 +132,54 @@ public class OutRechargePriceServiceImpl implements OutRechargePriceService {
// 配置展示平台 // 配置展示平台
commonService.configPlatform(postObject); commonService.configPlatform(postObject);
} }
}
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void updateRechargePrice(JSONObject object) {
OutRechargePrice outRechargePrice = outRechargePriceMapper.selectByPrimaryKey(object.getLong("id"));
outRechargePrice.setPayPrice(outRechargePrice.getRechargePrice().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(object.getInteger("sort"));
outRechargePrice.setGoodsId(object.getLong("goodsId"));
outRechargePriceMapper.updateByPrimaryKey(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 @Override
public void updateRechargePrice(OutRechargePrice outRechargePrice) { public void editPriceStatus(OutRechargePrice outRechargePrice) {
outRechargePriceMapper.updateByPrimaryKey(outRechargePrice); outRechargePriceMapper.updateByPrimaryKey(outRechargePrice);
} }
@Override @Override
public void deletePrice(Long id) { public void deletePrice(Long id) {
outRechargePriceMapper.deleteByPrimaryKey(id); outRechargePriceMapper.deleteByPrimaryKey(id);
} }
@Override
public JSONObject getProductList() {
return null;
}
} }

@ -8,7 +8,6 @@ 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.WxUtils; import com.hai.common.utils.WxUtils;
import com.hai.config.CommonSysConst; import com.hai.config.CommonSysConst;
import com.hai.config.TelConfig;
import com.hai.dao.HighGasOrderPushMapper; import com.hai.dao.HighGasOrderPushMapper;
import com.hai.entity.*; import com.hai.entity.*;
import com.hai.enum_type.OrderPushType; import com.hai.enum_type.OrderPushType;

@ -52,11 +52,17 @@ TelApiKey=2d01f6b520254b1a80f6b167832cea18
TelApiSecret=d11ee9b41e014a039f030e53ae6f5295 TelApiSecret=d11ee9b41e014a039f030e53ae6f5295
TelMemberId=d13091df65d64aafbf0f35d2093157b7 TelMemberId=d13091df65d64aafbf0f35d2093157b7
// Mobile # Jj
CzNotifyUrl = https://hsgcs.dctpay.com/crest/czOrder/rechargeCallback JjNotifyUrl = https://hsgcs.dctpay.com/crest/czOrder/rechargeCallback
CzAppKey = eaomqcbpdz7yjfih JjAppKey = eaomqcbpdz7yjfih
CzUrl = https://hfcs.dmjvip.com/index.php/third/mobile/ JjUrl = https://hfcs.dmjvip.com/index.php/third/mobile/
CzAppSecret = xkf9eoq2cjh6uvzp0mtrga134lnibdw8 JjAppSecret = xkf9eoq2cjh6uvzp0mtrga134lnibdw8
#LY
LyNotifyUrl = https://hsgcs.dctpay.com/crest/czOrder/rechargeCallback
LyApiKey=CMdyxh2gJ7tbXc6rS0KADqPIfVpaQLjU
LyMemberId=18665
LyPostUrl=https://cz.31994.cn/yrapi.php/
unionAppId=7113783e75354df2a985efd3f31b9528 unionAppId=7113783e75354df2a985efd3f31b9528

@ -49,11 +49,15 @@ TelApiSecret=d11ee9b41e014a039f030e53ae6f5295
TelMemberId=d13091df65d64aafbf0f35d2093157b7 TelMemberId=d13091df65d64aafbf0f35d2093157b7
// Mobile // Mobile
CzNotifyUrl = https://hsg.dctpay.com/crest/czOrder/rechargeCallback JjNotifyUrl = https://hsg.dctpay.com/crest/czOrder/rechargeCallback
CzAppKey = p429mlj3cvn5hb07 JjAppKey = p429mlj3cvn5hb07
CzUrl = https://jj.dmjvip.com/index.php/third/mobile/ JjUrl = https://jj.dmjvip.com/index.php/third/mobile/
CzAppSecret = bf57pnqy8mkexr0v169c3g4odazwu2ij JjAppSecret = bf57pnqy8mkexr0v169c3g4odazwu2ij
#LY
LyApiKey=CMdyxh2gJ7tbXc6rS0KADqPIfVpaQLjU
LyMemberId=18665
LyPostUrl=https://cz.31994.cn/yrapi.php/
unionAppId=ced46392acfe42be863fdfdd3e61164a unionAppId=ced46392acfe42be863fdfdd3e61164a
unionSecret=a0f380bb22cd4ce2a8d35f3bf437d6fa unionSecret=a0f380bb22cd4ce2a8d35f3bf437d6fa

Loading…
Cancel
Save