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.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.SysVipInfo; 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.MoneyCardUseService; import com.matrix.system.hive.service.SysOrderService; import com.matrix.system.hive.service.SysVipInfoService; 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, "会员信息"); } } /** * 查看会员信息 */ @SuppressWarnings("unchecked") @ApiOperation(value = "查看会员信息", notes = "查看会员信息") @GetMapping(value = "/showVipInfo/{phone}") public AjaxResult findByModel(@PathVariable("phone")String phone) { List 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 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; } }