修改话费订单导出

袁野 2 years ago
parent 831e5c9c63
commit 0765647741
  1. 2
      hai-bweb/src/main/java/com/bweb/controller/HighTestController.java
  2. 32
      hai-service/src/main/java/com/hai/dao/ApiAmountRecordMapperExt.java
  3. 31
      hai-service/src/main/java/com/hai/dao/ApiOrderRecordMapperExt.java
  4. 11
      hai-service/src/main/java/com/hai/service/ApiOrderRecordService.java
  5. 103
      hai-service/src/main/java/com/hai/service/impl/ApiOpenServiceImpl.java
  6. 5
      hai-service/src/main/java/com/hai/service/impl/ApiOrderRecordServiceImpl.java

File diff suppressed because one or more lines are too long

@ -1,40 +1,8 @@
package com.hai.dao; package com.hai.dao;
import com.hai.entity.ApiOrderRecord;
import com.hai.entity.OutRechargeOrder;
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;
/** /**
* mapper扩展类 * mapper扩展类
*/ */
public interface ApiAmountRecordMapperExt { public interface ApiAmountRecordMapperExt {
@Select({"SELECT * FROM api_order_record aor WHERE TIMESTAMPDIFF(MINUTE,aor.request_time,SYSDATE()) < 15 AND aor.status = 100"})
@Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="amount_type", property="amountType", jdbcType=JdbcType.INTEGER),
@Result(column="amount", property="amount", jdbcType=JdbcType.DECIMAL),
@Result(column="before_amount", property="beforeAmount", jdbcType=JdbcType.DECIMAL),
@Result(column="after_amount", property="afterAmount", jdbcType=JdbcType.DECIMAL),
@Result(column="mch_id", property="mchId", jdbcType=JdbcType.VARCHAR),
@Result(column="source_type", property="sourceType", jdbcType=JdbcType.INTEGER),
@Result(column="source_id", property="sourceId", jdbcType=JdbcType.BIGINT),
@Result(column="source_order_no", property="sourceOrderNo", jdbcType=JdbcType.VARCHAR),
@Result(column="source_content", property="sourceContent", jdbcType=JdbcType.VARCHAR),
@Result(column="operator_id", property="operatorId", jdbcType=JdbcType.BIGINT),
@Result(column="operator_name", property="operatorName", jdbcType=JdbcType.VARCHAR),
@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<ApiOrderRecord> callBackOrderList();
} }

@ -1,7 +1,38 @@
package com.hai.dao; package com.hai.dao;
import com.hai.entity.ApiOrderRecord;
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;
/** /**
* mapper扩展类 * mapper扩展类
*/ */
public interface ApiOrderRecordMapperExt { public interface ApiOrderRecordMapperExt {
@Select({"SELECT * FROM api_order_record aor WHERE TIMESTAMPDIFF(MINUTE,aor.request_time,SYSDATE()) < 15 AND aor.status = 100"})
@Results({
@Result(column="id", property="id", jdbcType= JdbcType.BIGINT, id=true),
@Result(column="amount_type", property="amountType", jdbcType=JdbcType.INTEGER),
@Result(column="amount", property="amount", jdbcType=JdbcType.DECIMAL),
@Result(column="before_amount", property="beforeAmount", jdbcType=JdbcType.DECIMAL),
@Result(column="after_amount", property="afterAmount", jdbcType=JdbcType.DECIMAL),
@Result(column="mch_id", property="mchId", jdbcType=JdbcType.VARCHAR),
@Result(column="source_type", property="sourceType", jdbcType=JdbcType.INTEGER),
@Result(column="source_id", property="sourceId", jdbcType=JdbcType.BIGINT),
@Result(column="source_order_no", property="sourceOrderNo", jdbcType=JdbcType.VARCHAR),
@Result(column="source_content", property="sourceContent", jdbcType=JdbcType.VARCHAR),
@Result(column="operator_id", property="operatorId", jdbcType=JdbcType.BIGINT),
@Result(column="operator_name", property="operatorName", jdbcType=JdbcType.VARCHAR),
@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<ApiOrderRecord> callBackOrderList();
} }

@ -2,6 +2,7 @@ package com.hai.service;
import com.hai.entity.ApiOrderRecord; import com.hai.entity.ApiOrderRecord;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@ -42,4 +43,14 @@ public interface ApiOrderRecordService {
* @return void * @return void
*/ */
void updateOrderRecord(ApiOrderRecord apiOrderRecord); void updateOrderRecord(ApiOrderRecord apiOrderRecord);
/**
* @Author Sum1Dream
* @name callBackOrderList.java
* @Description // 查询15分钟内的未回调的订单
* @Date 16:16 2022/6/15
* @Param []
* @return java.util.List<com.hai.entity.ApiOrderRecord>
*/
List<ApiOrderRecord> callBackOrderList();
} }

@ -129,7 +129,8 @@ public class ApiOpenServiceImpl implements ApiOpenService {
outRechargeOrder.setUserId(apiMerchants.getId()); outRechargeOrder.setUserId(apiMerchants.getId());
outRechargeOrderMapper.insert(outRechargeOrder); outRechargeOrderMapper.insert(outRechargeOrder);
outRechargeOrderService.pollRequest(outRechargeOrder); pollRequest(outRechargeOrder);
// 插入订单记录 // 插入订单记录
ApiOrderRecord apiOrderRecordPost = new ApiOrderRecord(); ApiOrderRecord apiOrderRecordPost = new ApiOrderRecord();
apiOrderRecordPost.setStatus(103); apiOrderRecordPost.setStatus(103);
@ -145,5 +146,105 @@ public class ApiOpenServiceImpl implements ApiOpenService {
apiOrderRecordService.insertOrderRecord(apiOrderRecordPost); apiOrderRecordService.insertOrderRecord(apiOrderRecordPost);
} }
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);
}
} }

@ -54,4 +54,9 @@ public class ApiOrderRecordServiceImpl implements ApiOrderRecordService {
public void updateOrderRecord(ApiOrderRecord apiOrderRecord) { public void updateOrderRecord(ApiOrderRecord apiOrderRecord) {
apiOrderRecordMapper.updateByPrimaryKey(apiOrderRecord); apiOrderRecordMapper.updateByPrimaryKey(apiOrderRecord);
} }
@Override
public List<ApiOrderRecord> callBackOrderList() {
return apiOrderRecordMapper.callBackOrderList();
}
} }

Loading…
Cancel
Save