Administrator
2025-04-23 595b7935a30e84fba1bc3561d05f9d19d3e32e1f
后台管理页面完成
9个文件已修改
137 ■■■■ 已修改文件
src/main/java/com/taoke/autopay/controller/admin/AdminWxUserController.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/taoke/autopay/controller/admin/credit/UserCreditExchangeRecordAdminController.java 61 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/taoke/autopay/factory/WxUserFactory.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/taoke/autopay/manager/UserCreditExchangeManager.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/taoke/autopay/vo/WxUserVO.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/static/admin/agent-list.html 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/static/admin/agent-update.html 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/static/admin/credit-exchange-record-list.html 27 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/static/admin/user-list.html 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/taoke/autopay/controller/admin/AdminWxUserController.java
@@ -9,10 +9,12 @@
import com.taoke.autopay.entity.AdminUser;
import com.taoke.autopay.entity.WxUserInfo;
import com.taoke.autopay.entity.WxUserSettings;
import com.taoke.autopay.entity.credit.UserCreditBalance;
import com.taoke.autopay.factory.WxUserFactory;
import com.taoke.autopay.service.AdminUserService;
import com.taoke.autopay.service.WxUserService;
import com.taoke.autopay.service.WxUserSettingService;
import com.taoke.autopay.service.credit.UserCreditBalanceService;
import com.taoke.autopay.utils.TimeUtil;
import com.taoke.autopay.vo.WxUserOrderSettingVO;
import com.taoke.autopay.vo.WxUserVO;
@@ -60,6 +62,9 @@
    @Resource
    private WxUserSettingService wxUserSettingService;
    @Resource
    private UserCreditBalanceService userCreditBalanceService;
    /**
     * @param key
@@ -99,6 +104,7 @@
        List<WxUserInfo> userList = wxUserService.list(query, page, limit);
        long count = wxUserService.count(query);
        Map<Long, WxUserSettings> settingsMap = new HashMap<>();
        Map<Long, UserCreditBalance> creditBalanceMap = new HashMap<>();
        if (userList.size() > 0) {
            List<Long> uids = new ArrayList<>();
            for (WxUserInfo u : userList) {
@@ -108,12 +114,16 @@
            for (WxUserSettings setting : settings) {
                settingsMap.put(setting.getId(), setting);
            }
            // 获取用户积分余额
            creditBalanceMap = userCreditBalanceService.getCreditBalancesByUserIds(uids);
        }
        // 转vo
        List<WxUserVO> voList = new ArrayList<>();
        for (WxUserInfo user : userList) {
            voList.add(WxUserFactory.createVO(user, settingsMap.get(user.getId())));
            voList.add(WxUserFactory.createVO(user, settingsMap.get(user.getId()), creditBalanceMap.get(user.getId())));
        }
        JSONObject data = new JSONObject();
        data.put("count", count);
src/main/java/com/taoke/autopay/controller/admin/credit/UserCreditExchangeRecordAdminController.java
@@ -14,6 +14,7 @@
import com.taoke.autopay.utils.StringUtil;
import com.taoke.autopay.utils.TimeUtil;
import com.taoke.autopay.vo.admin.UserCreditExchangeRecordSearchVO;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -34,22 +35,22 @@
    private Gson gson = new GsonBuilder()
            .registerTypeAdapter(Date.class, new TypeAdapter<Date>() {
        @Override
        public void write(JsonWriter out, Date value) throws IOException {
            String desc = "";
            if (value != null) {
                desc = TimeUtil.getGernalTime(value.getTime(), "yyyy-MM-dd HH:mm:ss");
                out.value(desc);
            } else {
                out.value("");
            }
        }
                @Override
                public void write(JsonWriter out, Date value) throws IOException {
                    String desc = "";
                    if (value != null) {
                        desc = TimeUtil.getGernalTime(value.getTime(), "yyyy-MM-dd HH:mm:ss");
                        out.value(desc);
                    } else {
                        out.value("");
                    }
                }
        @Override
        public Date read(JsonReader in) throws IOException {
            return new Date();
        }
    }) .registerTypeAdapter(CreditExchangeRecord.ExchangeType.class, new TypeAdapter<CreditExchangeRecord.ExchangeType>() {
                @Override
                public Date read(JsonReader in) throws IOException {
                    return new Date();
                }
            }).registerTypeAdapter(CreditExchangeRecord.ExchangeType.class, new TypeAdapter<CreditExchangeRecord.ExchangeType>() {
                @Override
                public void write(JsonWriter out, CreditExchangeRecord.ExchangeType value) throws IOException {
                    String desc = "";
@@ -76,12 +77,12 @@
    @ResponseBody
    @RequestMapping("list")
    public String listRecords(UserCreditExchangeRecordSearchVO search, int page, int limit) {
        CreditExchangeRecordMapper.DaoQuery query =  CreditExchangeRecordMapper.DaoQuery.builder().build();
        CreditExchangeRecordMapper.DaoQuery query = CreditExchangeRecordMapper.DaoQuery.builder().build();
        if (!StringUtil.isNullOrEmpty(search.getUid())) {
            query.uid = Long.parseLong(search.getUid());
        }
        if (!StringUtil.isNullOrEmpty(search.getStatus())) {
            query.exchangeStatus =Integer.parseInt(search.getStatus());
            query.exchangeStatus = Integer.parseInt(search.getStatus());
        }
        if (!StringUtil.isNullOrEmpty(search.getStart_date())) {
@@ -89,7 +90,7 @@
        }
        if (!StringUtil.isNullOrEmpty(search.getEnd_date())) {
            query.maxCreateTime = new Date(TimeUtil.convertToTimeTemp(search.getEnd_date(), "yyyy-MM-dd")+1000*60*60*24L);
            query.maxCreateTime = new Date(TimeUtil.convertToTimeTemp(search.getEnd_date(), "yyyy-MM-dd") + 1000 * 60 * 60 * 24L);
        }
        query.sortList = Arrays.asList(new String[]{"_create_time desc"});
        query.start = (long) (page - 1) * limit;
@@ -109,18 +110,20 @@
     */
    @ResponseBody
    @RequestMapping("approve")
    public String approveRecords(Long[] ids) {
    public String approveRecords(String ids) {
        int successCount = 0;
        int failCount = 0;
        for(Long id :ids) {
        JSONArray idsArray = JSONArray.fromObject(ids);
        for (int i = 0; i < idsArray.size(); i++) {
            long id = idsArray.optLong(i);
            try {
                userCreditExchangeManager.approveExchange(id);
                successCount+=1;
                successCount += 1;
            } catch (UserCreditExchangeException e) {
                failCount+=1;
                failCount += 1;
            }
        }
        return JsonUtil.loadTrueResult(String.format("成功通过 %d 条记录 通过异常 %d 条记录", successCount, failCount));
        return JsonUtil.loadFalseResult(String.format("成功通过 %d 条记录 通过异常 %d 条记录", successCount, failCount));
    }
    /**
@@ -128,17 +131,19 @@
     */
    @ResponseBody
    @RequestMapping("reject")
    public String rejectRecords(Long[] ids) {
    public String rejectRecords(String ids) {
        int successCount = 0;
        int failCount = 0;
        for(Long id :ids) {
        JSONArray idsArray = JSONArray.fromObject(ids);
        for (int i = 0; i < idsArray.size(); i++) {
            long id = idsArray.optLong(i);
            try {
                userCreditExchangeManager.rejectExchange(id);
                successCount+=1;
                successCount += 1;
            } catch (UserCreditExchangeException e) {
                failCount+=1;
                failCount += 1;
            }
        }
        return JsonUtil.loadTrueResult(String.format("成功驳回 %d 条记录 驳回异常 %d 条记录", successCount, failCount));
        return JsonUtil.loadFalseResult(String.format("成功驳回 %d 条记录 驳回异常 %d 条记录", successCount, failCount));
    }
}
src/main/java/com/taoke/autopay/factory/WxUserFactory.java
@@ -3,6 +3,7 @@
import com.google.gson.Gson;
import com.taoke.autopay.entity.WxUserInfo;
import com.taoke.autopay.entity.WxUserSettings;
import com.taoke.autopay.entity.credit.UserCreditBalance;
import com.taoke.autopay.utils.IPUtil;
import com.taoke.autopay.utils.StringUtil;
import com.taoke.autopay.vo.WxUserOrderSettingVO;
@@ -16,7 +17,7 @@
 */
public class WxUserFactory {
    public static WxUserVO createVO(WxUserInfo user, WxUserSettings settings) {
    public static WxUserVO createVO(WxUserInfo user, WxUserSettings settings, UserCreditBalance balance) {
        WxUserVO vo = new WxUserVO();
        vo.setId(user.getId());
        vo.setCreateTime(user.getCreateTime());
@@ -28,6 +29,7 @@
            vo.setIpInfo(new Gson().fromJson(user.getLatestIPInfo(), IPUtil.IPInfo.class));
        }
        vo.setStatus(user.getStatus());
        vo.setCredit(balance==null?0:balance.getCreditBalance());
        if(settings!=null) {
            WxUserOrderSettingVO settingVO = new WxUserOrderSettingVO(settings.getDyOrderCountPerDay(), settings.getKsOrderCountPerDay(), settings.getTotalOrderCountPerDay());
            vo.setOrderSetting(settingVO);
src/main/java/com/taoke/autopay/manager/UserCreditExchangeManager.java
@@ -117,6 +117,10 @@
            throw new UserCreditExchangeException(UserCreditExchangeException.CODE_NOT_BIND_ALIPAY_ACCOUNT, "兑换记录不存在");
        }
        if(exchangeRecord.getExchangeStatus() != CreditExchangeRecord.STATUS_NOT_VERIFY){
            throw new UserCreditExchangeException(UserCreditExchangeException.CODE_COMMON, "兑换已处理");
        }
        // 如果是红包兑换,调用通过兑换逻辑(TODO)
        if (exchangeRecord.getExchangeType() == CreditExchangeRecord.ExchangeType.FUND_EXCHANGE) {
            // TODO: 调用通过兑换逻辑
@@ -143,6 +147,11 @@
            throw new UserCreditExchangeException(UserCreditExchangeException.CODE_NOT_BIND_ALIPAY_ACCOUNT, "兑换记录不存在");
        }
        if(exchangeRecord.getExchangeStatus() != CreditExchangeRecord.STATUS_NOT_VERIFY){
            throw new UserCreditExchangeException(UserCreditExchangeException.CODE_COMMON, "兑换已处理");
        }
        // 退回用户积分余额
        userCreditBalanceService.increaseCreditBalance(exchangeRecord.getUid(), exchangeRecord.getConsumedCredits());
        // 添加积分记录
src/main/java/com/taoke/autopay/vo/WxUserVO.java
@@ -22,4 +22,5 @@
    private String ip;
    private IPUtil.IPInfo ipInfo;
    private Integer status;
    private int credit;
}
src/main/resources/static/admin/agent-list.html
@@ -290,7 +290,18 @@
                    templet: function (d) {
                        return d.status == 0 ? '正常' : '封禁'
                    }
                }, {
                },{
                    field: '',
                    title: '积分是否开启',
                    width: 100,
                    sort: false,
                    templet: function (d) {
                        return d.creditEnable == 0 ? '关闭' : '<span style="color: green">开启</span>'
                    }
                },
                    {
                    field: 'createTime',
                    title: '创建时间',
                    width: 180,
src/main/resources/static/admin/agent-update.html
@@ -152,8 +152,8 @@
            <div class="layui-form-item">
                <label class="layui-form-label">是否开启积分:</label>
                <div class="layui-input-inline">
                    <input type="checkbox" name="creditEnable" required lay-verify=""  autocomplete="off" class="layui-input">
                    <div class="layui-form-mid layui-word-aux">队员是否可得积分</div>
                    <input type="checkbox" checked name="creditEnable" lay-skin="switch" value="1" lay-filter="switchTest" title="">
                </div>
            </div>
src/main/resources/static/admin/credit-exchange-record-list.html
@@ -55,6 +55,13 @@
<script src="layui/layui.js" type="text/javascript" charset="utf-8"></script>
<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/http_api.js"></script>
<script type="text/html" id="toolbarDemo">
    <div class="layui-btn-container">
<!--        <button class="layui-btn layui-btn-sm" lay-event="getCheckData">获取选中行数据</button>-->
<!--        <button class="layui-btn layui-btn-sm" lay-event="getCheckLength">获取选中数目</button>-->
<!--        <button class="layui-btn layui-btn-sm" lay-event="isAll">验证是否全选</button>-->
    </div>
</script>
<script>
    layui.use(['form', 'jquery', 'layer', 'table', 'laydate'], function () {
        var table = layui.table;
@@ -77,13 +84,20 @@
                    "data": res.data.list // 解析数据列表
                };
            },
            toolbar: '#toolbarDemo',
            defaultToolbar: ['filter', 'exports', { //自定义头部工具栏右侧图标。如无需自定义,去除该参数即可
                title: '提示'
                ,layEvent: 'LAYTABLE_TIPS'
                ,icon: 'layui-icon-tips'
            }],
            page: true, // 开启分页
            cols: [
                [
                    {field: 'id', title: 'ID', width: 100, fixed: 'left'},
                    {type:'checkbox',fixed: 'left'},
                    {field: 'id', title: 'ID', width: 100},
                    {field: 'uid', title: '用户ID', width: 150},
                    {field: 'exchangeType', title: '兑换类型', width: 150},
                    {field: 'exchangeValue', title: '兑换数值', width: 150},
                    {field: 'exchangeValue', title: '兑换金额(元)', width: 150},
                    {field: 'consumedCredits', title: '消耗积分', width: 150},
                    {field: 'creditBalance', title: '积分余额', width: 150},
                    {field: 'status', title: '状态', width: 150, templet: function (d) {
@@ -98,7 +112,8 @@
                        }
                        return "未知";
                    }},
                    {field: 'createTime', title: '创建时间', width: 180}
                    {field: 'createTime', title: '创建时间', width: 180},
                    {field: 'updateTime', title: '更新时间', width: 180}
                ]
            ]
        };
@@ -121,9 +136,9 @@
            let ids = checkStatus.data.map(item => item.id);
            if (ids.length === 0) {
                layer.msg("请至少选择一条记录");
                return;
                return true;
            }
            $.post('/admin/api/credit/exchange-record/approve', {ids: ids}, function (response) {
            $.post('/admin/api/credit/exchange-record/approve', {ids: JSON.stringify(ids)}, function (response) {
                if (response.code === 0) {
                    layer.msg(response.msg);
                    tableIns.reload();
@@ -143,7 +158,7 @@
                layer.msg("请至少选择一条记录");
                return;
            }
            $.post('/admin/api/credit/exchange-record/reject', {ids: ids}, function (response) {
            $.post('/admin/api/credit/exchange-record/reject', {ids: JSON.stringify(ids)}, function (response) {
                if (response.code === 0) {
                    layer.msg(response.msg);
                    tableIns.reload();
src/main/resources/static/admin/user-list.html
@@ -160,6 +160,12 @@
                    },
                    {
                        field: 'credit',
                        title: '积分余额',
                        sort: false
                    },
                    {
                        field: '',
                        title: '头像',
                        sort: false,