xiaoyong931011
2022-05-05 72e6562ca013e531862a461c2acee822983b03d0
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
package com.matrix.system.padApi.action;
 
import cn.hutool.core.util.StrUtil;
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.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.SysOrder;
import com.matrix.system.hive.bean.SysShopInfo;
import com.matrix.system.hive.bean.SysVipInfo;
import com.matrix.system.hive.bean.SysVipLevel;
import com.matrix.system.hive.dao.MoneyCardUseDao;
import com.matrix.system.hive.dao.ShoppingGoodsDao;
import com.matrix.system.hive.dao.SysVipLabelDao;
import com.matrix.system.hive.pojo.CzXkVo;
import com.matrix.system.hive.service.*;
import com.matrix.system.padApi.dto.PadVipListDto;
import com.matrix.system.score.dao.ScoreVipDetailDao;
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 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);
 
        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("未查到询客户信息");
        }
    }
 
    /**
     * 充值 查询门店所有员工
     */
    @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;
    }
 
}