提交实物代码

dev-discount
袁野 2 years ago
parent a0e93c1715
commit 717cbdcb0c
  1. 57
      hai-order/src/main/java/com/web/controller/business/GoodsOrderController.java
  2. 99
      hai-order/src/main/java/com/web/rocketmq/consumer/OrderMobileRechargeConsumer.java
  3. 2
      hai-schedule/src/main/java/com/hai/schedule/HighRechargeOrderSchedule.java
  4. 2
      hai-service/src/main/java/com/hai/config/RechargeConfig.java
  5. 14
      hai-service/src/main/java/com/hai/mobile/service/MobileHandleService.java
  6. 6
      hai-service/src/main/java/com/hai/mobile/service/impl/MobileHandleServiceImpl.java
  7. 19
      hai-service/src/main/java/com/hai/order/model/GoodsChildOrderExtModel.java
  8. 10
      hai-service/src/main/java/com/hai/order/service/OrderService.java
  9. 2
      hai-service/src/main/java/com/hai/order/service/impl/OrderCreateHandleServiceImpl.java
  10. 35
      hai-service/src/main/java/com/hai/order/service/impl/OrderServiceImpl.java
  11. 222
      hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java

@ -21,6 +21,7 @@ import com.hai.goods.service.GoodsSkuService;
import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel;
import com.hai.order.model.ExportOrderMobileModel;
import com.hai.order.model.GoodsChildOrderExtModel;
import com.hai.order.model.GoodsOrderExtModel;
import com.hai.order.service.OrderService;
import com.hai.order.type.OrderPayType;
@ -195,4 +196,60 @@ public class GoodsOrderController {
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/getOrderChildList", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "查询子订单列表")
public ResponseData getOrderChildList(@RequestParam(name = "orderNo", required = false) String orderNo,
@RequestParam(name = "childOrderNo", required = false) String childOrderNo,
@RequestParam(name = "memPhone", required = false) String memPhone,
@RequestParam(name = "status", required = false) Integer status,
@RequestParam(name = "createTimeS", required = false) Long createTimeS,
@RequestParam(name = "createTimeE", required = false) Long createTimeE,
@RequestParam(name = "pageNum", required = true) Integer pageNum,
@RequestParam(name = "pageSize", required = true) Integer pageSize,
HttpServletRequest request) {
try {
UserInfoModel userInfoModel = userCenter.getSessionModel(UserInfoModel.class);
if (userInfoModel == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMPETENCE_INSUFFICIENT, "");
}
Map<String,Object> map = new HashMap<>();
map.put("createTimeS", createTimeS);
map.put("createTimeE", createTimeE);
map.put("orderNo", orderNo);
map.put("secUserId", userInfoModel.getSecUser().getId());
map.put("childOrderNo", childOrderNo);
map.put("memPhone", memPhone);
map.put("status", status);
List<HighChildOrder> list = orderService.getChildOrderList(map);
List<GoodsChildOrderExtModel> goodsChildOrderExtModels = new ArrayList<>();
GoodsChildOrderExtModel model;
for (HighChildOrder order : list) {
model = new GoodsChildOrderExtModel();
BeanUtils.copyProperties(order, model);
GoodsOrder goodsOrder = goodsOrderExtService.findGoodsOrder(order.getChildOrderNo());
if (goodsOrder != null) {
model.setLogisticsStatus(goodsOrder.getStatus());
}
goodsChildOrderExtModels.add(model);
}
goodsChildOrderExtModels = goodsChildOrderExtModels.stream().sorted(Comparator.comparing(GoodsChildOrderExtModel::getLogisticsStatus)).collect(Collectors.toList());
return ResponseMsgUtil.success(PageUtil.initPageInfoObj(pageNum, goodsChildOrderExtModels.size(), pageSize, new PageInfo<>(goodsChildOrderExtModels)));
} catch (Exception e) {
log.error("OrderCouponController --> getOrderList() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -1,99 +0,0 @@
package com.web.rocketmq.consumer;
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.config.CommonSysConst;
import com.hai.config.RechargeConfig;
import com.hai.entity.OutRechargeChildOrder;
import com.hai.entity.OutRechargeOrder;
import com.hai.service.OutRechargeChildOrderService;
import com.hai.service.OutRechargeOrderService;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Date;
@Component
@Slf4j
@RocketMQMessageListener(consumerGroup = "order-mobile-recharge-group", topic = "order-topic",selectorExpression = "mobile-recharge")
public class OrderMobileRechargeConsumer implements RocketMQListener<OutRechargeChildOrder> {
@Resource
private OutRechargeOrderService outRechargeOrderService;
@Resource
private OutRechargeChildOrderService outRechargeChildOrderService;
@Override
public void onMessage(OutRechargeChildOrder childOrder) {
JSONObject object = new JSONObject();
OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderId(childOrder.getParentOrderId());
object.put("rechargePrice" , outRechargeOrder.getRechargePrice());
object.put("rechargeMobile" , outRechargeOrder.getRechargeContent());
object.put("productId" , outRechargeOrder.getGoodsId());
object.put("parentOrderId" , outRechargeOrder.getId());
// -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功
Integer status = outRechargeOrderService.getRechargeOrderLegality(childOrder);
if (status == 2 || status == -1) {
// 补充下单参数
object = outRechargeOrderService.prepaidRechargeOrderHandle(object);
// 尖椒充值
if (object.getInteger("rechargePlatform") == 1) {
object.put("out_order_id", childOrder.getOrderNo());
object.put("amount", object.getBigDecimal("rechargePrice"));
object.put("mobile", object.getString("rechargeMobile"));
object.put("notifyUrl", CommonSysConst.getSysConfig().getJjNotifyUrl());
JSONObject returnObject = RechargeConfig.rechargeOrderByJj(object);
childOrder.setExt1(returnObject.toJSONString());
}
// 龙阅
if (object.getInteger("rechargePlatform") == 2) {
if (object.getString("code") == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
object.put("out_trade_num", childOrder.getOrderNo());
object.put("product_id", object.getString("code"));
object.put("mobile", object.getString("rechargeMobile"));
object.put("notifyUrl", CommonSysConst.getSysConfig().getLyNotifyUrl());
JSONObject returnObject = RechargeConfig.rechargeOrderByLy(object);
childOrder.setExt1(returnObject.toJSONString());
}
// 畅停充值
if (object.getInteger("rechargePlatform") == 4) {
if (object.getString("code") == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
object.put("orderid", childOrder.getOrderNo());
object.put("product_id", object.getString("code"));
object.put("phone", object.getString("rechargeMobile"));
object.put("price", object.getBigDecimal("rechargePrice"));
JSONObject returnObject = RechargeConfig.rechargeOrderByHg(object);
childOrder.setExt1(returnObject.toJSONString());
}
System.out.println("消费内容:" + childOrder);
childOrder.setUpdateTime(new Date());
outRechargeChildOrderService.updateOrder(childOrder);
}
}
}

@ -50,7 +50,7 @@ public class HighRechargeOrderSchedule {
* @Date 14:18 2022/5/31
* @Param []
*/
@Scheduled(cron = "0 0/60 * * * ?") //每120分钟执行一次
@Scheduled(cron = "0 0/60 * * * ?") //每60分钟执行一次
public void initRechargeOrder() {
log.info("处理话费订单定时任务开始");
Map<String, Object> map = new HashMap<>();

@ -100,7 +100,7 @@ public class RechargeConfig {
paramMap.put("out_trade_nums" , object.getString("out_trade_nums"));
paramMap.put("sign", WxUtils.generateSignatureLy(paramMap , CommonSysConst.getSysConfig().getLyApiKey() , WXPayConstants.SignType.MD5));
log.info("发起龙阅订单查询=");
log.info("发起龙阅订单查询");
log.info("龙阅订单查询-请求参数: " + JSON.toJSONString(paramMap));
JSONObject jsonObject = HttpsUtils.doPost(CommonSysConst.getSysConfig().getLyPostUrl()+ "index/check", paramMap);

@ -0,0 +1,14 @@
package com.hai.mobile.service;
/**
* @serviceName MobileHandleService.java
* @author Sum1Dream
* @version 1.0.0
* @Description // 话费业务处理
* @createTime 11:09 2023/5/17
**/
public interface MobileHandleService {
}

@ -0,0 +1,6 @@
package com.hai.mobile.service.impl;
import com.hai.mobile.service.MobileHandleService;
public class MobileHandleServiceImpl implements MobileHandleService {
}

@ -0,0 +1,19 @@
package com.hai.order.model;
import com.hai.entity.HighChildOrder;
public class GoodsChildOrderExtModel extends HighChildOrder {
/**
* 1:待发货 2:已发货 3配送中 4已送达 5已取消 6退货中 7已退货 8待支付 0:删除';
*/
private String logisticsStatus;
public String getLogisticsStatus() {
return logisticsStatus;
}
public void setLogisticsStatus(String logisticsStatus) {
this.logisticsStatus = logisticsStatus;
}
}

@ -103,4 +103,14 @@ public interface OrderService {
*/
List<HighOrder> phoneErrorOrder();
/**
* @Author Sum1Dream
* @Name getChildOrderList
* @Description // 查询子订单数量
* @Date 15:54 2023/5/16
* @Param [param]
* @Return java.util.List<com.hai.entity.HighChildOrder>
*/
List<HighChildOrder> getChildOrderList(Map<String,Object> param);
}

@ -883,6 +883,7 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService {
childOrder.setPraiseStatus(0);
childOrder.setCreateTime(new Date());
// 生成充值订单
outRechargeOrder.setUserId(order.getMemId());
outRechargeOrder.setRechargeContent(rechargeContent);
outRechargeOrder.setCompanyId(outRechargePrice.getCompanyId());
@ -929,6 +930,7 @@ public class OrderCreateHandleServiceImpl implements OrderCreateHandleService {
childOrder.setGoodsType(OrderChildGoodsType.TYPE11.getNumber());
childOrder.setGoodsId(createOrderChild.getGoodsId());
childOrder.setGoodsName(goods.getName());
childOrder.setSecUserId(goods.getOpId());
childOrder.setSkuId(createOrderChild.getSkuId());
childOrder.setGoodsSpecName(goodsSku.getName());
childOrder.setGoodsPrice(goodsSku.getOriginalPrice());

@ -861,4 +861,39 @@ public class OrderServiceImpl implements OrderService {
public List<HighOrder> phoneErrorOrder() {
return orderMapper.phoneErrorOrder();
}
@Override
public List<HighChildOrder> getChildOrderList(Map<String, Object> param) {
HighChildOrderExample example = new HighChildOrderExample();
HighChildOrderExample.Criteria criteria = example.createCriteria();
if (MapUtils.getString(param, "orderNo") != null) {
criteria.andOrderNoEqualTo(MapUtils.getString(param, "orderNo"));
}
if (MapUtils.getString(param, "childOrderNo") != null) {
criteria.andChildOrderNoEqualTo(MapUtils.getString(param, "childOrderNo"));
}
if (MapUtils.getString(param, "memPhone") != null) {
criteria.andMemPhoneEqualTo(MapUtils.getString(param, "memPhone"));
}
if (MapUtils.getInteger(param, "status") != null) {
criteria.andChildOrderStatusEqualTo(MapUtils.getInteger(param, "status"));
}
if (MapUtils.getLong(param, "createTimeS") != null) {
criteria.andCreateTimeGreaterThanOrEqualTo(new Date(MapUtils.getLong(param, "createTimeS")));
}
if (MapUtils.getLong(param, "createTimeE") != null) {
criteria.andCreateTimeLessThan(new Date(MapUtils.getLong(param, "createTimeE")));
}
if (MapUtils.getLong(param, "secUserId") != null) {
criteria.andSecUserIdEqualTo(MapUtils.getLong(param, "secUserId"));
}
example.setOrderByClause("create_time desc");
return childOrderMapper.selectByExample(example);
}
}

@ -399,42 +399,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
}
@Override
public void getPrepaidRechargeApi(OutRechargeOrder outRechargeOrder) {
JSONObject object = new JSONObject();
object.put("rechargePrice" , outRechargeOrder.getRechargePrice());
object.put("rechargeMobile" , outRechargeOrder.getRechargeContent());
object.put("productId" , outRechargeOrder.getGoodsId());
object.put("parentOrderId" , outRechargeOrder.getId());
// 判断参数是否为空
if (
object.getBigDecimal("rechargePrice") == null ||
object.getString("rechargeMobile") == null ||
object.getInteger("productId") == null ||
object.getLong("parentOrderId") == null
) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 定义子订单对象
OutRechargeChildOrder childOrder = new OutRechargeChildOrder();
// 补充下单参数
object = prepaidRechargeOrderHandle(object);
// 补充子订单参数
childOrder.setParentOrderId(object.getLong("parentOrderId"));
childOrder.setRechargePlatform(object.getInteger("rechargePlatform"));
childOrder.setStatus(102);
childOrder.setOrderNo("CZ" + OrderUtil.generateOrderNo());
childOrder.setUpdateTime(new Date());
childOrder.setCreateTime(new Date());
outRechargeChildOrderService.insertOrder(childOrder);
rocketMQTemplate.syncSend(OrderTopic.MOBILE_TOPIC_PROFIT_RECHARGE.getTopic(), childOrder);
}
@Override
public void prepaidRechargeHandle(OutRechargeOrder outRechargeOrder){
@ -483,6 +448,178 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
}
// @Override
// public void getPrepaidRechargeApi(OutRechargeOrder outRechargeOrder) {
//
// JSONObject object = new JSONObject();
// object.put("rechargePrice" , outRechargeOrder.getRechargePrice());
// object.put("rechargeMobile" , outRechargeOrder.getRechargeContent());
// object.put("productId" , outRechargeOrder.getGoodsId());
// object.put("parentOrderId" , outRechargeOrder.getId());
//
// // 判断参数是否为空
// if (
// object.getBigDecimal("rechargePrice") == null ||
// object.getString("rechargeMobile") == null ||
// object.getInteger("productId") == null ||
// object.getLong("parentOrderId") == null
// ) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
// }
//
// // 定义子订单对象
// OutRechargeChildOrder childOrder = new OutRechargeChildOrder();
//
// // 补充下单参数
// object = prepaidRechargeOrderHandle(object);
//
// // 补充子订单参数
// childOrder.setParentOrderId(object.getLong("parentOrderId"));
// childOrder.setRechargePlatform(object.getInteger("rechargePlatform"));
// childOrder.setStatus(102);
// childOrder.setOrderNo("CZ" + OrderUtil.generateOrderNo());
// childOrder.setUpdateTime(new Date());
// childOrder.setCreateTime(new Date());
//
// outRechargeChildOrderService.insertOrder(childOrder);
//
// // -1 取消,0充值中 ,1充值成功,2充值失败,3部分成功
// Integer status = outRechargeOrderService.getRechargeOrderLegality(childOrder);
//
// if (status == 2 || status == -1) {
// // 补充下单参数
// object = outRechargeOrderService.prepaidRechargeOrderHandle(object);
//
// // 尖椒充值
// if (object.getInteger("rechargePlatform") == 1) {
// object.put("out_order_id", childOrder.getOrderNo());
// object.put("amount", object.getBigDecimal("rechargePrice"));
// object.put("mobile", object.getString("rechargeMobile"));
// object.put("notifyUrl", CommonSysConst.getSysConfig().getJjNotifyUrl());
// JSONObject returnObject = RechargeConfig.rechargeOrderByJj(object);
// childOrder.setExt1(returnObject.toJSONString());
// }
//
// // 龙阅
// if (object.getInteger("rechargePlatform") == 2) {
//
// if (object.getString("code") == null) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
// }
//
// object.put("out_trade_num", childOrder.getOrderNo());
// object.put("product_id", object.getString("code"));
// object.put("mobile", object.getString("rechargeMobile"));
// object.put("notifyUrl", CommonSysConst.getSysConfig().getLyNotifyUrl());
// JSONObject returnObject = RechargeConfig.rechargeOrderByLy(object);
// childOrder.setExt1(returnObject.toJSONString());
// }
//
// // 畅停充值
// if (object.getInteger("rechargePlatform") == 4) {
//
// if (object.getString("code") == null) {
// throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
// }
//
// object.put("orderid", childOrder.getOrderNo());
// object.put("product_id", object.getString("code"));
// object.put("phone", object.getString("rechargeMobile"));
// object.put("price", object.getBigDecimal("rechargePrice"));
// JSONObject returnObject = RechargeConfig.rechargeOrderByHg(object);
// childOrder.setExt1(returnObject.toJSONString());
// }
//
//
// System.out.println("消费内容:" + childOrder);
//
// childOrder.setUpdateTime(new Date());
// outRechargeChildOrderService.updateOrder(childOrder);
// }
// }
@Override
public void getPrepaidRechargeApi(OutRechargeOrder outRechargeOrder) {
JSONObject object = new JSONObject();
object.put("rechargePrice" , outRechargeOrder.getRechargePrice());
object.put("rechargeMobile" , outRechargeOrder.getRechargeContent());
object.put("productId" , outRechargeOrder.getGoodsId());
object.put("parentOrderId" , outRechargeOrder.getId());
// 判断参数是否为空
if (
object.getBigDecimal("rechargePrice") == null ||
object.getString("rechargeMobile") == null ||
object.getInteger("productId") == null ||
object.getLong("parentOrderId") == null
) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
// 定义子订单对象
OutRechargeChildOrder childOrder = new OutRechargeChildOrder();
// 补充下单参数
object = prepaidRechargeOrderHandle(object);
// 补充子订单参数
childOrder.setParentOrderId(object.getLong("parentOrderId"));
childOrder.setRechargePlatform(object.getInteger("rechargePlatform"));
childOrder.setStatus(102);
childOrder.setOrderNo("CZ" + OrderUtil.generateOrderNo());
childOrder.setUpdateTime(new Date());
childOrder.setCreateTime(new Date());
outRechargeChildOrderService.insertOrder(childOrder);
// 尖椒充值
if (object.getInteger("rechargePlatform") == 1) {
object.put("out_order_id", childOrder.getOrderNo());
object.put("amount", object.getBigDecimal("rechargePrice"));
object.put("mobile", object.getString("rechargeMobile"));
object.put("notifyUrl", CommonSysConst.getSysConfig().getJjNotifyUrl());
JSONObject returnObject = RechargeConfig.rechargeOrderByJj(object);
childOrder.setRechargePlatform(1);
childOrder.setExt1("尖椒" + returnObject.toJSONString());
childOrder.setExt2(object.toJSONString());
}
// 龙阅
if (object.getInteger("rechargePlatform") == 2) {
if (object.getString("code") == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
object.put("out_trade_num", childOrder.getOrderNo());
object.put("product_id", object.getString("code"));
object.put("mobile", object.getString("rechargeMobile"));
object.put("notifyUrl", CommonSysConst.getSysConfig().getLyNotifyUrl());
JSONObject returnObject = RechargeConfig.rechargeOrderByLy(object);
childOrder.setRechargePlatform(2);
childOrder.setExt1("龙阅充值" + returnObject.toJSONString());
childOrder.setExt2(object.toJSONString());
}
// 畅停充值
if (object.getInteger("rechargePlatform") == 4) {
if (object.getString("code") == null) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, "");
}
object.put("orderid", childOrder.getOrderNo());
object.put("product_id", object.getString("code"));
object.put("phone", object.getString("rechargeMobile"));
object.put("price", object.getBigDecimal("rechargePrice"));
JSONObject returnObject = RechargeConfig.rechargeOrderByHg(object);
childOrder.setRechargePlatform(4);
childOrder.setExt1("畅停" + returnObject.toJSONString());
childOrder.setExt2(object.toJSONString());
}
childOrder.setUpdateTime(new Date());
outRechargeChildOrderService.updateOrder(childOrder);
}
@Override
public void completeOrder(Long orderId) {
@ -567,11 +704,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
objectData = (JSONObject) objects;
}
if (objectData.size() == 0) {
if (jsonObject.getInteger("errno") == 0) {
return 2;
} else {
return 99;
}
} else {
// -1取消,0充值中 ,1充值成功,2充值失败,3部分成功
return objectData.getInteger("state");
@ -584,9 +717,6 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
JSONObject jsonObject = RechargeConfig.checkOrderByHg(object);
if (jsonObject.getJSONArray("data") == null) {
if (jsonObject.getInteger("code") == 20001) {
return 2;
}
return 99;
} else {
JSONArray objectJSONArray = jsonObject.getJSONArray("data");
@ -740,6 +870,9 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
return hours > 71 ? 2 : 1;
}
}
if (status == 99) {
return 4;
}
// 充值订单为充值成功
if (status == 1) {
// 修改充值订单状态
@ -758,7 +891,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
// 修改充值订单状态
rechargeChildOrderHandle(childOrderList.get(0) , 103);
// 如果订单记录超过5条退款 反之继续充值
if (childOrderList.size() > 4) {
if (childOrderList.size() > 2) {
return 2;
} else {
// 如果订单记录超过71小时 反之继续充值
@ -766,6 +899,9 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
}
}
if (status == 99) {
return 4;
}
if (status == 1) {
// 修改充值订单状态
rechargeChildOrderHandle(childOrderList.get(0) , 101);

Loading…
Cancel
Save