admin
2021-06-07 fdd50bd7ca375743475f5f799564dffdd92fa491
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package com.yeshi.fanli.controller.client.v2;
 
import com.google.gson.Gson;
import com.yeshi.fanli.entity.accept.AcceptData;
import com.yeshi.fanli.entity.bus.user.LostOrder;
import com.yeshi.fanli.entity.system.ConfigKeyEnum;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.order.LostOrderService;
import com.yeshi.fanli.util.Constant;
import com.yeshi.fanli.util.Utils;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.yeshi.utils.IPUtil;
import org.yeshi.utils.JsonUtil;
import org.yeshi.utils.NumberUtil;
import org.yeshi.utils.TimeUtil;
 
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
 
/**
 * 动态
 *
 * @author Administrator
 */
@Controller
@RequestMapping("api/v2/lostOrder")
public class LostOrderControllerV2 {
 
    @Resource
    private LostOrderService lostOrderService;
 
    @Resource
    private ConfigService configService;
 
 
    @RequestMapping("findLostOrder")
    public void findLostOrder(AcceptData acceptData, LostOrder lostOrder, HttpServletRequest request, PrintWriter out) {
        Integer type = lostOrder.getType();
        if (type == null) {
            type = Constant.SOURCE_TYPE_TAOBAO;
        }
 
        boolean orderNum = true;
        String orderId = lostOrder.getOrderId();
        if (type == Constant.SOURCE_TYPE_TAOBAO) {
            if (!NumberUtil.isNumeric(orderId) || (orderId.length() < 12 || orderId.length() > 20)) {
                orderNum = false;
            } else {
                orderNum = Utils.isOrderNum(orderId);
            }
        } else if (type == Constant.SOURCE_TYPE_JD) {
            if (!NumberUtil.isNumeric(orderId) || (orderId.length() < 6 || orderId.length() > 20)) {
                orderNum = false;
            }
        } else if (type == Constant.SOURCE_TYPE_PDD) {
            if (!orderId.contains("-")) {
                orderNum = false;
            } else {
                String[] split = orderId.split("-");
                if (split == null || split.length != 2) {
                    orderNum = false;
                } else {
                    if (!NumberUtil.isNumeric(split[0]) || !NumberUtil.isNumeric(split[1])) {
                        orderNum = false;
                    }
                }
            }
        } else if (type == Constant.SOURCE_TYPE_VIP) {
            if (!NumberUtil.isNumeric(orderId) || (orderId.length() < 10 || orderId.length() > 18)) {
                orderNum = false;
            }
        } else if (type == Constant.SOURCE_TYPE_SUNING) {
            if (!NumberUtil.isNumeric(orderId) || (orderId.length() < 10 || orderId.length() > 15)) {
                orderNum = false;
            }
        }
 
        if (lostOrder.getUserInfo() == null || lostOrder.getUserInfo().getId() == null
                || lostOrder.getUserInfo().getId() <= 0) {
            out.print(JsonUtil.loadFalseResult(1,
                    String.format("请登录%s账号", Constant.getAppName(acceptData.getPlatform(), acceptData.getVersion()))));
            return;
        }
        lostOrder.setIpInfo(IPUtil.getRemotIP(request) + ":" + request.getRemotePort());
        int state;
        String stateInfo = "提交成功,请等待审核结果";
        if (!orderNum) {
            state = -4;
            stateInfo = "请提交准确的订单号";
        } else {
            lostOrder.setResultCode(LostOrder.RESULT_CODE_VERFING);
            state = lostOrderService.addLostOrder(lostOrder);
            if (state == -3) {
                stateInfo = "该订单已被统计,无需申诉";
            } else if (state == -2) {
                stateInfo = "请勿重复提交,该订单正在审核中";
            } else if (state == -1) {
                stateInfo = "该订单申诉已通过,请在订单列表中查看";
            } else if (state == -5) {
                stateInfo = "分享奖金订单无需申诉";
            } else if (state == -6) {
                stateInfo = "该订单申诉已失败,请在订单列表中查看";
            } else if (state == -7) {
                stateInfo = "今日申诉次数已达上限";
            } else if (state == -1001) {
                stateInfo = "订单违规";
            }
        }
        JSONObject data = new JSONObject();
        data.put("state", state);
        data.put("info", stateInfo);
        out.print(JsonUtil.loadTrueResult(data));
    }
 
}