dev-discount
胡锐 2 years ago
commit 0d5392af05
  1. 1
      hai-bweb/src/main/java/com/bweb/controller/BsProductConfigController.java
  2. 2
      hai-bweb/src/main/java/com/bweb/controller/HighTestController.java
  3. 94
      hai-bweb/src/main/java/com/bweb/controller/OrderStatistics/HomeOrderStatisticsController.java
  4. 1
      hai-cweb/src/main/java/com/cweb/controller/CmsContentController.java
  5. 2
      hai-cweb/src/main/java/com/cweb/controller/pay/CzOrderController.java
  6. 64
      hai-service/src/main/java/com/hai/dao/order/OrderStatisticsMapperExt.java
  7. 37
      hai-service/src/main/java/com/hai/service/OrderStatisticsService.java
  8. 11
      hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java
  9. 4
      hai-service/src/main/java/com/hai/service/impl/CommonServiceImpl.java
  10. 27
      hai-service/src/main/java/com/hai/service/impl/OrderStatisticsServiceImpl.java
  11. 33
      hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java

@ -155,7 +155,6 @@ public class BsProductConfigController {
if (object == null ||
object.getLong("id") == null ||
object.getBigDecimal("discount") == null ||
object.getInteger("productType") == null ||
object.getJSONArray("productPlatform") == null ||
object.getJSONArray("payType") == null

File diff suppressed because one or more lines are too long

@ -0,0 +1,94 @@
package com.bweb.controller.OrderStatistics;
import com.alibaba.fastjson.JSONObject;
import com.bweb.controller.ApiProductController;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.security.SessionObject;
import com.hai.common.security.UserCenter;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.model.ResponseData;
import com.hai.model.UserInfoModel;
import com.hai.service.OrderStatisticsService;
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.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
@Controller
@RequestMapping(value = "/homeOrderStatistics")
@Api(value = "首页订单统计")
public class HomeOrderStatisticsController {
Logger log = LoggerFactory.getLogger(ApiProductController.class);
@Resource
private OrderStatisticsService orderStatisticsService;
@Autowired
private UserCenter userCenter;
@RequestMapping(value = "/orderStatisticsByYMD", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "根据年月日统计订单")
public ResponseData orderStatisticsByYMD(
@RequestParam(name = "dateType", required = false) Integer dateType,
@RequestParam(name = "num", required = false) Integer num,
HttpServletRequest request) {
try {
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (userInfoModel.getSecRole().getRoleType() != 1) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂无权限");
}
JSONObject object = new JSONObject();
object.put("dateType" , dateType);
object.put("num" , num);
return ResponseMsgUtil.success(orderStatisticsService.orderStatisticsByYMD(object));
} catch (Exception e) {
log.error("HighOrderController --> getBackendToken() error!", e);
return ResponseMsgUtil.exception(e);
}
}
@RequestMapping(value = "/orderStatisticsByProductType", method = RequestMethod.GET)
@ResponseBody
@ApiOperation(value = "获取订单统计根据年月周日 产品类型相关数据")
public ResponseData orderStatisticsByProductType(
@RequestParam(name = "dateType", required = false) Integer dateType,
HttpServletRequest request) {
try {
SessionObject sessionObject = userCenter.getSessionObject(request);
UserInfoModel userInfoModel = (UserInfoModel) sessionObject.getObject();
if (userInfoModel.getSecRole().getRoleType() != 1) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "暂无权限");
}
JSONObject object = new JSONObject();
object.put("dateType" , dateType);
return ResponseMsgUtil.success(orderStatisticsService.orderStatisticsByProductType(object));
} catch (Exception e) {
log.error("HighOrderController --> getBackendToken() error!", e);
return ResponseMsgUtil.exception(e);
}
}
}

@ -113,7 +113,6 @@ public class CmsContentController {
}
Map<String, Object> mapUser = new HashMap<>();
mapUser.put("companyId" , companyId);
mapUser.put("whereCheck" , false);
mapUser.put("msgType" , 1);
mapUser.put("userId" , userInfoModel.getHighUser().getId());

@ -326,7 +326,7 @@ public class CzOrderController {
outRechargeOrderService.updateOrder(rechargeOrder);
outRechargeChildOrderService.updateOrder(childOrder);
outRechargeOrderService.rechargeOrderToRefund(rechargeOrder.getId());
outRechargeOrderService.refundOrder(rechargeOrder.getId());
new Thread(() -> {

@ -0,0 +1,64 @@
package com.hai.dao.order;
import com.alibaba.fastjson.JSONObject;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
/**
* @serviceName OrderStatisticsMapperExt.java
* @author Sum1Dream
* @version 1.0.0
* @Description // 订单统计
* @createTime 16:11 2022/11/2
**/
public interface OrderStatisticsMapperExt {
@Select(value = {
"<script>",
"SELECT sum(pay_real_price) as sum," +
"<choose>" +
"<when test='dateType == 1'>" +
" DATE_FORMAT(create_time, '%Y-%m-%d') as time FROM high_order where order_status in (2,3) and DATE(create_time) >= DATE_SUB(CURDATE(), INTERVAL #{num} DAY )" +
"</when>" +
"<when test='dateType == 3'>" +
" DATE_FORMAT(create_time, '%Y-%m') as time FROM high_order where order_status in (2,3) and DATE(create_time) >= DATE_SUB(CURDATE(), INTERVAL #{num} MONTH )" +
"</when>" +
"<when test='dateType == 4'>" +
" DATE_FORMAT(create_time, '%Y') as time FROM high_order where order_status in (2,3) and DATE(create_time) >= DATE_SUB(CURDATE() , INTERVAL #{num} YEAR )" +
"</when>" +
"<otherwise>" +
"</otherwise>" +
"</choose>" +
" GROUP BY time" +
"</script>"
})
List<Map<String , Object>> orderStatisticsByYMD(@Param("dateType") Integer dateType, @Param("num") Integer num);
@Select(value = {
"<script>",
"SELECT sum(pay_real_price) as value, product_type as name FROM high_order WHERE " +
"<choose>" +
"<when test='dateType == 1'>" +
" TO_DAYS(create_time) = TO_DAYS(NOW()) " +
"</when>" +
"<when test='dateType == 2'>" +
" YEARWEEK(DATE_FORMAT(create_time,'%Y-%m-%d')) = YEARWEEK(NOW())" +
"</when>" +
"<when test='dateType == 3'>" +
" DATE_FORMAT(create_time,'%Y%m') = DATE_FORMAT(CURDATE(),'%Y%m')" +
"</when>" +
"<when test='dateType == 4'>" +
" YEAR(create_time)=YEAR(NOW())" +
"</when>" +
"<otherwise>" +
"</otherwise>" +
"</choose>" +
" and order_status in (2,3) GROUP BY product_type; " +
"</script>"
})
List<Map<String , Object>> orderStatisticsByProductType(@Param("dateType") Integer dateType);
}

@ -0,0 +1,37 @@
package com.hai.service;
import com.alibaba.fastjson.JSONObject;
import java.util.List;
import java.util.Map;
/**
* @serviceName OrderStatisticsService.java
* @author Sum1Dream
* @version 1.0.0
* @Description // 订单统计接口哦
* @createTime 10:00 2022/11/3
**/
public interface OrderStatisticsService {
/**
* @Author Sum1Dream
* @Name orderStatisticsByYMD
* @Description // 获取订单统计年月日相关订单数据
* @Date 16:28 2022/11/2
* @Param [object]
* @Return com.alibaba.fastjson.JSONObject
*/
List<Map<String , Object>> orderStatisticsByYMD(JSONObject object);
/**
* @Author Sum1Dream
* @Name orderStatisticsByProductType
* @Description // 获取订单统计根据年月周日 产品类型相关数据
* @Date 14:14 2022/11/3
* @Param [object]
* @Return java.util.List<java.util.Map < java.lang.String, java.lang.Object>>
*/
List<Map<String , Object>> orderStatisticsByProductType(JSONObject object);
}

@ -12,6 +12,7 @@ import com.hai.model.OutUserOrderModel;
import io.swagger.models.auth.In;
import java.math.BigDecimal;
import java.util.Calendar;
import java.util.List;
import java.util.Map;
@ -157,6 +158,16 @@ public interface OutRechargeOrderService {
*/
void rechargeOrderToRefund(Long orderId) throws Exception;
/**
* @Author Sum1Dream
* @Name refundOrder
* @Description //TODO
* @Date 15:18 2022/11/2
* @Param [orderId]
* @Return void
*/
void refundOrder(Long orderId) throws Exception;
/**
* @Author Sum1Dream
* @name pollRequest.java

@ -10,6 +10,7 @@ import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.utils.HttpsUtils;
import com.hai.dao.*;
import com.hai.dao.order.OrderStatisticsMapperExt;
import com.hai.entity.*;
import com.hai.model.IndexCountModel;
import com.hai.model.LineCountModel;
@ -70,6 +71,8 @@ public class CommonServiceImpl implements CommonService {
@Resource
private ApiCityMapper apiCityMapper;
private Map<String, Map<String, SecDictionary>> dicCache = new HashMap<String, Map<String, SecDictionary>>();
private List<SecRegion> citiesCache = new ArrayList<>();
@ -699,4 +702,5 @@ public class CommonServiceImpl implements CommonService {
}
}

@ -0,0 +1,27 @@
package com.hai.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.hai.dao.order.OrderStatisticsMapperExt;
import com.hai.service.OrderStatisticsService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
@Service("orderStatisticsService")
public class OrderStatisticsServiceImpl implements OrderStatisticsService {
@Resource
private OrderStatisticsMapperExt orderStatisticsMapperExt;
@Override
public List<Map<String, Object>> orderStatisticsByYMD(JSONObject object) {
return orderStatisticsMapperExt.orderStatisticsByYMD(object.getInteger("dateType"), object.getInteger("num"));
}
@Override
public List<Map<String, Object>> orderStatisticsByProductType(JSONObject object) {
return orderStatisticsMapperExt.orderStatisticsByProductType(object.getInteger("dateType"));
}
}

@ -19,6 +19,8 @@ import com.hai.enum_type.OperatorEnum;
import com.hai.enum_type.OrderPushType;
import com.hai.enum_type.RechargePayType;
import com.hai.model.*;
import com.hai.order.service.OrderService;
import com.hai.order.type.OrderRefundOpUserType;
import com.hai.service.*;
import com.hai.service.pay.impl.GoodsOrderServiceImpl;
import io.swagger.models.auth.In;
@ -59,6 +61,9 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
@Resource
private HighUserCardService highUserCardService;
@Resource
private OrderService orderService;
@Resource
private HighGasOrderPushMapper highGasOrderPushMapper;
@ -113,6 +118,9 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
@Resource
private BsRechargeCodeService rechargeCodeService;
@Resource
private HighOrderService highOrderService;
@Override
public List<OutRechargeOrder> getListRechargeOrder(Map<String, Object> map) {
OutRechargeOrderExample example = new OutRechargeOrderExample();
@ -626,6 +634,7 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
}
@Override
public void rechargeOrderToRefund(Long orderId) throws Exception {
OutRechargeOrder order = outRechargeOrderService.findByOrderId(orderId);
@ -791,6 +800,30 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
}
@Override
public void refundOrder(Long orderId) throws Exception {
OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderId(orderId);
// 101.待支付 102.已支付 100.已完成 104.已取消 105.已退款
if (outRechargeOrder.getPayStatus() != 102) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单不处于已支付状态");
}
// 充值状态:201:充值中 202:充值成功 203:充值失败 204:未充值
if (outRechargeOrder.getRechargeStatus() == 201) {
throw ErrorHelp.genException(SysCode.System, ErrorCode.COMMON_ERROR, "无法退款,订单处于充值中状态");
}
HighOrder highOrder = highOrderService.getOrderByOrderNo(outRechargeOrder.getOrderNo());
orderService.refundOrder(highOrder, "话费自动退款",OrderRefundOpUserType.TYPE1,
null,
"系统自动退款");
outRechargeOrder.setPayStatus(105);
outRechargeOrder.setRechargeStatus(203);
outRechargeOrder.setRefundTime(new Date());
outRechargeOrderService.updateOrder(outRechargeOrder);
}
public String doRefundRequest(String mchId, String data) throws Exception {
//小程序退款需要调用双向证书的认证

Loading…
Cancel
Save