admin
2024-06-29 7ac0b5be02902a96bd1feb658e41a9b69fa50738
src/main/java/com/taoke/autopay/controller/client/OrderController.java
@@ -8,13 +8,15 @@
import com.google.gson.stream.JsonWriter;
import com.taoke.autopay.dao.KeyOrderMapper;
import com.taoke.autopay.dto.DYOrderDto;
import com.taoke.autopay.entity.ClientInfo;
import com.taoke.autopay.entity.KeyOrder;
import com.taoke.autopay.entity.*;
import com.taoke.autopay.exception.KeyOrderException;
import com.taoke.autopay.exception.WxOrderCountException;
import com.taoke.autopay.factory.OrderFactory;
import com.taoke.autopay.service.ClientInfoService;
import com.taoke.autopay.service.KeyOrderService;
import com.taoke.autopay.service.WxUserOrderCountService;
import com.taoke.autopay.service.WxUserSettingService;
import com.taoke.autopay.utils.JsonUtil;
import com.taoke.autopay.utils.StringUtil;
import com.taoke.autopay.utils.TimeUtil;
@@ -68,6 +70,13 @@
    @Resource
    private ClientInfoService clientInfoService;
    @Resource
    private WxUserOrderCountService wxUserOrderCountService;
    @Resource
    private WxUserSettingService wxUserSettingService;
    @ResponseBody
    @RequestMapping("listOrder")
@@ -154,7 +163,7 @@
     * @param: id 订单ID
     * @param: orderNo 订单号
     * @param: orderStatus 订单状态:订单已取消/已支付
     * @return java.lang.String
     * @return java.lang.String 返回是否可以去支付
     **/
    @ResponseBody
    @RequestMapping("setOrderNo")
@@ -181,6 +190,9 @@
        }
        try {
            if(!StringUtil.isNullOrEmpty(orderStatus)){
                throw new KeyOrderException(orderStatus);
            }
            DYOrderDto dto = DYOrderApi.getOrderDetail(orderNo);
//            dto.setOrder_status(1);
            if (dto.getOrder_status() != DYOrderDto.ORDER_STATUS_NOT_PAY) {
@@ -206,6 +218,17 @@
                    throw new Exception("订单已支付");
                }
            }
            if(order.getUid()!=null) {
                WxUserOrderCount countInfo = wxUserOrderCountService.get(order.getUid(), OrderCountTypeEnum.DY_ORDER_PAY, TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyyMMdd"));
                if (countInfo != null) {
                    WxUserSettings settings = wxUserSettingService.selectByUid(order.getUid());
                    if (settings.getDyOrderCountPerDay()<=countInfo.getOrderCount()){
                        throw new Exception("今日已达支付次数上限:"+settings.getDyOrderCountPerDay());
                    }
                }
            }
            // 设置进入
            KeyOrder orderUpdate = new KeyOrder();
            orderUpdate.setId(id);
@@ -259,7 +282,12 @@
                orderUpdate.setId(id);
                orderUpdate.setState(KeyOrder.STATE_PAY);
                orderUpdate.setStateDesc("支付成功");
                keyOrderService.update(orderUpdate);
                try {
                    keyOrderService.paySuccess(id,"支付成功",TimeUtil.getGernalTime(System.currentTimeMillis(),"yyyyMMdd"));
                } catch (WxOrderCountException e) {
                    e.printStackTrace();
                    return JsonUtil.loadFalseResult(e.getMessage());
                }
            }
        }
        return JsonUtil.loadTrueResult("");