1
zj
2026-03-20 737589b78d687c3a1fe43d13dc39e8cc0e2429d0
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
package com.nq.service.impl;
 
import com.nq.common.ServerResponse;
import com.nq.dao.SitePayOptionMapper;
import com.nq.pojo.SitePayOption;
import com.nq.service.ISitePayOptionService;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import javax.annotation.Resource;
import java.util.List;
 
@Service
public class SitePayOptionServiceImpl implements ISitePayOptionService {
 
    @Resource
    private SitePayOptionMapper sitePayOptionMapper;
 
    @Override
    public ServerResponse listForAdmin() {
        List<SitePayOption> list = sitePayOptionMapper.listAllOrderBySort();
        return ServerResponse.createBySuccess(list);
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public ServerResponse updateSort(List<Integer> orderedIds) {
        if (CollectionUtils.isEmpty(orderedIds)) {
            return ServerResponse.createByErrorMsg("排序数据不能为空");
        }
        for (int i = 0; i < orderedIds.size(); i++) {
            Integer id = orderedIds.get(i);
            int param = i;
            int sortOrder = i;
            sitePayOptionMapper.updateParamAndSortOrder(id, param, sortOrder);
        }
        return ServerResponse.createBySuccessMsg("排序已更新");
    }
 
    @Override
    public ServerResponse setEnabled(Integer id, Integer enabled) {
        if (id == null) {
            return ServerResponse.createByErrorMsg("id不能为空");
        }
        if (enabled == null || (enabled != 0 && enabled != 1)) {
            return ServerResponse.createByErrorMsg("enabled 只能为 0 或 1");
        }
        int n = sitePayOptionMapper.updateEnabled(id, enabled);
        if (n > 0) {
            return ServerResponse.createBySuccessMsg(enabled == 1 ? "已开启" : "已关闭");
        }
        return ServerResponse.createByErrorMsg("操作失败");
    }
 
    @Override
    public ServerResponse listForH5() {
        List<SitePayOption> list = sitePayOptionMapper.listEnabledOrderBySort();
        return ServerResponse.createBySuccess(list);
    }
}