修改短信话术 修改 修改工会卡终端号

袁野 2 years ago
parent c7cf44ec80
commit 24e4976381
  1. 2
      hai-bweb/src/main/java/com/bweb/controller/HighTestController.java
  2. 45
      hai-cweb/src/main/java/com/cweb/controller/pay/CzOrderController.java
  3. 44
      hai-service/src/main/java/com/hai/common/utils/HttpsUtils.java
  4. 2
      hai-service/src/main/java/com/hai/entity/ApiOrderRecord.java
  5. 2
      hai-service/src/main/java/com/hai/entity/OutRechargeOrder.java
  6. 34
      hai-service/src/main/java/com/hai/service/ApiAmountRecordService.java
  7. 2
      hai-service/src/main/java/com/hai/service/ApiOpenService.java
  8. 20
      hai-service/src/main/java/com/hai/service/ApiOrderRecordService.java
  9. 30
      hai-service/src/main/java/com/hai/service/impl/ApiAmountRecordServiceImpl.java
  10. 214
      hai-service/src/main/java/com/hai/service/impl/ApiOpenServiceImpl.java
  11. 13
      hai-service/src/main/java/com/hai/service/impl/ApiOrderRecordServiceImpl.java

File diff suppressed because one or more lines are too long

@ -49,9 +49,6 @@ public class CzOrderController {
@Resource
private UserCenter userCenter;
@Resource
private HighGasOrderRefundMapper highGasOrderRefundMapper;
@Resource
private OutRechargeOrderService outRechargeOrderService;
@ -76,6 +73,12 @@ public class CzOrderController {
@Resource
private WechatPayUtil wechatPayUtil;
@Resource
private ApiOrderRecordService apiOrderRecordService;
@Resource
private ApiAmountRecordService apiAmountRecordService;
@RequestMapping(value = "/rechargeCallback", method = RequestMethod.POST)
@ApiOperation(value = "龙阅充值回调")
@ -191,6 +194,8 @@ public class CzOrderController {
outRechargeOrderService.updateOrder(rechargeOrder);
outRechargeChildOrderService.updateOrder(childOrder);
apiOrderRecord(rechargeOrder);
} else {
callbackResult(childOrder , rechargeOrder);
}
@ -254,6 +259,7 @@ public class CzOrderController {
outRechargeOrderService.updateOrder(rechargeOrder);
outRechargeChildOrderService.updateOrder(childOrder);
apiOrderRecord(rechargeOrder);
} else {
callbackResult(childOrder , rechargeOrder);
}
@ -468,4 +474,37 @@ public class CzOrderController {
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value="/test",method = RequestMethod.POST)
@ResponseBody
@ApiOperation(value = "ces")
public String test(@RequestBody String reqBodyStr) {
try {
if (StringUtils.isBlank(reqBodyStr)) {
log.error("orderToPay error!", "参数错误");
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
return "SUCCESS";
} catch (Exception e) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
}
private void apiOrderRecord(OutRechargeOrder rechargeOrder) {
Map<String, Object> orderMap = new HashMap<>();
orderMap.put("orderId" , rechargeOrder.getId());
// 查询是否用重复订单
ApiOrderRecord apiOrderRecord = apiOrderRecordService.queryOrderResult(orderMap);
apiOrderRecord.setStatus(100);
apiOrderRecord.setRequestTime(new Date());
apiOrderRecordService.updateOrderRecord(apiOrderRecord);
}
}

@ -35,6 +35,7 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.security.GeneralSecurityException;
import java.security.KeyStore;
import java.security.cert.CertificateException;
@ -663,6 +664,49 @@ public class HttpsUtils {
return null;
}
/**
* 发送 POST 请求JSON形式
*
* @param apiUrl
* @return
*/
public static String doApiPost(String apiUrl, String str) {
CloseableHttpClient httpClient = null;
if (apiUrl.startsWith("https")) {
httpClient = HttpClients.custom().setSSLSocketFactory(createSSLConnSocketFactory())
.setConnectionManager(connMgr).setDefaultRequestConfig(requestConfig).build();
} else {
httpClient = HttpClients.createDefault();
}
String httpStr = null;
CloseableHttpResponse response = null;
try {
HttpPost httpPost = new HttpPost(apiUrl);
httpPost.setConfig(requestConfig);
StringEntity stringEntity = new StringEntity(str, "UTF-8");// 解决中文乱码问题
stringEntity.setContentEncoding("UTF-8");
stringEntity.setContentType("application/json");
httpPost.setEntity(stringEntity);
response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
return EntityUtils.toString(response.getEntity(), StandardCharsets.UTF_8);
} catch (Exception e) {
log.error(e.getMessage(),e);
} finally {
if (response != null) {
try {
EntityUtils.consume(response.getEntity());
} catch (IOException e) {
log.error(e.getMessage(),e);
}
}
}
return null;
}
public static JSONObject doPost(String apiUrl, String str, String token, String sign, Long ts) {
CloseableHttpClient httpClient = null;
if (apiUrl.startsWith("https")) {

@ -74,7 +74,7 @@ public class ApiOrderRecord implements Serializable {
private Date updateTime;
/**
* 100 :未回调 101已回调 102回调未响应
* 100 :未回调 101已回调 102回调未响应 103 预回调
*/
private Integer status;

@ -85,7 +85,7 @@ public class OutRechargeOrder implements Serializable {
private String rechargeContent;
/**
* 1支付宝 2微信 3汇联通工会卡 4银联 5银联分期
* 1支付宝 2微信 3汇联通工会卡 4银联 5银联分期 6:商户预充值
*/
private Integer payType;

@ -0,0 +1,34 @@
package com.hai.service;
import com.hai.entity.ApiAmountRecord;
/**
* @serviceName ApiAmountRecordService.java
* @author Sum1Dream
* @version 1.0.0
* @Description // 商户金额记录接口
* @createTime 14:31 2022/6/13
**/
public interface ApiAmountRecordService {
/**
* @Author Sum1Dream
* @name insertAmountRecord.java
* @Description // 插入金额记录
* @Date 14:32 2022/6/13
* @Param [com.hai.entity.ApiAmountRecord]
* @return void
*/
void insertAmountRecord(ApiAmountRecord apiAmountRecord);
/**
* @Author Sum1Dream
* @name findById.java
* @Description // 查询详情
* @Date 15:39 2022/6/13
* @Param [java.lang.Long]
* @return com.hai.entity.ApiAmountRecord
*/
ApiAmountRecord findById(Long id);
}

@ -19,6 +19,6 @@ public interface ApiOpenService {
* @Param [com.alibaba.fastjson.JSONObject]
* @return com.alibaba.fastjson.JSONObject
*/
JSONObject createOrder(JSONObject object);
JSONObject createOrder(JSONObject object) throws Exception;
}

@ -22,4 +22,24 @@ public interface ApiOrderRecordService {
* @return com.hai.entity.ApiOrderRecord
*/
ApiOrderRecord queryOrderResult(Map<String , Object> map);
/**
* @Author Sum1Dream
* @name insertOrderRecord.java
* @Description // 插入订单记录
* @Date 15:28 2022/6/13
* @Param [com.hai.entity.ApiOrderRecord]
* @return void
*/
void insertOrderRecord(ApiOrderRecord apiOrderRecord);
/**
* @Author Sum1Dream
* @name updateOrderRecord.java
* @Description // 更新
* @Date 16:01 2022/6/13
* @Param [com.hai.entity.ApiOrderRecord]
* @return void
*/
void updateOrderRecord(ApiOrderRecord apiOrderRecord);
}

@ -0,0 +1,30 @@
package com.hai.service.impl;
import com.hai.dao.ApiAmountRecordMapper;
import com.hai.entity.ApiAmountRecord;
import com.hai.service.ApiAmountRecordService;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.Date;
@Service("apiAmountRecordService")
public class ApiAmountRecordServiceImpl implements ApiAmountRecordService {
@Resource
private ApiAmountRecordMapper apiAmountRecordMapper;
@Override
public void insertAmountRecord(ApiAmountRecord apiAmountRecord) {
apiAmountRecord.setCreateTime(new Date());
apiAmountRecord.setUpdateTime(new Date());
apiAmountRecord.setStatus(100);
apiAmountRecordMapper.insert(apiAmountRecord);
}
@Override
public ApiAmountRecord findById(Long id) {
return apiAmountRecordMapper.selectByPrimaryKey(id);
}
}

@ -4,20 +4,26 @@ 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.entity.ApiMerchants;
import com.hai.entity.ApiOrderRecord;
import com.hai.entity.ApiProduct;
import com.hai.service.ApiMerchantsService;
import com.hai.service.ApiOpenService;
import com.hai.service.ApiOrderRecordService;
import com.hai.service.ApiProductService;
import com.hai.common.utils.DateUtil;
import com.hai.common.utils.IDGenerator;
import com.hai.config.RechargeConfig;
import com.hai.dao.ApiAmountRecordMapper;
import com.hai.dao.OutRechargeOrderMapper;
import com.hai.entity.*;
import com.hai.enum_type.OperatorEnum;
import com.hai.model.OutRechargePriceModel;
import com.hai.service.*;
import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service("apiOpenService")
@ -32,9 +38,21 @@ public class ApiOpenServiceImpl implements ApiOpenService {
@Resource
private ApiProductService apiProductService;
@Resource
private ApiAmountRecordService apiAmountRecordService;
@Resource
private OutRechargeOrderMapper outRechargeOrderMapper;
@Resource
private OutRechargeChildOrderService outRechargeChildOrderService;
@Resource
private BsRequestRecordService bsRequestRecordService;
@Override
@Transactional(rollbackFor=Exception.class,isolation = Isolation.SERIALIZABLE,propagation= Propagation.REQUIRES_NEW)
public JSONObject createOrder(JSONObject object) {
public JSONObject createOrder(JSONObject object) throws Exception {
Map<String, Object> orderMap = new HashMap<>();
orderMap.put("sourceOrderNo" , object.getString("orderNo"));
@ -49,10 +67,188 @@ public class ApiOpenServiceImpl implements ApiOpenService {
}
ApiProduct apiProduct = apiProductService.findById(object.getLong("goodsId"));
// 查询商户配置产品
Map<String, Object> productMap = new HashMap<>();
productMap.put("productId" , object.getString("goodsId"));
productMap.put("merchantsId" , apiMerchants.getId());
ApiProductConfig productConfig = apiProductService.findMchProduct(productMap);
// 当前账号余额是否可以充值当前金额
// if (apiMerchants.getAmounts().compareTo(apiProduct.))
if (apiMerchants.getAmounts().compareTo(productConfig.getDiscountPrice()) < 0) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.INSUFFICIENT_BALANCE);
}
// 插入金额记录
// 变更前金额
BigDecimal beforeAmount = apiMerchants.getAmounts();
// 计算金额
apiMerchants.setAmounts(apiMerchants.getAmounts().subtract(productConfig.getDiscountPrice()));
// 变更后金额
BigDecimal afterAmount = apiMerchants.getAmounts();
apiMerchantsService.updateApiMerchants(apiMerchants);
ApiAmountRecord apiAmountRecord = new ApiAmountRecord();
apiAmountRecord.setCreateTime(new Date());
apiAmountRecord.setUpdateTime(new Date());
apiAmountRecord.setMchId(apiMerchants.getMchId());
apiAmountRecord.setStatus(100);
apiAmountRecord.setAmount(productConfig.getDiscountPrice());
apiAmountRecord.setAfterAmount(afterAmount);
apiAmountRecord.setBeforeAmount(beforeAmount);
apiAmountRecord.setAmountType(2);
apiAmountRecord.setSourceType(3);
apiAmountRecord.setSourceOrderNo(object.getString("orderNo"));
apiAmountRecord.setSourceId(apiProduct.getId());
apiAmountRecord.setSourceContent(apiMerchants.getMerchantName() + "|" + object.getString("mobile") + "充值" + apiProduct.getRechargePrice());
apiAmountRecordService.insertAmountRecord(apiAmountRecord);
// 充值订单
OutRechargeOrder outRechargeOrder = new OutRechargeOrder();
outRechargeOrder.setPayStatus(102);
outRechargeOrder.setRechargeStatus(204);
outRechargeOrder.setOrderNo("RCG" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5));
outRechargeOrder.setPaySerialNo("22" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5));
outRechargeOrder.setRechargePrice(apiProduct.getRechargePrice());
outRechargeOrder.setRechargeType(apiProduct.getPhoneRechargeType());
outRechargeOrder.setOrderPrice(productConfig.getDiscountPrice());
outRechargeOrder.setPayPrice(productConfig.getDiscountPrice());
outRechargeOrder.setRechargeContent(object.getString("mobile"));
outRechargeOrder.setPayTime(new Date());
outRechargeOrder.setUserName(apiMerchants.getUserName());
outRechargeOrder.setUserPhone(apiMerchants.getPhone());
outRechargeOrder.setPayType(6);
outRechargeOrder.setCompanyId(6666L);
outRechargeOrder.setType(1);
outRechargeOrder.setCreateTimed(new Date());
outRechargeOrder.setOperatorName(apiProduct.getOperatorName());
outRechargeOrder.setOperatorType(apiProduct.getOperatorType());
outRechargeOrder.setGoodsId(apiProduct.getId());
outRechargeOrder.setMerchId(apiMerchants.getMchId());
outRechargeOrder.setUserId(apiMerchants.getId());
outRechargeOrderMapper.insert(outRechargeOrder);
pollRequest(outRechargeOrder);
// 插入订单记录
ApiOrderRecord apiOrderRecordPost = new ApiOrderRecord();
apiOrderRecordPost.setStatus(103);
apiOrderRecordPost.setOrderNo(outRechargeOrder.getOrderNo());
apiOrderRecordPost.setSourceOrderNo(apiAmountRecord.getSourceOrderNo());
apiOrderRecordPost.setCreateTime(new Date());
apiOrderRecordPost.setMchId(apiMerchants.getMchId());
apiOrderRecordPost.setOrderId(outRechargeOrder.getId());
apiOrderRecordPost.setGoodsId(apiProduct.getId().toString());
apiOrderRecordPost.setNotifyUrl(object.getString("notifyUrl"));
apiOrderRecordPost.setUpdateTime(new Date());
apiOrderRecordService.insertOrderRecord(apiOrderRecordPost);
return null;
}
private void pollRequest(OutRechargeOrder outRechargeOrder) throws Exception {
// 查询充值产品
ApiProduct apiProduct = apiProductService.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 = apiProduct.getRechargePlatform().split("-");
for (String s : rechargePlatform) {
// 尖椒充值
if (s.equals("1") && (type == 2 || type == 0)) {
object.put("out_order_id", orderNo);
object.put("amount", apiProduct.getRechargePrice());
object.put("mobile", outRechargeOrder.getRechargeContent());
if (apiProduct.getRechargeType() == 1) {
object.put("is_fast", 1);
}
JSONObject returnObject = RechargeConfig.rechargeOrderByJj(object);
object.put("return_content", returnObject);
if (returnObject != null && returnObject.getLong("code") == 200) {
childOrder.setStatus(102);
} else {
childOrder.setStatus(103);
}
rechargePlatformType = 1;
break;
}
if (s.equals("2") && (type == 1 || type == 0)) {
object.put("out_trade_num", orderNo);
object.put("product_id", apiProduct.getProductId());
object.put("mobile", outRechargeOrder.getRechargeContent());
JSONObject returnObject = RechargeConfig.rechargeOrderByLy(object);
object.put("return_content", returnObject);
if (returnObject != null && returnObject.getLong("errno") == 0) {
childOrder.setStatus(102);
} else {
childOrder.setStatus(103);
}
rechargePlatformType = 2;
break;
}
}
childOrder.setOrderNo(orderNo);
childOrder.setCreateTime(new Date());
childOrder.setParentOrderId(outRechargeOrder.getId());
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(object.toJSONString());
requestRecord.setOperatorId(0L);
requestRecord.setOperatorName("系统生成");
requestRecord.setSourceId(childOrder.getId().toString());
requestRecord.setSourceType(1);
bsRequestRecordService.insertRequestRecord(requestRecord);
// 判断是否充值提交成功
if (childOrder.getStatus() == 102) {
outRechargeOrder.setRechargeStatus(201);
}
if (childOrder.getStatus() == 103) {
outRechargeOrder.setRechargeStatus(204);
}
outRechargeOrderMapper.updateByPrimaryKey(outRechargeOrder);
}
}

@ -32,6 +32,9 @@ public class ApiOrderRecordServiceImpl implements ApiOrderRecordService {
if (StringUtils.isNotBlank(MapUtils.getString(map , "merchId"))) {
criteria.andMchIdEqualTo(MapUtils.getString(map , "merchId"));
}
if (MapUtils.getLong(map , "orderId") != null) {
criteria.andOrderIdEqualTo(MapUtils.getLong(map , "orderId"));
}
List<ApiOrderRecord> list = apiOrderRecordMapper.selectByExample(example);
@ -41,4 +44,14 @@ public class ApiOrderRecordServiceImpl implements ApiOrderRecordService {
return null;
}
}
@Override
public void insertOrderRecord(ApiOrderRecord apiOrderRecord) {
apiOrderRecordMapper.insert(apiOrderRecord);
}
@Override
public void updateOrderRecord(ApiOrderRecord apiOrderRecord) {
apiOrderRecordMapper.updateByPrimaryKey(apiOrderRecord);
}
}

Loading…
Cancel
Save