提交实物代码

dev-discount
袁野 2 years ago
parent 717cbdcb0c
commit ecb007c81e
  1. 2
      hai-bweb/src/main/java/com/bweb/controller/HighTestController.java
  2. 84
      hai-order/src/main/java/com/web/controller/business/OrderMobileRechargeController.java
  3. 31
      hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java
  4. 2
      hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java
  5. 3
      hai-service/src/main/java/com/hai/service/impl/HighGoldRecServiceImpl.java
  6. 81
      hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java
  7. 4
      v1/src/main/java/com/v1/controller/WxMsgController.java
  8. 5
      v1/src/main/java/com/v1/controller/business/OrderRebateController.java

File diff suppressed because one or more lines are too long

@ -21,6 +21,7 @@ import com.hai.order.service.OrderService;
import com.hai.order.type.OrderPayType;
import com.hai.order.type.OrderStatus;
import com.hai.order.type.RechargePlatformType;
import com.hai.service.HighOrderService;
import com.hai.service.OutRechargeChildOrderService;
import com.hai.service.OutRechargeOrderService;
import com.hai.service.impl.OutRechargeOrderServiceImpl;
@ -29,6 +30,8 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@ -57,12 +60,13 @@ public class OrderMobileRechargeController {
private OutRechargeOrderService outRechargeOrderService;
@Resource
private OutRechargeChildOrderService outRechargeChildOrderService;
private OrderService orderService;
@Resource
private OrderService orderService;
private HighOrderService highOrderService;
@Autowired
private RedisTemplate redisTemplate;
@RequestMapping(value = "/getOrderList", method = RequestMethod.GET)
@ResponseBody
@ -71,6 +75,7 @@ public class OrderMobileRechargeController {
@RequestParam(name = "memPhone", required = false) String memPhone,
@RequestParam(name = "memCardNo", required = false) String memCardNo,
@RequestParam(name = "title", required = false) String title,
@RequestParam(name = "exceptionStatus", required = false) Boolean exceptionStatus,
@RequestParam(name = "payType", required = false) Integer payType,
@RequestParam(name = "orderStatus", required = false) Integer orderStatus,
@RequestParam(name = "companyId", required = false) Long companyId,
@ -80,8 +85,8 @@ public class OrderMobileRechargeController {
@RequestParam(name = "payTimeE", required = false) Long payTimeE,
@RequestParam(name = "finishTimeS", required = false) Long finishTimeS,
@RequestParam(name = "finishTimeE", required = false) Long finishTimeE,
@RequestParam(name = "refundTimeS", required = false) String refundTimeS,
@RequestParam(name = "refundTimeE", required = false) String refundTimeE,
@RequestParam(name = "refundTimeS", required = false) Long refundTimeS,
@RequestParam(name = "refundTimeE", required = false) Long refundTimeE,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize,
HttpServletRequest request) {
@ -99,6 +104,8 @@ public class OrderMobileRechargeController {
} else {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, "");
}
map.put("exceptionStatus", exceptionStatus);
map.put("createTimeS", createTimeS);
map.put("createTimeE", createTimeE);
map.put("payTimeS", payTimeS);
@ -133,6 +140,7 @@ public class OrderMobileRechargeController {
@RequestParam(name = "payType", required = false) Integer payType,
@RequestParam(name = "orderStatus", required = false) Integer orderStatus,
@RequestParam(name = "companyId", required = false) Long companyId,
@RequestParam(name = "exceptionStatus", required = false) Boolean exceptionStatus,
@RequestParam(name = "createTimeS", required = false) Long createTimeS,
@RequestParam(name = "title", required = false) String title,
@RequestParam(name = "createTimeE", required = false) Long createTimeE,
@ -159,6 +167,7 @@ public class OrderMobileRechargeController {
}
map.put("createTimeS", createTimeS);
map.put("createTimeE", createTimeE);
map.put("exceptionStatus", exceptionStatus);
map.put("payTimeS", payTimeS);
map.put("payTimeE", payTimeE);
map.put("finishTimeS", finishTimeS);
@ -250,4 +259,69 @@ public class OrderMobileRechargeController {
}
}
@RequestMapping(value="/refundOrder",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "订单退款")
public ResponseData refundOrder(@RequestParam(name = "orderNo", required = true) String orderNo) {
OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderNo(orderNo);
String key = "recharge_" + outRechargeOrder.getId();
try {
// 分布式锁占坑
Boolean lock = redisTemplate.opsForValue().setIfAbsent(key, outRechargeOrder.getOrderNo());
if(Boolean.TRUE.equals(lock)) {
// 加锁成功,处理业务
// 判断订单是否可以继续充值 1:满足继续充值条件 2:订单满足退款条件 3:订单不可以退款不可以继续充值 4:订单存在多个充值订单 5:订单充值完成 6:充值订单号未查询到任何充值记录
int orderStatus = outRechargeOrderService.orderWhetherRecharge(outRechargeOrder);
if (orderStatus == 2) {
outRechargeOrderService.refundOrder(outRechargeOrder.getId());
}
if (orderStatus == 6) {
outRechargeOrderService.refundOrder(outRechargeOrder.getId());
}
} else {
// 加锁失败,重试
Thread.sleep(100);
refundOrder(orderNo);
}
HighOrder order = highOrderService.getOrderByOrderNo(orderNo);
order.setExceptionStatus(false);
highOrderService.updateOrder(order);
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("OrderExtController -> getGasOrderDetail() error!",e);
return ResponseMsgUtil.exception(e);
} finally {
// 删除key,释放锁
redisTemplate.delete(key);
}
}
@RequestMapping(value="/orderNormal",method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "订单修改正常")
public ResponseData orderNormal(@RequestParam(name = "orderNo", required = true) String orderNo) {
try {
HighOrder order = highOrderService.getOrderByOrderNo(orderNo);
order.setExceptionStatus(false);
highOrderService.updateOrder(order);
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("OrderExtController -> getGasOrderDetail() error!",e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -623,14 +623,6 @@ public class OrderServiceImpl implements OrderService {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单无法退款!");
}
// 订单是否异常,订单没异常则需要校验产品业务是否支持退款
if (order.getExceptionStatus().equals(true)
// 产品业务是否支付退款
&& order.getProductType().equals(OrderProductType.PRODUCT_TYPE9.getNumber())
) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "订单无法退款!");
}
// 退款订单号
String refundOrderNo = OrderUtil.generateRefundOrderNo();
@ -784,6 +776,10 @@ public class OrderServiceImpl implements OrderService {
criteria.andMemIdEqualTo(MapUtils.getLong(param, "userId"));
}
if (MapUtils.getBoolean(param, "exceptionStatus") != null) {
criteria.andExceptionStatusEqualTo(MapUtils.getBoolean(param, "exceptionStatus"));
}
if (MapUtils.getLong(param, "companyId") != null) {
criteria.andCompanyIdEqualTo(MapUtils.getLong(param, "companyId"));
}
@ -824,23 +820,26 @@ public class OrderServiceImpl implements OrderService {
}
if (MapUtils.getLong(param, "payTimeS") != null) {
criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(param, "payTimeS")));
criteria.andPayTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(param, "payTimeS")));
}
if (MapUtils.getLong(param, "payTimeE") != null) {
criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(param, "payTimeE")));
criteria.andPayTimeLessThan(new Date(MapUtils.getLong(param, "payTimeE")));
}
if (MapUtils.getLong(param, "finishTimeS") != null) {
criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(param, "finishTimeS")));
criteria.andFinishTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(param, "finishTimeS")));
}
if (MapUtils.getLong(param, "finishTimeE") != null) {
criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(param, "finishTimeE")));
criteria.andFinishTimeLessThan(new Date(MapUtils.getLong(param, "finishTimeE")));
}
if (StringUtils.isNotBlank(MapUtils.getString(param, "refundTimeS")) && StringUtils.isNotBlank(MapUtils.getString(param, "refundTimeE"))) {
criteria.andRefundTimeBetween(
DateUtil.format(MapUtils.getString(param, "refundTimeS"), "yyyy-MM-dd HH:mm:ss"),
DateUtil.format(MapUtils.getString(param, "refundTimeE"), "yyyy-MM-dd HH:mm:ss"));
if (MapUtils.getLong(param, "refundTimeS") != null) {
criteria.andRefundTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(param, "refundTimeS")));
}
if (MapUtils.getLong(param, "refundTimeE") != null) {
criteria.andRefundTimeLessThan(new Date(MapUtils.getLong(param, "refundTimeE")));
}
example.setOrderByClause("create_time desc");
return orderMapper.selectByExample(example);

@ -205,7 +205,7 @@ public interface OutRechargeOrderService {
* @Description // 订单是否可以充值
* @Date 16:11 2023/3/28
* @Param [childOrder]
* @Return java.lang.Integer 1满足继续充值条件 2订单满足退款条件 3订单不可以退款不可以继续充值 4:订单异常 5:订单充值完成
* @Return java.lang.Integer 1满足继续充值条件 2订单满足退款条件 3订单不可以退款不可以继续充值 4:订单异常 5:订单充值完成 6充值订单号未查询到任何充值记录
*/
Integer orderWhetherRecharge(OutRechargeOrder rechargeOrder);

@ -59,6 +59,9 @@ public class HighGoldRecServiceImpl implements HighGoldRecService {
if (MapUtils.getLong(map, "resId") != null) {
criteria.andResIdEqualTo(MapUtils.getLong(map, "resId"));
}
if (MapUtils.getString(map, "resOrderNo") != null) {
criteria.andResOrderNoEqualTo(MapUtils.getString(map, "resOrderNo"));
}
if (MapUtils.getLong(map , "createTimeS") != null) {
criteria.andCreateTimeBetween(new Date(MapUtils.getLong(map , "createTimeS")) , new Date(MapUtils.getLong(map , "createTimeE")));

@ -413,7 +413,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
if(Boolean.TRUE.equals(lock)) {
// 加锁成功,处理业务
// 判断订单是否可以继续充值 1:满足继续充值条件 2:订单满足退款条件 3:订单不可以退款不可以继续充值 4:订单异常 5:订单充值完成
// 判断订单是否可以继续充值 1:满足继续充值条件 2:订单满足退款条件 3:订单不可以退款不可以继续充值 4:订单存在多个充值订单 5:订单充值完成 6:充值订单号未查询到任何充值记录
int orderStatus = orderWhetherRecharge(outRechargeOrder);
log.info("处理话费" + outRechargeOrder.getOrderNo() + "订单状态:" + orderStatus);
if (orderStatus == 1) {
@ -425,7 +425,13 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
if (orderStatus == 4) {
HighOrder highOrder = highOrderService.getOrderByOrderNo(outRechargeOrder.getOrderNo());
highOrder.setExceptionStatus(true);
highOrder.setExceptionContent("话费订单存在多条重复记录");
highOrder.setExceptionContent("订单存在多个充值订单");
highOrderService.updateOrder(highOrder);
}
if (orderStatus == 6) {
HighOrder highOrder = highOrderService.getOrderByOrderNo(outRechargeOrder.getOrderNo());
highOrder.setExceptionStatus(true);
highOrder.setExceptionContent("充值订单号未查询到任何充值记录");
highOrderService.updateOrder(highOrder);
}
if (orderStatus == 5) {
@ -597,7 +603,9 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
JSONObject returnObject = RechargeConfig.rechargeOrderByLy(object);
childOrder.setRechargePlatform(2);
childOrder.setExt1("龙阅充值" + returnObject.toJSONString());
childOrder.setExt2(object.toJSONString());
childOrder.setExt2("龙阅请求参数" + object.toJSONString());
childOrder.setExt3("龙阅充值" + returnObject.toJSONString());
}
// 畅停充值
@ -613,8 +621,9 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
object.put("price", object.getBigDecimal("rechargePrice"));
JSONObject returnObject = RechargeConfig.rechargeOrderByHg(object);
childOrder.setRechargePlatform(4);
childOrder.setExt1("畅停" + returnObject.toJSONString());
childOrder.setExt2(object.toJSONString());
childOrder.setExt1("畅停充值" + returnObject.toJSONString());
childOrder.setExt2("畅停请求参数" + object.toJSONString());
childOrder.setExt3("畅停充值" + returnObject.toJSONString());
}
childOrder.setUpdateTime(new Date());
outRechargeChildOrderService.updateOrder(childOrder);
@ -690,24 +699,28 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
public Integer getRechargeOrderLegality(OutRechargeChildOrder childOrder) {
try {
JSONObject object = new JSONObject();
Integer status = 99;
// 龙阅
if (childOrder.getRechargePlatform() == 2) {
object.put("out_trade_nums" , childOrder.getOrderNo());
JSONObject jsonObject = RechargeConfig.checkOrderByLy(object);
childOrder.setExt3("龙阅查询"+ jsonObject);
JSONArray objectJSONArray = jsonObject.getJSONArray("data");
JSONObject objectData = new JSONObject();
for (Object objects : objectJSONArray) {
objectData = (JSONObject) objects;
}
if (objectData.size() == 0) {
return 99;
} else {
if (objectData.size() > 0) {
// -1取消,0充值中 ,1充值成功,2充值失败,3部分成功
return objectData.getInteger("state");
status = objectData.getInteger("state");
}
}
@ -716,34 +729,43 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
object.put("orderid" , childOrder.getOrderNo());
JSONObject jsonObject = RechargeConfig.checkOrderByHg(object);
if (jsonObject.getJSONArray("data") == null) {
return 99;
} else {
childOrder.setExt3("畅停查询"+ jsonObject);
if (jsonObject.getJSONArray("data") != null) {
JSONArray objectJSONArray = jsonObject.getJSONArray("data");
JSONObject objectData;
for (Object objects : objectJSONArray) {
objectData = (JSONObject) objects;
// 0充值中,1成功,2失败,3已取消,4部分充值,5缓存订单
// -1取消,0充值中 ,1充值成功,2充值失败,3部分成功
if (objectData.getInteger("status") == 0 || objectData.getInteger("status") == 5) {
return 0;
status = 0;
} else if (objectData.getInteger("status") == 1) {
return 1;
status = 1;
} else if (objectData.getInteger("status") == 2) {
return 2;
status = 2;
} else if (objectData.getInteger("status") == 3) {
return -1;
status = -1;
} else if (objectData.getInteger("status") == 4) {
return 3;
status = 3;
}
}
}
}
return 99;
if (status == 1) {
childOrder.setStatus(101);
}
if (status == 2 || status == -1) {
childOrder.setStatus(103);
}
childOrder.setUpdateTime(new Date());
outRechargeChildOrderService.updateOrder(childOrder);
return status;
}catch (Exception e) {
return null;
return 99;
}
@ -822,7 +844,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
List<OutRechargeChildOrder> childOrderList = outRechargeChildOrderService.getListRechargeChildOrderByOrderId(rechargeOrder.getId());
if (childOrderList.size() == 0) {
return 4;
return 6;
}
// 充值订单充值时间
@ -862,8 +884,8 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
if (status == 2 || status == -1) {
// 修改充值订单状态
rechargeChildOrderHandle(childOrders102.get(0) , 103);
// 如果订单记录超过5条退款 反之继续充值
if (childOrderList.size() > 4) {
// 如果订单记录超过2条退款 反之继续充值
if (childOrderList.size() > 1) {
return 2;
} else {
// 如果订单记录超过71小时 反之继续充值
@ -871,7 +893,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
}
}
if (status == 99) {
return 4;
return 6;
}
// 充值订单为充值成功
if (status == 1) {
@ -890,8 +912,8 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
if (status == 2 || status == -1) {
// 修改充值订单状态
rechargeChildOrderHandle(childOrderList.get(0) , 103);
// 如果订单记录超过5条退款 反之继续充值
if (childOrderList.size() > 2) {
// 如果订单记录超过2条退款 反之继续充值
if (childOrderList.size() > 1) {
return 2;
} else {
// 如果订单记录超过71小时 反之继续充值
@ -900,19 +922,14 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
}
if (status == 99) {
return 4;
return 6;
}
if (status == 1) {
// 修改充值订单状态
rechargeChildOrderHandle(childOrderList.get(0) , 101);
return 5;
}
} else {
// 如果订单记录超过71小时 反之继续充值
return hours > 71 ? 2 : 1;
}
}
return 3;
}

@ -216,7 +216,7 @@ public class WxMsgController {
linkContent =
"支付分享,享受更高优惠[礼物]\n\n"
+ "<a href='"
+ CommonSysConst.getSysConfig().getHsgDomainName() + "/hsgH5?accountId=0000013&key=&code="
+ CommonSysConst.getSysConfig().getHsgDomainName() + "/hsgH5?accountId=0000012&key=&code="
+ object.getString("code")
+ "'>分享好友</a>\n\n";
}
@ -339,7 +339,7 @@ public class WxMsgController {
linkContent =
"支付分享,享受更高优惠[礼物]\n\n"
+ "<a href='"
+ CommonSysConst.getSysConfig().getHsgDomainName() + "/hsgH5?accountId=0000013&key=&code="
+ CommonSysConst.getSysConfig().getHsgDomainName() + "/hsgH5?accountId=0000012&key=&code="
+ object.getString("code")
+ "'>分享好友</a>\n\n";
}

@ -172,6 +172,7 @@ public class OrderRebateController {
Map<String, Object> mapGold = new HashMap<>();
mapGold.put("goldType", 1);
mapGold.put("resId", object.getLong("orderId"));
mapGold.put("resOrderNo", object.getString("orderNo"));
List<HighGoldRec> goldRecs = highGoldRecService.getGoldRec(mapGold);
@ -296,10 +297,6 @@ public class OrderRebateController {
}
return ResponseMsgUtil.success("操作成功");
} catch (Exception e) {
log.error("HighOrderController --> getBackendToken() error!", e);

Loading…
Cancel
Save