提交2。0代码

dev-discount
袁野 2 years ago
parent f288555163
commit 59c01a9e48
  1. 27
      hai-bweb/src/main/java/com/bweb/controller/ApiMchProduct/ApiMchProductController.java
  2. 2
      hai-bweb/src/main/java/com/bweb/controller/HighTestController.java
  3. 66
      hai-bweb/src/main/resources/dev/logback.xml
  4. 4
      hai-order/src/main/java/com/web/controller/business/OrderMobileRechargeController.java
  5. 76
      hai-schedule/src/main/java/com/hai/schedule/HighRechargeOrderSchedule.java
  6. 65
      hai-schedule/src/main/resources/dev/logback.xml
  7. 65
      hai-schedule/src/main/resources/prod/logback.xml
  8. 16
      hai-service/src/main/java/com/hai/common/utils/ArrayUtils.java
  9. 2
      hai-service/src/main/java/com/hai/config/RechargeConfig.java
  10. 2
      hai-service/src/main/java/com/hai/dao/HighOrderMapperExt.java
  11. 55
      hai-service/src/main/java/com/hai/openApi/service/ApiMchProductService.java
  12. 37
      hai-service/src/main/java/com/hai/openApi/service/impl/ApiMchProductServiceImpl.java
  13. 70
      hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java
  14. 440
      hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java

@ -0,0 +1,27 @@
package com.bweb.controller.ApiMchProduct;
import com.hai.common.security.UserCenter;
import com.hai.openApi.service.ApiMchProductService;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
@Controller
@RequestMapping(value = "/apiMchProduct")
@Api(value = "API商户产品配置")
public class ApiMchProductController {
Logger log = LoggerFactory.getLogger(ApiMchProductController.class);
@Resource
private ApiMchProductService apiMchProductService;
@Autowired
private UserCenter userCenter;
}

File diff suppressed because one or more lines are too long

@ -57,6 +57,59 @@
<charset>UTF-8</charset> <!-- 此处设置字符集 --> <charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder> </encoder>
</appender> </appender>
<appender name="wechatPayLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/wechatPay.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log/wechatPayLog/wechatPayLog.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 64 MB -->
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<appender name="RechargeLog"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/RechargeLog.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log/RechargeLog/RechargeLog.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 64 MB -->
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<appender name="HltCardLog"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/HltCardLog.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log/hlt/hltcard.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 64 MB -->
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<root level="DEBUG"> <root level="DEBUG">
<appender-ref ref="STDOUT" /> <appender-ref ref="STDOUT" />
</root> </root>
@ -69,4 +122,17 @@
<logger name="com.hai" level="ERROR"> <logger name="com.hai" level="ERROR">
<appender-ref ref="errorlog" /> <appender-ref ref="errorlog" />
</logger> </logger>
<logger name="com.hai.config.WxOrderConfig" level="INFO">
<appender-ref ref="wechatPayLog" />
</logger>
<logger name="com.hai.config.HuiLianTongUnionCardConfig" level="INFO">
<appender-ref ref="HltCardLog" />
</logger>
<logger name="com.hai.config.RechargeConfig" level="INFO">
<appender-ref ref="RechargeLog" />
</logger>
<logger name="com.hai.service.impl.OutRechargeOrderServiceImpl" level="INFO">
<appender-ref ref="RechargeLog" />
</logger>
</configuration> </configuration>

@ -61,6 +61,7 @@ public class OrderMobileRechargeController {
public ResponseData getOrderList(@RequestParam(name = "orderNo", required = false) String orderNo, public ResponseData getOrderList(@RequestParam(name = "orderNo", required = false) String orderNo,
@RequestParam(name = "memPhone", required = false) String memPhone, @RequestParam(name = "memPhone", required = false) String memPhone,
@RequestParam(name = "memCardNo", required = false) String memCardNo, @RequestParam(name = "memCardNo", required = false) String memCardNo,
@RequestParam(name = "title", required = false) String title,
@RequestParam(name = "payType", required = false) Integer payType, @RequestParam(name = "payType", required = false) Integer payType,
@RequestParam(name = "status", required = false) Integer status, @RequestParam(name = "status", required = false) Integer status,
@RequestParam(name = "companyId", required = false) Long companyId, @RequestParam(name = "companyId", required = false) Long companyId,
@ -92,6 +93,7 @@ public class OrderMobileRechargeController {
map.put("payTimeS", payTimeS); map.put("payTimeS", payTimeS);
map.put("payTimeE", payTimeE); map.put("payTimeE", payTimeE);
map.put("finishTimeS", finishTimeS); map.put("finishTimeS", finishTimeS);
map.put("title", title);
map.put("finishTimeE", finishTimeE); map.put("finishTimeE", finishTimeE);
map.put("orderNo", orderNo); map.put("orderNo", orderNo);
map.put("memPhone", memPhone); map.put("memPhone", memPhone);
@ -119,6 +121,7 @@ public class OrderMobileRechargeController {
@RequestParam(name = "status", required = false) Integer status, @RequestParam(name = "status", required = false) Integer status,
@RequestParam(name = "companyId", required = false) Long companyId, @RequestParam(name = "companyId", required = false) Long companyId,
@RequestParam(name = "createTimeS", required = false) Long createTimeS, @RequestParam(name = "createTimeS", required = false) Long createTimeS,
@RequestParam(name = "title", required = false) String title,
@RequestParam(name = "createTimeE", required = false) Long createTimeE, @RequestParam(name = "createTimeE", required = false) Long createTimeE,
@RequestParam(name = "payTimeS", required = false) Long payTimeS, @RequestParam(name = "payTimeS", required = false) Long payTimeS,
@RequestParam(name = "payTimeE", required = false) Long payTimeE, @RequestParam(name = "payTimeE", required = false) Long payTimeE,
@ -145,6 +148,7 @@ public class OrderMobileRechargeController {
map.put("payTimeE", payTimeE); map.put("payTimeE", payTimeE);
map.put("finishTimeS", finishTimeS); map.put("finishTimeS", finishTimeS);
map.put("finishTimeE", finishTimeE); map.put("finishTimeE", finishTimeE);
map.put("title", title);
map.put("orderNo", orderNo); map.put("orderNo", orderNo);
map.put("memPhone", memPhone); map.put("memPhone", memPhone);
map.put("memCardNo", memCardNo); map.put("memCardNo", memCardNo);

@ -53,7 +53,7 @@ public class HighRechargeOrderSchedule {
* @Date 14:18 2022/5/31 * @Date 14:18 2022/5/31
* @Param [] * @Param []
*/ */
@Scheduled(cron = "0 0/5 * * * ?") //每5分钟执行一次 @Scheduled(cron = "0 0/1 * * * ?") //每5分钟执行一次
public void initRechargeOrder() { public void initRechargeOrder() {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("payStatus", String.valueOf(102)); map.put("payStatus", String.valueOf(102));
@ -79,7 +79,8 @@ public class HighRechargeOrderSchedule {
outRechargeOrderService.pollRequest(order); outRechargeOrderService.pollRequest(order);
continue; continue;
} }
outRechargeOrderService.refundOrder(order.getId() , childOrderList.get(0));
outRechargeOrderService.rechargeOrderHandle(order , childOrderList.get(0));
} }
} catch (Exception e) { } catch (Exception e) {
@ -90,90 +91,25 @@ public class HighRechargeOrderSchedule {
System.out.println("话费定时任务 -> 结束任务"); System.out.println("话费定时任务 -> 结束任务");
} }
@Scheduled(cron = "0 0/3 * * * ?") //每30分钟执行一次 @Scheduled(cron = "0 0/30 * * * ?") //每30分钟执行一次
public void failRechargeOrder() { public void failRechargeOrder() {
List<HighOrder> highOrders = orderService.phoneErrorOrder(); List<HighOrder> highOrders = orderService.phoneErrorOrder();
JSONObject object;
for (HighOrder order: highOrders) { for (HighOrder order: highOrders) {
try { try {
object = new JSONObject();
OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(order.getOrderNo()); OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(order.getOrderNo());
OutRechargeChildOrder childOrder = outRechargeOrder.getOutRechargeChildOrders().get(0); OutRechargeChildOrder childOrder = outRechargeOrder.getOutRechargeChildOrders().get(0);
if (outRechargeOrder.getPayStatus() == 102 && outRechargeOrder.getRechargeStatus() != 202) { outRechargeOrderService.rechargeOrderHandle(outRechargeOrder , childOrder);
if (outRechargeOrder.getOutRechargeChildOrders().size() == 0) {
OutRechargeChildOrder outRechargeChildOrder = new OutRechargeChildOrder();
outRechargeChildOrder.setOrderNo("CZ" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5));
outRechargeChildOrder.setParentOrderId(outRechargeOrder.getId());
outRechargeChildOrder.setUpdateTime(new Date());
outRechargeChildOrder.setCreateTime(new Date());
outRechargeOrderService.refundOrder(outRechargeOrder.getId() , outRechargeChildOrder);
} else {
if (childOrder.getStatus() != 101) {
// 龙阅
if (childOrder.getRechargePlatform() == 2) {
object.put("out_trade_nums" , childOrder.getOrderNo());
JSONObject jsonObject = RechargeConfig.checkOrderByLy(object);
JSONArray objectJSONArray = jsonObject.getJSONArray("data");
JSONObject objectData = new JSONObject();
for (Object objects : objectJSONArray) {
objectData = (JSONObject) objects;
}
if (objectData.size() == 0) {
outRechargeOrderService.refundOrder(outRechargeOrder.getId() , childOrder);
} else {
// -1取消,0充值中 ,1充值成功,2充值失败,3部分成功
if (objectData.getInteger("state") == 2 || objectData.getInteger("state") == -1) {
outRechargeOrderService.refundOrder(outRechargeOrder.getId() , childOrder);
} else if (objectData.getInteger("state") == 1) {
outRechargeOrderService.completeOrder(outRechargeOrder , childOrder);
}
}
}
// 嗨购
if (childOrder.getRechargePlatform() == 4) {
object.put("orderid" , childOrder.getOrderNo());
JSONObject jsonObject = RechargeConfig.checkOrderByHg(object);
if (jsonObject.getJSONArray("data") == null) {
outRechargeOrderService.refundOrder(outRechargeOrder.getId() , childOrder);
} else {
JSONArray objectJSONArray = jsonObject.getJSONArray("data");
JSONObject objectData;
for (Object objects : objectJSONArray) {
objectData = (JSONObject) objects;
// 充值中1成功2失败3已取消4部分充值5缓存订单
if (objectData.getInteger("status") == 2 || objectData.getInteger("status") == 3) {
outRechargeOrderService.refundOrder(outRechargeOrder.getId() , childOrder);
} else if (objectData.getInteger("status") == 1) {
outRechargeOrderService.completeOrder(outRechargeOrder , childOrder);
}
}
}
}
}
}
}
} catch (Exception e) { } catch (Exception e) {
log.error("HighCouponSchedule --> expiredCoupon() error!", e); log.error("HighCouponSchedule --> expiredCoupon() error!", e);
} }
} }
} }

@ -57,6 +57,58 @@
<charset>UTF-8</charset> <!-- 此处设置字符集 --> <charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder> </encoder>
</appender> </appender>
<appender name="wechatPayLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/wechatPay.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log/wechatPayLog/wechatPayLog.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 64 MB -->
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<appender name="RechargeLog"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/RechargeLog.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log/RechargeLog/RechargeLog.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 64 MB -->
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<appender name="HltCardLog"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/HltCardLog.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log/hlt/hltcard.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 64 MB -->
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<root level="DEBUG"> <root level="DEBUG">
<appender-ref ref="STDOUT" /> <appender-ref ref="STDOUT" />
</root> </root>
@ -69,4 +121,17 @@
<logger name="com.hai" level="ERROR"> <logger name="com.hai" level="ERROR">
<appender-ref ref="errorlog" /> <appender-ref ref="errorlog" />
</logger> </logger>
<logger name="com.hai.config.WxOrderConfig" level="INFO">
<appender-ref ref="wechatPayLog" />
</logger>
<logger name="com.hai.config.HuiLianTongUnionCardConfig" level="INFO">
<appender-ref ref="HltCardLog" />
</logger>
<logger name="com.hai.config.RechargeConfig" level="INFO">
<appender-ref ref="RechargeLog" />
</logger>
<logger name="com.hai.service.impl.OutRechargeOrderServiceImpl" level="INFO">
<appender-ref ref="RechargeLog" />
</logger>
</configuration> </configuration>

@ -57,6 +57,58 @@
<charset>UTF-8</charset> <!-- 此处设置字符集 --> <charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder> </encoder>
</appender> </appender>
<appender name="wechatPayLog" class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/wechatPay.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log/wechatPayLog/wechatPayLog.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 64 MB -->
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<appender name="RechargeLog"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/RechargeLog.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log/RechargeLog/RechargeLog.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 64 MB -->
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<appender name="HltCardLog"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<File>log/HltCardLog.log</File>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<fileNamePattern>log/hlt/hltcard.log.%d.%i</fileNamePattern>
<timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
<!-- or whenever the file size reaches 64 MB -->
<maxFileSize>64 MB</maxFileSize>
</timeBasedFileNamingAndTriggeringPolicy>
</rollingPolicy>
<encoder>
<pattern>
%d %p (%file:%line\)- %m%n
</pattern>
<charset>UTF-8</charset> <!-- 此处设置字符集 -->
</encoder>
</appender>
<root level="DEBUG"> <root level="DEBUG">
<appender-ref ref="STDOUT" /> <appender-ref ref="STDOUT" />
</root> </root>
@ -69,4 +121,17 @@
<logger name="com.hai" level="ERROR"> <logger name="com.hai" level="ERROR">
<appender-ref ref="errorlog" /> <appender-ref ref="errorlog" />
</logger> </logger>
<logger name="com.hai.config.WxOrderConfig" level="INFO">
<appender-ref ref="wechatPayLog" />
</logger>
<logger name="com.hai.config.HuiLianTongUnionCardConfig" level="INFO">
<appender-ref ref="HltCardLog" />
</logger>
<logger name="com.hai.config.RechargeConfig" level="INFO">
<appender-ref ref="RechargeLog" />
</logger>
<logger name="com.hai.service.impl.OutRechargeOrderServiceImpl" level="INFO">
<appender-ref ref="RechargeLog" />
</logger>
</configuration> </configuration>

@ -0,0 +1,16 @@
package com.hai.common.utils;
public class ArrayUtils {
public static int arrayIndex(String [] array , String s) {
for (int i = 0; i < array.length; i++) {
if (s.equals(array[i])) {
if (i == array.length -1) {
return 0;
}
return i + 1;
}
}
return 0;
}
}

@ -225,7 +225,7 @@ public class RechargeConfig {
paramMap.put("mchid" , CommonSysConst.getSysConfig().getHgMemberId()); paramMap.put("mchid" , CommonSysConst.getSysConfig().getHgMemberId());
paramMap.put("phone" , object.getString("phone")); paramMap.put("phone" , object.getString("phone"));
paramMap.put("orderid" , object.getString("orderid")); paramMap.put("orderid" , object.getString("orderid"));
paramMap.put("price" , object.getBigDecimal("price")); paramMap.put("price" , object.getInteger("price").toString());
paramMap.put("product_id" , object.getString("product_id")); paramMap.put("product_id" , object.getString("product_id"));
paramMap.put("notify" , CommonSysConst.getSysConfig().getHgNotifyUrl()); paramMap.put("notify" , CommonSysConst.getSysConfig().getHgNotifyUrl());
paramMap.put("sign", WxUtils.generateSignatureHg(paramMap , CommonSysConst.getSysConfig().getHgApiKey() , WXPayConstants.SignType.MD5)); paramMap.put("sign", WxUtils.generateSignatureHg(paramMap , CommonSysConst.getSysConfig().getHgApiKey() , WXPayConstants.SignType.MD5));

@ -1224,7 +1224,7 @@ public interface HighOrderMapperExt {
List<ApiThirdOrderModel> getApiThirdOrderByList(@Param("map") Map<String,Object> map); List<ApiThirdOrderModel> getApiThirdOrderByList(@Param("map") Map<String,Object> map);
@Select("SELECT * FROM high_order WHERE create_time < NOW()-INTERVAL 3 day and product_type = 9 and order_status = 2 and pay_type = 4 group by create_time asc;") @Select("SELECT * FROM high_order WHERE create_time < NOW()-INTERVAL 3 day and product_type = 9 and order_status = 2 group by create_time asc;")
@Results({ @Results({
@Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true), @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
@Result(column="title", property="title", jdbcType=JdbcType.VARCHAR), @Result(column="title", property="title", jdbcType=JdbcType.VARCHAR),

@ -0,0 +1,55 @@
package com.hai.openApi.service;
import com.hai.entity.ApiMchProduct;
import java.util.List;
import java.util.Map;
/**
* @serviceName ApiMchProductService.java
* @author Sum1Dream
* @version 1.0.0
* @Description // 商户产品配置
* @createTime 11:51 2023/2/15
**/
public interface ApiMchProductService {
/**
* @Author Sum1Dream
* @Name insertMchProduct
* @Description // 新增商户产品
* @Date 11:55 2023/2/15
* @Param [apiMchProduct]
* @Return void
*/
void insertMchProduct(ApiMchProduct apiMchProduct);
/**
* @Author Sum1Dream
* @Name updateMchProduct
* @Description // 更新商户产品
* @Date 11:55 2023/2/15
* @Param [apiMchProduct]
* @Return void
*/
void updateMchProduct(ApiMchProduct apiMchProduct);
/**
* @Author Sum1Dream
* @Name getListMchProduct
* @Description // 查询商户产品列表
* @Date 11:55 2023/2/15
* @Param [map]
* @Return java.util.List<com.hai.entity.ApiMchProduct>
*/
List<ApiMchProduct> getListMchProduct(Map<String, Object> map);
/**
* @Author Sum1Dream
* @Name findById
* @Description // 根据id 查询商户产品
* @Date 11:55 2023/2/15
* @Param [id]
* @Return com.hai.entity.ApiMchProduct
*/
ApiMchProduct findById(Long id);
}

@ -0,0 +1,37 @@
package com.hai.openApi.service.impl;
import com.hai.dao.ApiMchProductMapper;
import com.hai.entity.ApiMchProduct;
import com.hai.openApi.service.ApiMchProductService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@Service("apiMchProductService")
public class ApiMchProductServiceImpl implements ApiMchProductService {
@Resource
private ApiMchProductMapper apiMchProductMapper;
@Override
public void insertMchProduct(ApiMchProduct apiMchProduct) {
apiMchProductMapper.insert(apiMchProduct);
}
@Override
public void updateMchProduct(ApiMchProduct apiMchProduct) {
apiMchProductMapper.updateByPrimaryKey(apiMchProduct);
}
@Override
public List<ApiMchProduct> getListMchProduct(Map<String, Object> map) {
return null;
}
@Override
public ApiMchProduct findById(Long id) {
return apiMchProductMapper.selectByPrimaryKey(id);
}
}

@ -60,8 +60,6 @@ public interface OutRechargeOrderService {
**/ **/
void updateOrder(OutRechargeOrder outRechargeOrder); void updateOrder(OutRechargeOrder outRechargeOrder);
void updateOrderList(List<OutRechargeOrder> rechargeOrders) throws Exception;
/** /**
* @Author Sum1Dream * @Author Sum1Dream
* @Description //取消订单 Administrator * @Description //取消订单 Administrator
@ -87,15 +85,6 @@ public interface OutRechargeOrderService {
*/ */
List<OutRechargeOrderModel> getOrderCount(Map<String,Object> map) throws Exception; List<OutRechargeOrderModel> getOrderCount(Map<String,Object> map) throws Exception;
/**
* @Author Sum1Dream
* @Description //查询订单未支付数量 Administrator
* @Date 10:53 2021/6/14
* @Param []
* @return java.lang.Integer
**/
Long CountOrder();
/** /**
* @Author Sum1Dream * @Author Sum1Dream
* @Description //TODO Administrator * @Description //TODO Administrator
@ -114,26 +103,6 @@ public interface OutRechargeOrderService {
**/ **/
List<OutUserOrderModel> getUserCountList(Map<String , String> map) throws Exception; List<OutUserOrderModel> getUserCountList(Map<String , String> map) throws Exception;
/**
* @Author Sum1Dream
* @name hltUnionCardPay.java
* @Description // 汇联通支付
* @Date 17:21 2022/5/25
* @Param [java.lang.Long, com.hai.entity.OutRechargeOrder]
* @return void
*/
void hltUnionCardPay(HighUserCard userCard, OutRechargeOrder order) throws Exception;
/**
* @Author Sum1Dream
* @name getOutRechargeOrderList.java
* @Description // 查询话费充值超过15分钟订单
* @Date 3:34 下午 2021/12/10
* @Param []
* @return java.util.List<com.hai.entity.OutRechargeOrder>
*/
List<OutRechargeOrder> getOutRechargeOrderList();
/** /**
* @Author Sum1Dream * @Author Sum1Dream
@ -185,25 +154,6 @@ public interface OutRechargeOrderService {
*/ */
void completeOrder(OutRechargeOrder order , OutRechargeChildOrder childOrder); void completeOrder(OutRechargeOrder order , OutRechargeChildOrder childOrder);
/**
* @Author Sum1Dream
* @name rechargeOrderNum.java
* @Description // 查询充值订单待支付数量
* @Date 17:49 2022/5/30
* @Param [java.lang.Long]
* @return java.lang.Integer
*/
Integer rechargeOrderNum(Long userId);
/**
* @Author Sum1Dream
* @name integralRebateRechargeOrder.java
* @Description // 查询话费未返利订单
* @Date 17:49 2022/5/30
* @Param [java.lang.Long]
* @return java.lang.Integer
*/
List<OutRechargeOrder> integralRebateRechargeOrder();
/** /**
* @Author Sum1Dream * @Author Sum1Dream
@ -226,4 +176,24 @@ public interface OutRechargeOrderService {
*/ */
void editOutRechargeOrder(HighOrder order); void editOutRechargeOrder(HighOrder order);
/**
* @Author Sum1Dream
* @Name refundLegality
* @Description // 话费订单处理
* @Date 14:45 2023/2/15
* @Param [outRechargeOrder, childOrder]
* @Return void
*/
void rechargeOrderHandle(OutRechargeOrder outRechargeOrder , OutRechargeChildOrder childOrder) throws Exception;
/**
* @Author Sum1Dream
* @Name getRechargeOrderLegality
* @Description // 判断话费订单合法性
* @Date 15:57 2023/2/15
* @Param [object]
* @Return void
*/
Integer getRechargeOrderLegality(OutRechargeOrder outRechargeOrder , OutRechargeChildOrder childOrder) throws Exception;
} }

@ -1,6 +1,7 @@
package com.hai.service.impl; package com.hai.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alicp.jetcache.anno.CacheType; import com.alicp.jetcache.anno.CacheType;
import com.alicp.jetcache.anno.Cached; import com.alicp.jetcache.anno.Cached;
@ -47,6 +48,7 @@ import java.math.RoundingMode;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
@Service("outRechargeOrderService") @Service("outRechargeOrderService")
public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
@ -414,19 +416,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
outRechargeOrderMapper.updateByPrimaryKey(outRechargeOrder); outRechargeOrderMapper.updateByPrimaryKey(outRechargeOrder);
} }
@Override
@Transactional(propagation = Propagation.REQUIRES_NEW)
public void updateOrderList(List<OutRechargeOrder> rechargeOrders) throws Exception {
for (OutRechargeOrder list : rechargeOrders) {
// if (list.getStatus() == 3) {
// outRechargeOrderMapper.updateByPrimaryKey(list);
// } else if (list.getStatus() == 6) {
// rechargeOrderToRefund(list.getId());
// }
}
}
@Override @Override
@Transactional(propagation = Propagation.REQUIRES_NEW) @Transactional(propagation = Propagation.REQUIRES_NEW)
public void cancelOrder(Long orderId) { public void cancelOrder(Long orderId) {
@ -495,12 +484,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
return outRechargeOrderMapper.selectOrderCount(map); return outRechargeOrderMapper.selectOrderCount(map);
} }
@Override
public Long CountOrder() {
OutRechargeOrderExample example = new OutRechargeOrderExample();
// example.createCriteria().andStatusEqualTo(2);
return outRechargeOrderMapper.countByExample(example);
}
@Override @Override
public List<OutOrderModel> getListOrderCount(Map<String, String> map) throws Exception { public List<OutOrderModel> getListOrderCount(Map<String, String> map) throws Exception {
@ -580,231 +563,13 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
return outRechargeOrderMapperExt.getListUserCount(fTimeS, fTimeE); return outRechargeOrderMapperExt.getListUserCount(fTimeS, fTimeE);
} }
@Override
public void hltUnionCardPay(HighUserCard userCard, OutRechargeOrder order) throws Exception {
String goodsDesc = "充值话费";
String tranDesc = order.getRechargeContent() + "充值" + order.getPayRealPrice() + "元话费";
String instCode = "11101527";
String businessType = "hisen_consume";
// 工会卡支付
JSONObject consumption = HuiLianTongUnionCardConfig.consumption(order.getOrderNo(), userCard.getCardNo(), order.getPayRealPrice(), businessType, instCode, goodsDesc, tranDesc);
System.out.println("工会卡支付响应参数" + consumption.toJSONString());
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("orderNo", order.getOrderNo());
dataMap.put("cardType", "ghk");
dataMap.put("cardNo", userCard.getCardNo());
dataMap.put("checkPassword", "N");
dataMap.put("tranAmount", order.getPayRealPrice());
dataMap.put("tranChannel", "HiSen");
dataMap.put("businessType", businessType);
dataMap.put("instCode", instCode);
dataMap.put("goodsDesc", goodsDesc);
dataMap.put("tranDesc", tranDesc);
HighGasOrderPush payPush = new HighGasOrderPush();
payPush.setType(OrderPushType.type5.getType());
payPush.setOrderNo(order.getOrderNo());
payPush.setCreateTime(new Date());
payPush.setCode(consumption.getString("respCode"));
payPush.setRequestContent(JSON.toJSONString(dataMap));
payPush.setReturnContent(consumption.toJSONString());
highGasOrderPushMapper.insert(payPush);
if (!consumption.getString("respCode").equals("0000")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumption.getString("respMessage"));
}
JSONObject consumptionResult = HuiLianTongUnionCardConfig.resolveResponse(consumption.getString("data"));
if (!consumptionResult.getBoolean("success")) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, consumptionResult.getString("message"));
}
order.setPaySerialNo(consumptionResult.getString("orderId")); // 支付流水号
order.setPayRealPrice(order.getPayRealPrice()); // 实付金额
order.setPayStatus(102);
order.setRechargeStatus(204);
order.setLaborUnionCard(userCard.getCardNo());
order.setPayType(3);
order.setPayTime(new Date()); // 支付时间
updateOrder(order);
outRechargeOrderService.pollRequest(order);
}
@Override
public List<OutRechargeOrder> getOutRechargeOrderList() {
return outRechargeOrderMapper.getCloseOrder();
}
@Override @Override
public OrderCountModel rechargeOrderByIndex(Integer code) { public OrderCountModel rechargeOrderByIndex(Integer code) {
return outRechargeOrderMapper.rechargeOrderByIndex(code); return outRechargeOrderMapper.rechargeOrderByIndex(code);
} }
@Override @Override
public void rechargeOrderToRefund(Long orderId) throws Exception { public void rechargeOrderToRefund(Long orderId) throws Exception {
OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId);
// 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
if (order.getPayStatus() != 102) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态");
}
// 充值状态:201:充值中 202:充值成功 203:充值失败 204:未充值
if (order.getRechargeStatus() == 201) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单处于充值中状态");
}
// 微信退款
if (order.getPayType() == 2) {
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());
}
}
// 工会卡退款
if (order.getPayType() == 3) {
JSONObject jsonObject = HuiLianTongUnionCardConfig.refund("HFR" + new Date().getTime(), order.getOrderNo());
if (jsonObject == null) {
jsonObject = HuiLianTongUnionCardConfig.refund("HFR" + new Date().getTime(), order.getOrderNo());
}
JSONObject dataObject = HuiLianTongUnionCardConfig.resolveResponse(jsonObject.getString("data"));
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"));
}
// 商户预充值 帐户退款
if (order.getPayType() == 6) {
Map<String , Object> map = new HashMap<>();
map.put("orderNo" , order.getOrderNo());
map.put("amountType" , 1);
map.put("sourceType" , 2);
if ( apiAmountRecordService.getApiAmountRecordByList(map).size() == 1) {
ApiMerchants apiMerchants = apiMerchantsService.findByMchId(order.getMerchId());
// 插入金额记录
// 变更前金额
BigDecimal beforeAmount = apiMerchants.getAmounts();
// 计算金额
apiMerchants.setAmounts(apiMerchants.getAmounts().add(order.getPayPrice()));
// 变更后金额
BigDecimal afterAmount = apiMerchants.getAmounts();
apiMerchantsService.updateApiMerchants(apiMerchants);
ApiAmountRecord apiAmountRecord = new ApiAmountRecord();
apiAmountRecord.setCreateTime(new Date());
apiAmountRecord.setUpdateTime(new Date());
apiAmountRecord.setMchId(order.getMerchId());
apiAmountRecord.setStatus(100);
apiAmountRecord.setAmount(order.getPayPrice());
apiAmountRecord.setAfterAmount(afterAmount);
apiAmountRecord.setBeforeAmount(beforeAmount);
apiAmountRecord.setAmountType(1);
apiAmountRecord.setSourceType(2);
apiAmountRecord.setSourceOrderNo(order.getOrderNo());
apiAmountRecord.setSourceId(order.getId());
apiAmountRecord.setSourceContent(apiMerchants.getMerchantName() + "|订单退款" + order.getPayPrice());
apiAmountRecordService.insertAmountRecord(apiAmountRecord);
Map<String, Object> orderMap = new HashMap<>();
orderMap.put("orderId" , order.getId());
// 查询是否用重复订单
ApiOrderRecord apiOrderRecord = apiOrderRecordService.queryOrderResult(orderMap);
apiOrderRecord.setStatus(100);
apiOrderRecord.setRequestTime(new Date());
apiOrderRecordService.updateOrderRecord(apiOrderRecord);
}
}
}
// 银联退款
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);
}
}
// 退还积分
if (order.getIntegralNum().compareTo(new BigDecimal(0)) > 0) {
String remark = "话费订单" + order.getOrderNo() + "退款,退还积分:" + order.getIntegralNum().intValue();
highUserService.goldHandle(order.getUserId(), order.getIntegralNum().intValue(), 1, 3, order.getId() , remark);
if (order.getPayRealPrice().compareTo(new BigDecimal(0)) == 0) {
order.setPayStatus(105);
order.setRechargeStatus(203);
order.setRefundTime(new Date());
outRechargeOrderService.updateOrder(order);
}
}
} }
@ -841,87 +606,51 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
outRechargeChildOrderService.updateOrder(childOrder); outRechargeChildOrderService.updateOrder(childOrder);
} }
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();
}
}
@Override @Override
public void pollRequest(OutRechargeOrder outRechargeOrder) throws Exception { public void pollRequest(OutRechargeOrder outRechargeOrder) throws Exception {
// 查询充值产品 // 查询充值产品
OutRechargePriceModel outRechargePrice = outRechargePriceService.findById(outRechargeOrder.getGoodsId(), null); OutRechargePriceModel outRechargePrice = outRechargePriceService.findById(outRechargeOrder.getGoodsId(), null);
// 查询充值子订单
// 查询充值子订单列表
// 定义子订单请求map
Map<String, Object> childOrderMap = new HashMap<>(); Map<String, Object> childOrderMap = new HashMap<>();
// 添加查询是否存在充值中的子订单 // 组装查询子订单数据
childOrderMap.put("parent_order_id", outRechargeOrder.getId()); childOrderMap.put("parent_order_id", outRechargeOrder.getId());
childOrderMap.put("status", 102); // 添加查询是否存在充值中的子订单
List<OutRechargeChildOrder> childOrderList = outRechargeChildOrderService.getListRechargeChildOrder(childOrderMap); List<OutRechargeChildOrder> childOrderList = outRechargeChildOrderService.getListRechargeChildOrder(childOrderMap);
// 定义新的子订单对象 // 定义新的子订单对象
OutRechargeChildOrder childOrder = new OutRechargeChildOrder(); OutRechargeChildOrder childOrder = new OutRechargeChildOrder();
// 1:尖椒 2:龙阅 3:畅停 4.嗨购 // 初始化充值平台 1:尖椒 2:龙阅 3:畅停 4.嗨购
int type = 0; int platformType = 0;
// 定义新增子订单充值平台
int rechargePlatformType = 0;
// 判断子订单是否存在充值中订单 // 判断子订单是否存在充值中订单
if (childOrderList.size() > 0) { if (childOrderList.size() > 0) {
// 修改之前的自订单充值记录
childOrder = childOrderList.get(0); childOrder = childOrderList.get(0);
// -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功 99 未配置平台查询方法
Integer status = getRechargeOrderLegality(outRechargeOrder , childOrder);
if (status == 0 || status == 3 || status == 99) {
return;
} else if (status == 1) {
completeOrder(outRechargeOrder , childOrder);
}
childOrder.setStatus(103); childOrder.setStatus(103);
childOrder.setUpdateTime(new Date()); childOrder.setUpdateTime(new Date());
outRechargeChildOrderService.updateOrder(childOrder); outRechargeChildOrderService.updateOrder(childOrder);
type = childOrder.getRechargePlatform(); platformType = childOrder.getRechargePlatform();
} else {
// 查询充值状态为103充值失败的子订单
Map<String, Object> childOrderMap103 = new HashMap<>();
childOrderMap103.put("parent_order_id", outRechargeOrder.getId());
childOrderMap103.put("status", 103);
List<OutRechargeChildOrder> childOrderList103 = outRechargeChildOrderService.getListRechargeChildOrder(childOrderMap103);
if (childOrderList103.size() > 0) {
type = childOrderList103.get(0).getRechargePlatform();
}
}
if (type == 3) {
type = 1;
} else {
type++;
} }
JSONObject object = new JSONObject(); JSONObject object = new JSONObject();
// 定义订单哈 // 定义充值订单号
String orderNo = "CZ" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5); String orderNo = "CZ" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5);
// 查询平台 // 查询平台
@ -930,7 +659,14 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
// 判断平台只定义一个那么类型就是唯一 // 判断平台只定义一个那么类型就是唯一
if (string.length() == 1) { if (string.length() == 1) {
type = Integer.parseInt(string); platformType = Integer.parseInt(string);
} else {
if (platformType == 0) {
platformType = Integer.parseInt(rechargePlatform[0]);
} else {
platformType = Integer.parseInt(rechargePlatform[ArrayUtils.arrayIndex(rechargePlatform , String.valueOf(platformType))]);
}
} }
// 定义查询充值产品编码 // 定义查询充值产品编码
@ -939,7 +675,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
for (String s : rechargePlatform) { for (String s : rechargePlatform) {
// 尖椒充值 // 尖椒充值
if (s.equals("1") && type == 1) { if (s.equals("1") && platformType == 1) {
object.put("out_order_id", orderNo); object.put("out_order_id", orderNo);
object.put("amount", outRechargePrice.getRechargePrice()); object.put("amount", outRechargePrice.getRechargePrice());
object.put("mobile", outRechargeOrder.getRechargeContent()); object.put("mobile", outRechargeOrder.getRechargeContent());
@ -951,14 +687,14 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
} else { } else {
childOrder.setStatus(103); childOrder.setStatus(103);
} }
rechargePlatformType = 1; childOrder.setRechargePlatform(1);
break; break;
} }
// 龙阅充值 // 龙阅充值
if (s.equals("2") && type == 2) { if (s.equals("2") && platformType == 2) {
map.put("sourceId" , outRechargePrice.getId()); map.put("sourceId" , outRechargePrice.getId());
map.put("rechargePlatform" , type); map.put("rechargePlatform" , platformType);
BsRechargeCode rechargeCode = rechargeCodeService.findByMap(map); BsRechargeCode rechargeCode = rechargeCodeService.findByMap(map);
object.put("out_trade_num", orderNo); object.put("out_trade_num", orderNo);
object.put("product_id", rechargeCode.getGoodsId()); object.put("product_id", rechargeCode.getGoodsId());
@ -971,14 +707,14 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
} else { } else {
childOrder.setStatus(103); childOrder.setStatus(103);
} }
rechargePlatformType = 2; childOrder.setRechargePlatform(2);
break; break;
} }
// 城宇充值 // 城宇充值
if (s.equals("3") && type == 3) { if (s.equals("3") && platformType == 3) {
map.put("sourceId" , outRechargePrice.getId()); map.put("sourceId" , outRechargePrice.getId());
map.put("rechargePlatform" , type); map.put("rechargePlatform" , platformType);
BsRechargeCode rechargeCode = rechargeCodeService.findByMap(map); BsRechargeCode rechargeCode = rechargeCodeService.findByMap(map);
object.put("agentOrderId", orderNo); object.put("agentOrderId", orderNo);
object.put("productId", rechargeCode.getGoodsId()); object.put("productId", rechargeCode.getGoodsId());
@ -990,14 +726,14 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
} else { } else {
childOrder.setStatus(103); childOrder.setStatus(103);
} }
rechargePlatformType = 3; childOrder.setRechargePlatform(3);
break; break;
} }
// 嗨购充值 // 嗨购充值
if (s.equals("4") && type == 4) { if (s.equals("4") && platformType == 4) {
map.put("sourceId" , outRechargePrice.getId()); map.put("sourceId" , outRechargePrice.getId());
map.put("rechargePlatform" , type); map.put("rechargePlatform" , platformType);
BsRechargeCode rechargeCode = rechargeCodeService.findByMap(map); BsRechargeCode rechargeCode = rechargeCodeService.findByMap(map);
object.put("orderid", orderNo); object.put("orderid", orderNo);
object.put("product_id", rechargeCode.getGoodsId()); object.put("product_id", rechargeCode.getGoodsId());
@ -1010,7 +746,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
} else { } else {
childOrder.setStatus(103); childOrder.setStatus(103);
} }
rechargePlatformType = 4; childOrder.setRechargePlatform(4);
break; break;
} }
} }
@ -1018,7 +754,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
childOrder.setOrderNo(orderNo); childOrder.setOrderNo(orderNo);
childOrder.setCreateTime(new Date()); childOrder.setCreateTime(new Date());
childOrder.setParentOrderId(outRechargeOrder.getId()); childOrder.setParentOrderId(outRechargeOrder.getId());
childOrder.setRechargePlatform(rechargePlatformType);
childOrder.setUpdateTime(new Date()); childOrder.setUpdateTime(new Date());
outRechargeChildOrderService.insertOrder(childOrder); outRechargeChildOrderService.insertOrder(childOrder);
@ -1057,20 +792,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
outRechargeChildOrderService.updateOrder(childOrder); outRechargeChildOrderService.updateOrder(childOrder);
} }
@Override
public Integer rechargeOrderNum(Long userId) {
OutRechargeOrderExample example = new OutRechargeOrderExample();
OutRechargeOrderExample.Criteria criteria = example.createCriteria();
criteria.andUserIdEqualTo(userId);
criteria.andPayStatusEqualTo(101);
return outRechargeOrderMapper.selectByExample(example).size();
}
@Override
public List<OutRechargeOrder> integralRebateRechargeOrder() {
return outRechargeOrderMapper.integralRebateRechargeOrder();
}
@Override @Override
public void editOutRechargeOrder(HighOrder orderData) { public void editOutRechargeOrder(HighOrder orderData) {
@ -1096,4 +817,85 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
return outRechargeOrderMapper.getApiRechargePhoneByList(map); return outRechargeOrderMapper.getApiRechargePhoneByList(map);
} }
@Override
public void rechargeOrderHandle(OutRechargeOrder outRechargeOrder, OutRechargeChildOrder childOrder) throws Exception {
if (outRechargeOrder.getPayStatus() == 102 && outRechargeOrder.getRechargeStatus() != 202) {
if (outRechargeOrder.getOutRechargeChildOrders().size() == 0) {
OutRechargeChildOrder outRechargeChildOrder = new OutRechargeChildOrder();
outRechargeChildOrder.setOrderNo("CZ" + DateUtil.date2String(new Date(), "yyyyMMddHHmmss") + IDGenerator.nextId(5));
outRechargeChildOrder.setParentOrderId(outRechargeOrder.getId());
outRechargeChildOrder.setUpdateTime(new Date());
outRechargeChildOrder.setCreateTime(new Date());
refundOrder(outRechargeOrder.getId() , outRechargeChildOrder);
} else {
// -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功
Integer status = getRechargeOrderLegality(outRechargeOrder , childOrder);
if (status == 2 || status == -1) {
refundOrder(outRechargeOrder.getId() , childOrder);
} else if (status == 1) {
completeOrder(outRechargeOrder , childOrder);
}
}
}
}
@Override
public Integer getRechargeOrderLegality(OutRechargeOrder outRechargeOrder, OutRechargeChildOrder childOrder) throws Exception {
JSONObject object = new JSONObject();
// 龙阅
if (childOrder.getRechargePlatform() == 2) {
object.put("out_trade_nums" , childOrder.getOrderNo());
JSONObject jsonObject = RechargeConfig.checkOrderByLy(object);
JSONArray objectJSONArray = jsonObject.getJSONArray("data");
JSONObject objectData = new JSONObject();
for (Object objects : objectJSONArray) {
objectData = (JSONObject) objects;
}
if (objectData.size() == 0) {
return 2;
} else {
// -1取消,0充值中 ,1充值成功,2充值失败,3部分成功
return objectData.getInteger("state");
}
}
// 嗨购
if (childOrder.getRechargePlatform() == 4) {
object.put("orderid" , childOrder.getOrderNo());
JSONObject jsonObject = RechargeConfig.checkOrderByHg(object);
if (jsonObject.getJSONArray("data") == null) {
return -1;
} else {
JSONArray objectJSONArray = jsonObject.getJSONArray("data");
JSONObject objectData;
for (Object objects : objectJSONArray) {
objectData = (JSONObject) objects;
// 充值中1成功2失败3已取消4部分充值5缓存订单
// -1取消,0充值中 ,1充值成功,2充值失败,3部分成功
if (objectData.getInteger("status") == 1 || objectData.getInteger("status") == 5) {
return 0;
} else if (objectData.getInteger("status") == 2) {
return 1;
} else if (objectData.getInteger("status") == 3) {
return -1;
} else if (objectData.getInteger("status") == 4) {
return 3;
}
}
}
}
return 99;
}
} }

Loading…
Cancel
Save