|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import com.matrix.core.constance.MatrixConstance; | 
|---|
|  |  |  | import com.matrix.core.pojo.AjaxResult; | 
|---|
|  |  |  | import com.matrix.core.pojo.PaginationVO; | 
|---|
|  |  |  | import com.matrix.core.tools.EncrypUtil; | 
|---|
|  |  |  | import com.matrix.core.tools.StringUtils; | 
|---|
|  |  |  | import com.matrix.core.tools.WebUtil; | 
|---|
|  |  |  | import com.matrix.system.app.dto.AddVipDto; | 
|---|
|  |  |  | import com.matrix.system.app.dto.ModifyVipDto; | 
|---|
|  |  |  | import com.matrix.system.app.dto.QuestionAnswerDto; | 
|---|
|  |  |  | import com.matrix.system.app.dto.VipInfoListDto; | 
|---|
|  |  |  | import com.matrix.system.app.vo.VipInfoListVo; | 
|---|
|  |  |  | import com.matrix.system.app.mapper.MoneyCardUseMapper; | 
|---|
|  |  |  | import com.matrix.system.app.mapper.QuestionMapper; | 
|---|
|  |  |  | import com.matrix.system.app.vo.*; | 
|---|
|  |  |  | 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.tools.DataAuthUtil; | 
|---|
|  |  |  | import com.matrix.system.hive.bean.SysVipLevel; | 
|---|
|  |  |  | import com.matrix.system.common.tools.PasswordUtil; | 
|---|
|  |  |  | 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.MoneyCardUseDao; | 
|---|
|  |  |  | import com.matrix.system.hive.dao.VipAnswerDao; | 
|---|
|  |  |  | import com.matrix.system.hive.plugin.util.CollectionUtils; | 
|---|
|  |  |  | import com.matrix.system.hive.service.MoneyCardUseService; | 
|---|
|  |  |  | import com.matrix.system.hive.service.QuestionSerivce; | 
|---|
|  |  |  | import com.matrix.system.hive.service.SysVipInfoService; | 
|---|
|  |  |  | import com.matrix.system.hive.service.SysVipLevelService; | 
|---|
|  |  |  | import io.swagger.annotations.Api; | 
|---|
|  |  |  | 
|---|
|  |  |  | 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 java.io.UnsupportedEncodingException; | 
|---|
|  |  |  | import java.security.NoSuchAlgorithmException; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | 
|---|
|  |  |  | @Api(value = "ApiVipInfoAction", tags = "会员接口类") | 
|---|
|  |  |  | @RestController | 
|---|
|  |  |  | @RequestMapping(value = "/api/vip") | 
|---|
|  |  |  | public class ApiVipInfoAction { | 
|---|
|  |  |  | public class ApiVipInfoAction extends BaseController { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SysVipInfoService sysVipInfoService; | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private SysVipLevelService sysVipLevelService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private CustomerDataDictionaryDao customerDataDictionaryDao; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MoneyCardUseService moneyCardUseService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private QuestionSerivce questionSerivce; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private VipAnswerDao vipAnswerDao; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "获取会员通讯录列表", notes = "获取会员通讯录列表") | 
|---|
|  |  |  | @ApiResponses({ | 
|---|
|  |  |  | @ApiResponse(code = 200, message = "ok", response = VipInfoListVo.class) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @PostMapping(value = "/findVipInfoList") | 
|---|
|  |  |  | public AjaxResult findVipInfoList(@RequestBody VipInfoListDto vipInfoListDto) { | 
|---|
|  |  |  | if (StringUtils.isBlank(vipInfoListDto.getSort())) { | 
|---|
|  |  |  | vipInfoListDto.setSort("zjm"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (StringUtils.isBlank(vipInfoListDto.getOrder())) { | 
|---|
|  |  |  | vipInfoListDto.setOrder("asc"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | int offset = (vipInfoListDto.getPageNum() - 1) * vipInfoListDto.getPageSize(); | 
|---|
|  |  |  | int limit = vipInfoListDto.getPageSize(); | 
|---|
|  |  |  | vipInfoListDto.setOffset(offset); | 
|---|
|  |  |  | vipInfoListDto.setLimit(limit); | 
|---|
|  |  |  | return AjaxResult.buildSuccessInstance(sysVipInfoService.findVipAddressBook(vipInfoListDto)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "根据手机号查询用户信息", notes = "根据手机号查询用户信息") | 
|---|
|  |  |  | @GetMapping(value = "/findVipInfoByPhone/{phone}") | 
|---|
|  |  |  | public AjaxResult findVipInfoByPhone(@PathVariable("phone") String phone) { | 
|---|
|  |  |  | return null; | 
|---|
|  |  |  | @ApiOperation(value = "根据id查询用户信息(通讯录及个人中心)", notes = "根据id查询用户信息") | 
|---|
|  |  |  | @ApiResponses({ | 
|---|
|  |  |  | @ApiResponse(code = 200, message = "ok", response = VipInfoVo.class) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @GetMapping(value = "/findVipInfoById/{id}") | 
|---|
|  |  |  | public AjaxResult findVipInfoById(@PathVariable("id") Long id) { | 
|---|
|  |  |  | AjaxResult ajaxResult = AjaxResult.buildSuccessInstance("获取成功"); | 
|---|
|  |  |  | VipInfoVo vipInfoVo = sysVipInfoService.findApiVipInfoById(id); | 
|---|
|  |  |  | ajaxResult.putInMap("vipInfo", vipInfoVo); | 
|---|
|  |  |  | return ajaxResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "根据id查询用户详细信息") | 
|---|
|  |  |  | @ApiResponses({ | 
|---|
|  |  |  | @ApiResponse(code = 200, message = "ok", response = VipInfoDetailVo.class) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @GetMapping(value = "/findVipInfoDetailById/{id}") | 
|---|
|  |  |  | public AjaxResult findVipInfoDetailById(@PathVariable("id") Long id) { | 
|---|
|  |  |  | VipInfoDetailVo vipInfoDetailVo = sysVipInfoService.findVipInfoDetail(id); | 
|---|
|  |  |  | AjaxResult ajaxResult = AjaxResult.buildSuccessInstance("获取成功"); | 
|---|
|  |  |  | ajaxResult.putInMap("vipInfo", vipInfoDetailVo); | 
|---|
|  |  |  | return ajaxResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "查询会员类型", notes = "查询会员类型") | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return AjaxResult.buildSuccessInstance(sysVipLevelService.findByModel(sysVipLevel)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "获取到店途径列表", notes = "获取到店途径列表") | 
|---|
|  |  |  | @ApiResponses({ | 
|---|
|  |  |  | @ApiResponse(code = 200, message = "ok", response = CustomerDataDictionary.class) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @GetMapping(value = "/findArrivalWayList") | 
|---|
|  |  |  | public AjaxResult findArrivalWayList() { | 
|---|
|  |  |  | List<CustomerDataDictionary> ddtj = customerDataDictionaryDao.selectByParentCode("DDTJ", getMe().getCompanyId()); | 
|---|
|  |  |  | return AjaxResult.buildSuccessInstance(ddtj); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "添加会员", notes = "添加会员") | 
|---|
|  |  |  | @PostMapping(value = "/addVip") | 
|---|
|  |  |  | public AjaxResult addVip(@RequestBody @Validated AddVipDto addVipDto) { | 
|---|
|  |  |  | int i = sysVipInfoService.apiAddVip(addVipDto); | 
|---|
|  |  |  | if (i > 0) { | 
|---|
|  |  |  | return AjaxResult.buildSuccessInstance("新增成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return AjaxResult.buildFailInstance("新增失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "编辑会员", notes = "编辑会员") | 
|---|
|  |  |  | @PostMapping(value = "/modifyVip") | 
|---|
|  |  |  | public AjaxResult modifyVip(@RequestBody ModifyVipDto modifyVipDto) { | 
|---|
|  |  |  | int i = sysVipInfoService.apiModifyVip(modifyVipDto); | 
|---|
|  |  |  | if (i > 0) { | 
|---|
|  |  |  | return AjaxResult.buildSuccessInstance("修改成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return AjaxResult.buildFailInstance("修改失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "获取用户信息列表", notes = "获取用户信息列表") | 
|---|
|  |  |  | @GetMapping(value = "/findAllVipInfo") | 
|---|
|  |  |  | public AjaxResult findAllVipInfo() { | 
|---|
|  |  |  | SysUsers user = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); | 
|---|
|  |  |  | SysVipInfo sysVipInfo = new SysVipInfo(); | 
|---|
|  |  |  | if(!DataAuthUtil.hasAllShopAuth()) { | 
|---|
|  |  |  | sysVipInfo.setShopId(user.getShopId()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | QueryUtil.setQueryLimitCom(sysVipInfo); | 
|---|
|  |  |  | return AjaxResult.buildSuccessInstance(sysVipInfoService.findAll(sysVipInfo)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "卡项 - 获取会员卡项列表", notes = "卡项 - 获取会员卡项列表") | 
|---|
|  |  |  | @ApiResponses({ | 
|---|
|  |  |  | @ApiResponse(code = 200, message = "ok", response = VipCardListVo.class) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @GetMapping(value = "/findVipCardInfo/{vipId}") | 
|---|
|  |  |  | public AjaxResult findVipCardInfo(@PathVariable("vipId") Long vipId) { | 
|---|
|  |  |  | MoneyCardUse moneyCardUse = new MoneyCardUse(); | 
|---|
|  |  |  | moneyCardUse.setVipId(vipId); | 
|---|
|  |  |  | List<MoneyCardUse> list = moneyCardUseService.findVipCardUseInPage(moneyCardUse, null); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | List<VipCardListVo> dataList = MoneyCardUseMapper.INSTANCE.entitiesToCardListVos(list); | 
|---|
|  |  |  | return AjaxResult.buildSuccessInstance(dataList); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "会员档案 - 获取客户档案问题", notes = "会员档案 - 获取客户档案问题") | 
|---|
|  |  |  | @ApiResponses({ | 
|---|
|  |  |  | @ApiResponse(code = 200, message = "ok", response = QuestionVo.class) | 
|---|
|  |  |  | }) | 
|---|
|  |  |  | @GetMapping(value = "/findVipQuestions/{vipId}") | 
|---|
|  |  |  | public AjaxResult findVipQuestions(@PathVariable("vipId") Long vipId) { | 
|---|
|  |  |  | // 获取会员所有的答案,分类型 | 
|---|
|  |  |  | List<Question> questions = questionSerivce.findByVipId(vipId); | 
|---|
|  |  |  | AjaxResult result = AjaxResult.buildSuccessInstance("获取成功"); | 
|---|
|  |  |  | List<QuestionVo> list = QuestionMapper.INSTANCE.entitiesToVos(questions); | 
|---|
|  |  |  | result.putInMap("questions", list); | 
|---|
|  |  |  | return result; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "会员档案 - 提交会员档案", notes = "会员档案 - 提交会员档案") | 
|---|
|  |  |  | @PostMapping(value = "/saveVipQuestionsAnswer") | 
|---|
|  |  |  | public AjaxResult saveVipQuestionsAnswer(@RequestBody QuestionAnswerDto questionAnswerDto) { | 
|---|
|  |  |  | VipAnswer delAnswer = new VipAnswer(); | 
|---|
|  |  |  | delAnswer.setVipId(questionAnswerDto.getVipId()); | 
|---|
|  |  |  | vipAnswerDao.deleteByModel(delAnswer); | 
|---|
|  |  |  | if (CollectionUtils.isNotEmpty(questionAnswerDto.getItems())) { | 
|---|
|  |  |  | List<VipAnswer> vipAnswers = QuestionMapper.INSTANCE.dtosToVipAnswers(questionAnswerDto.getItems()); | 
|---|
|  |  |  | vipAnswerDao.batchInsert(vipAnswers); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return AjaxResult.buildSuccessInstance("档案更新成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @ApiOperation(value = "用户是否存在资金密码", notes = "用户是否存在资金密码") | 
|---|
|  |  |  | @GetMapping(value = "/isExistFundPassword/{vipId}") | 
|---|
|  |  |  | public AjaxResult isExistFundPassword(@PathVariable(value = "vipId") Long vipId) { | 
|---|
|  |  |  | SysVipInfo vipInfo = sysVipInfoService.findById(vipId); | 
|---|
|  |  |  | AjaxResult ajaxResult = AjaxResult.buildSuccessInstance("获取成功"); | 
|---|
|  |  |  | if (StringUtils.isNotBlank(vipInfo.getPassWord())) { | 
|---|
|  |  |  | ajaxResult.putInMap("isExist", true); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | ajaxResult.putInMap("isExist", false); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ajaxResult; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|