xiaoyong931011
2022-05-06 583fc7b7ed2ab5961c50e24e779262f168b9d55f
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
package com.matrix.system.padApi.action;
 
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.matrix.component.asyncmessage.AsyncMessageManager;
import com.matrix.core.constance.MatrixConstance;
import com.matrix.core.pojo.AjaxResult;
import com.matrix.core.pojo.PaginationVO;
import com.matrix.core.tools.DateUtil;
import com.matrix.core.tools.StringUtils;
import com.matrix.core.tools.WebUtil;
import com.matrix.system.common.bean.CustomerDataDictionary;
import com.matrix.system.common.bean.SysUsers;
import com.matrix.system.common.constance.AppConstance;
import com.matrix.system.common.dao.CustomerDataDictionaryDao;
import com.matrix.system.common.service.SysUsersService;
import com.matrix.system.constance.Dictionary;
import com.matrix.system.hive.action.BaseController;
import com.matrix.system.hive.action.util.QueryUtil;
import com.matrix.system.hive.bean.*;
import com.matrix.system.hive.dao.*;
import com.matrix.system.hive.pojo.CzXkVo;
import com.matrix.system.hive.service.*;
import com.matrix.system.padApi.dto.*;
import com.matrix.system.score.dao.ScoreUseRecordDao;
import com.matrix.system.score.dao.ScoreVipDetailDao;
import com.matrix.system.shopXcx.api.dto.ScoreFlowDto;
import com.matrix.system.shopXcx.api.vo.ScoreUseRecordVo;
import com.matrix.system.shopXcx.mqTask.AsyncMessageRouting;
import com.matrix.system.wechart.templateMsg.UniformMsgParam;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
 
import javax.annotation.Resource;
import java.util.List;
 
@CrossOrigin(origins = "*")
@Api(value = "PadVipAction", tags = "pad端Vip客户请求")
@RestController
@RequestMapping(value = "/api/pad/vipInfo")
public class PadVipAction extends BaseController {
 
    @Resource
    private SysVipInfoService vipInfoService;
    @Resource
    private SysOrderService sysOrderService;
    @Autowired
    ShoppingGoodsDao shoppingGoodsDao;
    @Autowired
    private ScoreVipDetailDao scoreVipDetailDao;
    @Resource
    private MoneyCardUseService cardUseService;
    @Autowired
    private MoneyCardUseDao moneyCardUseDao;
    @Autowired
    private SysVipLabelDao sysVipLabelDao;
    @Resource
    private SysOrderService orderService;
    @Autowired
    private AsyncMessageManager asyncMessageManager;
    @Autowired
    private SysUsersService sysUsersService;
    @Autowired
    private CustomerDataDictionaryDao dataDictionaryDao;
 
    /**
     * 显示所有的会员信息
     */
    @ApiOperation(value = "显示所有的会员信息列表", notes = "显示所有的会员信息列表")
    @PostMapping(value = "/showVipInfoList")
    public AjaxResult showList(@RequestBody @Validated PadVipListDto padVipListDto) {
 
        SysVipInfo vipInfo = new SysVipInfo();
        QueryUtil.setQueryLimit(vipInfo);
        String queryKey = padVipListDto.getQueryKey();
        if(StrUtil.isNotEmpty(queryKey)){
            vipInfo.setPadQueryKey(queryKey);
        }
        int offset = (padVipListDto.getPageNum() - 1) * padVipListDto.getPageSize();
        int limit = padVipListDto.getPageSize();
        PaginationVO pageVo = new PaginationVO();
        pageVo.setOffset(offset);
        pageVo.setLimit(limit);
 
        //默认排序
        if (StringUtils.isBlank(pageVo.getSort())) {
            pageVo.setSort("create_time");
        }
        if (StringUtils.isBlank(pageVo.getOrder())) {
            pageVo.setOrder("desc");
        }
 
        return showList(vipInfoService, vipInfo, pageVo);
    }
 
    /**
     * 添加或修改会员信息
     */
    @ApiOperation(value = "添加或修改会员信息", notes = "添加或修改会员信息")
    @PostMapping(value = "/addOrModify")
    public AjaxResult addOrModify(@RequestBody SysVipInfo vipInfo) {
        if (vipInfo.getId() != null) {
            return modify(vipInfoService, vipInfo, "会员信息");
        } else {
            vipInfo.setVipState(Dictionary.VIP_STATE_HY);
            SysUsers users = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
            if(vipInfo.getShopId()==null){
                vipInfo.setShopId(users.getShopId());
            }
            if(vipInfo.getCompanyId()==null){
                vipInfo.setCompanyId(users.getCompanyId());
            }
            return add(vipInfoService, vipInfo, "会员信息");
        }
    }
 
    @Resource
    private SysVipLevelService cardLevelService;
 
    @ApiOperation(value = "显示所有的会员卡等级信息,不分页", notes = "显示所有的会员卡等级信息,不分页")
    @GetMapping(value = "/all")
    public AjaxResult all() {
        SysVipLevel sysVipLevel = new SysVipLevel();
        return new AjaxResult(AjaxResult.STATUS_SUCCESS, cardLevelService.findByModel(sysVipLevel), null);
    }
 
    @Resource
    private SysShopInfoService shopInfoService; // 店铺Service
 
    @ApiOperation(value = "所属门店,不分页", notes = "所属门店,不分页")
    @GetMapping(value = "/findShopByRole")
    public AjaxResult findShopByRole() {
        SysUsers user = getMe();
        SysShopInfo shopInfo = new SysShopInfo();
        shopInfo.setCompanyId(user.getCompanyId());
        if(!user.getSuUserType().equals(AppConstance.USER_TYPE_ADMIN) && !user.getShopRole().equals(Dictionary.FLAG_YES_Y)){
            shopInfo.setId(user.getShopId());
        }
        return new AjaxResult(AjaxResult.STATUS_SUCCESS, shopInfoService.findByModel(shopInfo), null);
    }
 
    /**
     * 查看会员信息
     */
    @SuppressWarnings("unchecked")
    @ApiOperation(value = "查看会员信息", notes = "查看会员信息")
    @GetMapping(value = "/showVipInfo/{phone}")
    public AjaxResult findByModel(@PathVariable("phone")String phone) {
        List<SysVipInfo> vips = vipInfoService.findByVipNoOrTel(phone);
        if (vips.size() > 0) {
            vips.get(0).setPointAll(scoreVipDetailDao.selectUserTotalScore(vips.get(0).getId()));
            vips.get(0).setSysOrder(sysOrderService.findSysOrderTjByVipId(vips.get(0).getId()));
            vips.get(0).setLevelCard(cardUseService.findByVipId(vips.get(0).getId()));
            vips.get(0).setLabels(sysVipLabelDao.selectByVipId(vips.get(0).getId()));
            vips.get(0).setAge(DateUtil.getAgeForBirthDay(vips.get(0).getBirthday1()));
            vips.get(0).setBalance(moneyCardUseDao.selectVipCardTotalMoney(vips.get(0).getId()));
            vips.get(0).setArrears(sysOrderService.findVipArrearsByVipId(vips.get(0).getId()));
            AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, vips, 0);
            return result;
        } else {
            return AjaxResult.buildFailInstance("未查到询客户信息");
        }
    }
 
    @Resource
    private SysProjUseService projUseService;
 
    @ApiOperation(value = "项目使用情况", notes = "")
    @PostMapping(value = "/projectList")
    public AjaxResult showTc(@RequestBody PadProjectDto padProjectDto) {
 
        int offset = (padProjectDto.getPageNum() - 1) * padProjectDto.getPageSize();
        int limit = padProjectDto.getPageSize();
        PaginationVO pageVo = new PaginationVO();
        pageVo.setOffset(offset);
        pageVo.setLimit(limit);
 
        SysProjUse sysProjUse = new SysProjUse();
        sysProjUse.setType(Dictionary.SHOPPING_GOODS_TYPE_XM);
        sysProjUse.setTaocanId(-1L);
        sysProjUse.setVipId(padProjectDto.getVipId());
        if(StrUtil.isNotEmpty(padProjectDto.getState())){
            sysProjUse.setStatus(padProjectDto.getState());
        }
        return new AjaxResult(AjaxResult.STATUS_SUCCESS,
                projUseService.findInPage(sysProjUse, pageVo), projUseService.findTotal(sysProjUse));
    }
 
    /**
     * 会员充值卡的列表显示
     */
    @ApiOperation(value = "充值卡的列表显示", notes = "")
    @PostMapping(value = "/showVipMoneyCardList")
    public AjaxResult showVipMoneyCardList(@RequestBody PadVipCardDto padVipCardDto) {
 
        int offset = (padVipCardDto.getPageNum() - 1) * padVipCardDto.getPageSize();
        int limit = padVipCardDto.getPageSize();
        PaginationVO pageVo = new PaginationVO();
        pageVo.setOffset(offset);
        pageVo.setLimit(limit);
 
        MoneyCardUse moneyCardUse = new MoneyCardUse();
        moneyCardUse.setVipId(padVipCardDto.getVipId());
        if(StrUtil.isNotEmpty(padVipCardDto.getState())){
            moneyCardUse.setStatus(padVipCardDto.getState());
        }
        return new AjaxResult(AjaxResult.STATUS_SUCCESS, cardUseService.findVipCardUseInPage(
                moneyCardUse, pageVo), cardUseService.findTotalVipCardUse(moneyCardUse));
    }
 
 
    @Resource
    private SysProjUseService sysProjUseService;
 
    @ApiOperation(value = "套餐使用情况", notes = "")
    @PostMapping(value = "/tcList")
    public AjaxResult showTc(@RequestBody PadTcDto padTcDto) {
        int offset = (padTcDto.getPageNum() - 1) * padTcDto.getPageSize();
        int limit = padTcDto.getPageSize();
        PaginationVO pageVo = new PaginationVO();
        pageVo.setOffset(offset);
        pageVo.setLimit(limit);
 
        SysProjUse sysProjUse = new SysProjUse();
        sysProjUse.setType(Dictionary.SHOPPING_GOODS_TYPE_TC);
        sysProjUse.setVipId(padTcDto.getVipId());
        if(StrUtil.isNotEmpty(padTcDto.getState())){
            sysProjUse.setStatus(padTcDto.getState());
        }
        List<SysProjUse> projUseList =sysProjUseService.findInPage(sysProjUse,pageVo);
        //设置套餐中的项目
        projUseList.forEach(taocanProjUse -> {
            taocanProjUse.setTaocanProjUse(sysProjUseService.selectTaocanProjUse(taocanProjUse.getId(),sysProjUse.getStatus()));
        });
        return new AjaxResult(AjaxResult.STATUS_SUCCESS, projUseList, sysProjUseService.findTotal(sysProjUse));
    }
 
 
    @Autowired
    private SysVipInfoDao sysVipInfoDao;
 
    @Autowired
    private ScoreUseRecordDao scoreUseRecordDao;
 
    @ApiOperation(value = "积分流水记录", notes = "")
    @PostMapping(value = "/flowList")
    @ApiResponses({
            @ApiResponse(code = 200, message = "ok", response = ScoreUseRecordVo.class)
    })
    public AjaxResult getFlowList(@RequestBody ScoreFlowDto scoreFlowDto) {
        SysVipInfo vipInfo = sysVipInfoDao.selectById(scoreFlowDto.getVipId());
        scoreFlowDto.setVipId(vipInfo.getId());
        Page<ScoreUseRecordVo> page=new Page<>(scoreFlowDto.getPageNum(),scoreFlowDto.getPageSize());
        IPage<ScoreUseRecordVo> shopScoreRecord = scoreUseRecordDao.selectFlowList(page,scoreFlowDto);
        AjaxResult result=AjaxResult.buildSuccessInstance(shopScoreRecord.getRecords(),shopScoreRecord.getTotal());
        return result;
    }
 
 
 
    @Autowired
    private SysSkinCheckRecordDao sysSkinCheckRecordDao;
 
    @ApiOperation(value = "皮肤检测记录", notes = "")
    @PostMapping(value = "/skinList")
    public @ResponseBody AjaxResult showList(@RequestBody PadSkinDto padSkinDto) {
 
        int offset = (padSkinDto.getPageNum() - 1) * padSkinDto.getPageSize();
        int limit = padSkinDto.getPageSize();
        PaginationVO pageVo = new PaginationVO();
        pageVo.setOffset(offset);
        pageVo.setLimit(limit);
 
        SysSkinCheckRecord sysSkinCheckRecord = new SysSkinCheckRecord();
        sysSkinCheckRecord.setUserId(padSkinDto.getVipId());
        List<SysSkinCheckRecord> dataList = sysSkinCheckRecordDao.selectInPage(sysSkinCheckRecord, pageVo);
        AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, dataList,
                sysSkinCheckRecordDao.selectTotalRecord(sysSkinCheckRecord));
        return result;
    }
 
    /**
     * 充值 查询门店所有员工
     */
    @ApiOperation(value = "充值 查询门店所有员工", notes = "充值 查询门店所有员工")
    @GetMapping(value = "/shopAll")
    public AjaxResult shopAll() {
        return new AjaxResult(AjaxResult.STATUS_SUCCESS, sysUsersService.findByRoleName(true, null));
    }
    /**
     * 充值 查询业绩类型
     */
    @ApiOperation(value = "充值 查询业绩类型", notes = "充值 查询业绩类型")
    @GetMapping(value = "getListByParentCode/{parentCode}")
    public AjaxResult getListByParentCode(@PathVariable String parentCode) {
        SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
 
        List<CustomerDataDictionary> list = dataDictionaryDao.selectByParentCode(parentCode, user.getCompanyId());
        return new AjaxResult(AjaxResult.STATUS_SUCCESS, list, list.size());
    }
 
    /**
     * 充值 查询当前登录人
     */
    @ApiOperation(value = "充值 查询当前登录人", notes = "充值 查询当前登录人")
    @GetMapping(value = "getLoginUser")
    public AjaxResult getLoginUser() {
        AjaxResult result = AjaxResult.buildSuccessInstance("");
        SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
        result.putInMap("user", user);
        return result;
    }
 
    /**
     * 充值
     */
    @ApiOperation(value = "充值", notes = "充值")
    @PostMapping(value = "/cz")
    public AjaxResult cz(@RequestBody CzXkVo czVo) {
        SysOrder order=  orderService.moneyCardCz(czVo);
        AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, "充值成功");
 
        //发送微信公众号提醒
        UniformMsgParam uniformMsgParam=new UniformMsgParam(order.getCompanyId(),UniformMsgParam.GZH_CZCG);
        uniformMsgParam.put("orderId",order.getId());
        asyncMessageManager.sendMsg(AsyncMessageRouting.SEND_UNIFORM_TEMPLATE_MSG ,uniformMsgParam);
 
        result.putInMap("orderId",order.getId());
        return result;
    }
 
}