yujian
2020-06-03 80e39e3a40283521fc732c930aa51d9bece7c146
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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
package com.yeshi.fanli.controller.admin.user.cloud;
 
import java.io.PrintWriter;
import java.util.List;
 
import javax.annotation.Resource;
 
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.yeshi.utils.JsonUtil;
 
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.yeshi.fanli.entity.bus.user.UserInfo;
import com.yeshi.fanli.entity.bus.user.cloud.UserCloud;
import com.yeshi.fanli.entity.bus.user.cloud.UserCloudOrder;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.dynamic.GoodsEvaluateService;
import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
import com.yeshi.fanli.service.inter.user.UserInfoService;
import com.yeshi.fanli.service.inter.user.cloud.UserCloudGoodsService;
import com.yeshi.fanli.service.inter.user.cloud.UserCloudGroupService;
import com.yeshi.fanli.service.inter.user.cloud.UserCloudManageService;
import com.yeshi.fanli.service.inter.user.cloud.UserCloudOrderService;
import com.yeshi.fanli.service.inter.user.cloud.UserCloudService;
import com.yeshi.fanli.service.manger.alipay.UserCloudAlipayManager;
import com.yeshi.fanli.tag.PageEntity;
import com.yeshi.fanli.util.Constant;
 
import net.sf.json.JSONObject;
 
@Controller
@RequestMapping("admin/new/api/v1/cloud")
public class  UserCloudAdminController {
 
    @Resource
    private UserCloudService userCloudService;
 
    @Resource
    private UserCloudOrderService userCloudOrderService;
 
    @Resource
    private UserCloudGroupService userCloudGroupService;
 
    @Resource
    private UserCloudGoodsService userCloudGoodsService;
 
    @Resource
    private UserInfoService userInfoService;
 
    @Resource
    private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
 
    @Resource
    private UserCloudManageService userCloudManageService;
 
    @Resource
    private UserCloudAlipayManager userCloudAlipayManager;
    
    @Resource
    private GoodsEvaluateService goodsEvaluateService;
    
    
    
    /**
     * 订单信息查询
     * @param callback
     * @param pageIndex
     * @param key
     * @param state
     * @param out
     */
    @RequestMapping(value = "queryOrder")
    public void queryOrder(String callback, Integer pageIndex, Integer pageSize, String key, Integer state, PrintWriter out) {
        try {
            if (pageIndex == null)
                pageIndex = 1;
            if (pageSize == null)
                pageSize = Constant.PAGE_SIZE;
            List<UserCloudOrder> list = userCloudOrderService.query(pageIndex, pageSize, key, state);
            if (list == null || list.size() == 0) {
                out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("暂无数据")));
                return;
            }
            
            for (UserCloudOrder cloudOrder: list) {
                UserInfo userInfo = userInfoService.getUserByIdWithMybatis(cloudOrder.getUid());
                if (userInfo == null)
                    continue;
                
                cloudOrder.setNickName(userInfo.getNickName());
                cloudOrder.setPortrait(userInfo.getPortrait());
            }
            
            GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.serializeNulls(); // 重点
            Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
 
            long count = userCloudOrderService.count(key, state);
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
            
            JSONObject data = new JSONObject();
            data.put("pe", pe);
            data.put("list", gson.toJson(list));
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
        } catch (Exception e) {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("操作异常")));
            e.printStackTrace();
            LogHelper.errorDetailInfo(e);
        }
    }
 
    
    /**
     * 开通成功记录
     * @param callback
     * @param pageIndex
     * @param key
     * @param state
     * @param out
     */
    @RequestMapping(value = "queryCloud")
    public void queryCloud(String callback, Integer pageIndex, Integer pageSize, String key, Integer state, PrintWriter out) {
        try {
            if (pageIndex == null)
                pageIndex = 1;
            if (pageSize == null)
                pageSize = Constant.PAGE_SIZE;
            List<UserCloud> list = userCloudService.query(pageIndex, pageSize, key, state);
            if (list == null || list.size() == 0) {
                out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("暂无数据")));
                return;
            }
            
            for (UserCloud userCloud: list) {
                UserInfo userInfo = userInfoService.getUserByIdWithMybatis(userCloud.getUid());
                if (userInfo == null)
                    continue;
                
                userCloud.setNickName(userInfo.getNickName());
                userCloud.setPortrait(userInfo.getPortrait());
            }
            
            GsonBuilder gsonBuilder = new GsonBuilder();
            gsonBuilder.serializeNulls(); // 重点
            Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
 
            long count = userCloudService.count(key, state);
            int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
            PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
            
            JSONObject data = new JSONObject();
            data.put("pe", pe);
            data.put("list", gson.toJson(list));
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
        } catch (Exception e) {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("操作异常")));
            e.printStackTrace();
            LogHelper.errorDetailInfo(e);
        }
    }
}