新版仿ok交易所-后端
1
zj
2025-07-10 f15406ac788fb4e17a630c4d48129943af89fb9c
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
package com.yami.trading.api.controller;
 
import com.yami.trading.bean.c2c.C2cAppeal;
import com.yami.trading.bean.c2c.C2cOrder;
import com.yami.trading.bean.model.User;
import com.yami.trading.common.constants.Constants;
import com.yami.trading.common.constants.TipConstants;
import com.yami.trading.common.domain.Result;
import com.yami.trading.common.exception.YamiShopBindException;
import com.yami.trading.common.util.StringUtils;
import com.yami.trading.security.common.util.SecurityUtils;
import com.yami.trading.service.AwsS3OSSFileService;
import com.yami.trading.service.c2c.C2cAppealService;
import com.yami.trading.service.c2c.C2cOrderService;
import com.yami.trading.service.system.TipService;
import com.yami.trading.service.user.UserService;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.Date;
 
/**
 * C2C申诉
 */
@RestController
@CrossOrigin
public class ApiC2cAppealController {
    @Autowired
    private C2cAppealService c2cAppealService;
    @Autowired
    private C2cOrderService c2cOrderService;
    @Autowired
    private UserService partyService;
    @Autowired
    private TipService tipService;
    private final String action = "/api/c2cAppeal!";
    @Autowired
    AwsS3OSSFileService awsS3OSSFileService;
 
    /**
     * 申诉申请
     */
    @RequestMapping(action + "apply.action")
    public Result apply(HttpServletRequest request) throws IOException {
        String order_no = request.getParameter("order_no");
        String reason = request.getParameter("reason");
        String description = request.getParameter("description");
        String img = request.getParameter("img");
        String name = request.getParameter("name");
        String phone = request.getParameter("phone");
        if (StringUtils.isEmptyString(order_no)) {
            throw new YamiShopBindException("申诉订单号不正确");
        }
        if (StringUtils.isEmptyString(reason)) {
            throw new YamiShopBindException("请输入申诉原因");
        }
        if (StringUtils.isEmptyString(img)) {
            throw new YamiShopBindException("请上传申诉凭证");
        }
        String partyId = SecurityUtils.getUser().getUserId();
        C2cOrder order = this.c2cOrderService.get(order_no);
        if (null == order || !partyId.equals(order.getPartyId())) {
            throw new YamiShopBindException("订单不存在");
        }
        C2cAppeal appeal = this.c2cAppealService.findByOrderNo(order_no);
        if (null != appeal) {
            throw new YamiShopBindException("该订单已提交申诉");
        }
        C2cAppeal entity = new C2cAppeal();
        entity.setOrderNo(order_no);
        entity.setReason(reason);
        entity.setDescription(description);
        entity.setImg(img);
        entity.setName(name);
        entity.setPhone(phone);
        entity.setState("0");
        entity.setCreateTime(new Date());
        entity.setUpdateTime(new Date());
        this.c2cAppealService.save(entity);
        order.setState("2");
        c2cOrderService.updateById(order);
        User party = this.partyService.getById(partyId);
        if (Constants.SECURITY_ROLE_MEMBER.equals(party.getRoleName())) {
            this.tipService.saveTip(entity.getUuid().toString(), TipConstants.C2C_APPEAL);
        }
        return Result.succeed();
    }
 
    /**
     * 获取 申诉详情
     */
    @RequestMapping(action + "get.action")
    public Result get(HttpServletRequest request) throws IOException {
        String order_no = request.getParameter("order_no");
        if (StringUtils.isEmptyString(order_no)) {
            throw new YamiShopBindException("申诉订单号不正确");
        }
        C2cAppeal c2cAppeal = this.c2cAppealService.findByOrderNo(order_no);
        if (null == c2cAppeal) {
            throw new YamiShopBindException("申诉不存在");
        }
        if (StringUtils.isNotEmpty(c2cAppeal.getImg())) {
            String path = Constants.IMAGES_HTTP+c2cAppeal.getImg();
            c2cAppeal.setImg(path);
        }
        return Result.succeed();
    }
}