| | |
| | | import com.matrix.core.constance.MatrixConstance; |
| | | import com.matrix.core.pojo.AjaxResult; |
| | | import com.matrix.core.pojo.PaginationVO; |
| | | import com.matrix.core.tools.*; |
| | | import com.matrix.core.tools.DateUtil; |
| | | import com.matrix.core.tools.LogUtil; |
| | | import com.matrix.core.tools.StringUtils; |
| | | import com.matrix.core.tools.WebUtil; |
| | | import com.matrix.core.tools.excl.ExcelSheetPO; |
| | | import com.matrix.core.tools.excl.ExcelUtil; |
| | | import com.matrix.core.tools.excl.ExcelVersion; |
| | | import com.matrix.system.common.bean.SysUsers; |
| | | import com.matrix.system.common.bean.SystemDictionary; |
| | | 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.common.service.SystemDictionaryService; |
| | | import com.matrix.system.common.tools.DataAuthUtil; |
| | | import com.matrix.system.common.tools.ResponseHeadUtil; |
| | | import com.matrix.system.constance.Dictionary; |
| | | import com.matrix.system.constance.SystemConstance; |
| | | import com.matrix.system.hive.action.util.QueryUtil; |
| | | import com.matrix.system.hive.bean.Question; |
| | | import com.matrix.system.hive.bean.SysVipInfo; |
| | | import com.matrix.system.hive.bean.SysVipLevel; |
| | | import com.matrix.system.hive.bean.VipAnswer; |
| | | import com.matrix.system.hive.bean.*; |
| | | 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.dao.VipAnswerDao; |
| | | import com.matrix.system.hive.pojo.RegisterInfo; |
| | | import com.matrix.system.hive.service.*; |
| | | import com.matrix.system.score.dao.ScoreVipDetailDao; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.ui.ModelMap; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.OutputStream; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLDecoder; |
| | | import java.net.URLEncoder; |
| | | import java.security.NoSuchAlgorithmException; |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Calendar; |
| | | import java.util.List; |
| | | |
| | | |
| | | /** |
| | |
| | | @Controller |
| | | @RequestMapping(value = "admin/vipInfo") |
| | | public class VipInfoController extends BaseController { |
| | | |
| | | |
| | | @Value("${file_storage_path}") |
| | | private String fileStoragePath; |
| | | |
| | | @Resource |
| | | private SysVipInfoService vipInfoService; |
| | | |
| | |
| | | private CustomerDataDictionaryDao customerDataDictionaryDao; |
| | | @Resource |
| | | private SysOrderService sysOrderService; |
| | | |
| | | @Autowired |
| | | ShoppingGoodsDao shoppingGoodsDao; |
| | | @Autowired |
| | | private ScoreVipDetailDao scoreVipDetailDao; |
| | | @Resource |
| | | private SysProjUseService projUseService; |
| | | @Resource |
| | | HttpServletResponse response; |
| | | |
| | | @RequestMapping(value = "/exportExcel/{vipId}") |
| | | public void getVipAllProjInfo(@PathVariable Long vipId) throws IOException { |
| | | |
| | | List<ExcelSheetPO> res = new ArrayList<>(); |
| | | ExcelSheetPO orderSheet = new ExcelSheetPO(); |
| | | |
| | | SysVipInfo vipInfo = vipInfoService.findById(vipId); |
| | | |
| | | String title = vipInfo.getVipName()+"("+vipInfo.getVipNo()+")会员资料"; |
| | | orderSheet.setSheetName(title); |
| | | orderSheet.setTitle(title); |
| | | String[] header = {"产品类型", "产品名称","来源", "状态", "余额", "余次", "到期时间", "本金", "赠金"}; |
| | | orderSheet.setHeaders(header); |
| | | |
| | | |
| | | SysProjUse queryUse = new SysProjUse(); |
| | | queryUse.setVipId(vipId); |
| | | queryUse.setType(Dictionary.SHOPPING_GOODS_TYPE_XM); |
| | | queryUse.setTaocanId(-1L); |
| | | queryUse.setStatus(Dictionary.TAOCAN_STATUS_YX); |
| | | List<SysProjUse> projList = projUseService.findInPage(queryUse, null); |
| | | |
| | | List<List<Object>> list = new ArrayList<>(); |
| | | if (projList.size() > 0) { |
| | | for (SysProjUse item : projList) { |
| | | List<Object> temp = new ArrayList<>(); |
| | | temp.add("项目"); |
| | | temp.add(item.getProjName()); |
| | | temp.add(item.getSource()); |
| | | temp.add("有效"); |
| | | temp.add(item.getBalance()); |
| | | temp.add(item.getSurplusCount()); |
| | | temp.add(DateUtil.dateToString(item.getFailTimeStr(),DateUtil.DATE_FORMAT_DD)); |
| | | temp.add(""); |
| | | temp.add(""); |
| | | list.add(temp); |
| | | } |
| | | } |
| | | //套餐 |
| | | //切换到套餐查询条件 |
| | | SysProjUse queryTaocan = new SysProjUse(); |
| | | queryTaocan.setType(Dictionary.SHOPPING_GOODS_TYPE_TC); |
| | | queryTaocan.setStatus(Dictionary.TAOCAN_STATUS_YX); |
| | | queryTaocan.setVipId(vipId); |
| | | List<SysProjUse> taoCanList = projUseService.findInPage(queryTaocan, null); |
| | | taoCanList.forEach(item->{ |
| | | item.setTaocanProjUse(projUseService.selectTaocanProjUse(item.getId(), queryUse.getStatus())); |
| | | item.setProjInfo(shoppingGoodsDao.selectById(item.getProjId())); |
| | | }); |
| | | if (taoCanList.size() > 0) { |
| | | for (SysProjUse item : taoCanList) { |
| | | List<Object> temp = new ArrayList<>(); |
| | | |
| | | if(Dictionary.FLAG_YES_Y.equals(item.getIsCourse())){ |
| | | temp.add("任选套餐"); |
| | | }else{ |
| | | temp.add("固定套餐"); |
| | | } |
| | | temp.add(item.getProjName()); |
| | | temp.add(item.getSource()); |
| | | temp.add("有效"); |
| | | temp.add(item.getBalance()); |
| | | temp.add(item.getSurplusCount()); |
| | | temp.add(DateUtil.dateToString(item.getFailTimeStr(),DateUtil.DATE_FORMAT_DD)); |
| | | temp.add(""); |
| | | temp.add(""); |
| | | list.add(temp); |
| | | |
| | | //套餐下项目 |
| | | List<SysProjUse> taocanProjUse = item.getTaocanProjUse(); |
| | | if (taocanProjUse.size() > 0) { |
| | | for (SysProjUse proj_item : taocanProjUse) { |
| | | List<Object> temp2 = new ArrayList<>(); |
| | | temp2.add(" |————"); |
| | | temp2.add(proj_item.getProjName()); |
| | | temp2.add(proj_item.getSource()); |
| | | temp2.add("有效"); |
| | | temp2.add(proj_item.getBalance()); |
| | | temp2.add(proj_item.getSurplusCount()); |
| | | temp2.add(DateUtil.dateToString(proj_item.getFailTimeStr(),DateUtil.DATE_FORMAT_DD)); |
| | | temp2.add(""); |
| | | temp2.add(""); |
| | | list.add(temp2); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } |
| | | |
| | | |
| | | //储值卡 |
| | | MoneyCardUse moneyCardUse = new MoneyCardUse(); |
| | | moneyCardUse.setVipId(vipId); |
| | | moneyCardUse.setStatus(Dictionary.MONEYCARD_STATUS_YX); |
| | | List<MoneyCardUse> cards = cardUseService.findByModel(moneyCardUse); |
| | | |
| | | if (cards.size() > 0) { |
| | | for (MoneyCardUse item : cards) { |
| | | List<Object> temp = new ArrayList<>(); |
| | | temp.add("储值卡"); |
| | | temp.add(item.getCardName()); |
| | | temp.add(item.getSource()); |
| | | temp.add("有效"); |
| | | temp.add(""); |
| | | temp.add(item.getLastCount()); |
| | | temp.add(DateUtil.dateToString(item.getFailTime(),DateUtil.DATE_FORMAT_DD)); |
| | | temp.add(item.getRealMoney()); |
| | | temp.add(item.getGiftMoney()); |
| | | list.add(temp); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | orderSheet.setDataList(list); |
| | | res.add(orderSheet); |
| | | response = ResponseHeadUtil.setExcelHead(response); |
| | | response.setHeader("Content-Disposition", |
| | | "attachment;filename=" + URLEncoder.encode(title + DateUtil.getTimeMark() + ".xlsx".trim(), "UTF-8")); |
| | | OutputStream os = response.getOutputStream(); |
| | | ExcelUtil.createWorkbookAtOutStream(ExcelVersion.V2007, res, os, true); |
| | | } |
| | | |
| | | |
| | | |
| | | @RequestMapping(value = "/showVipLevel") |
| | |
| | | public @ResponseBody |
| | | AjaxResult showList(PaginationVO pageVo, SysVipInfo vipInfo) { |
| | | |
| | | // if (!getMe().getShopRole().equals(Dictionary.FLAG_YES_Y)) { |
| | | vipInfo.setShopId(getMe().getShopId()); |
| | | // } |
| | | |
| | | QueryUtil.setQueryLimit(vipInfo); |
| | | |
| | | return showList(vipInfoService, vipInfo, pageVo); |
| | | } |
| | | |
| | |
| | | |
| | | List<SysVipInfo> vips = vipInfoService.findByVipNoOrTel(keyWord); |
| | | if (vips.size() > 0) { |
| | | vips.get(0).setPointAll(scoreVipDetailDao.selectUserTotalScore(null,vips.get(0).getId())); |
| | | 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())); |
| | | AjaxResult result= new AjaxResult(AjaxResult.STATUS_SUCCESS, vips, 0); |
| | | vips.get(0).setArrears(sysOrderService.findVipArrearsByVipId(vips.get(0).getId())); |
| | | AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, vips, 0); |
| | | return result; |
| | | }else{ |
| | | } else { |
| | | return AjaxResult.buildFailInstance("未查到询客户信息"); |
| | | } |
| | | |
| | |
| | | public @ResponseBody |
| | | AjaxResult addOrModify(SysVipInfo vipInfo) { |
| | | if (vipInfo.getId() != null) { |
| | | |
| | | try { |
| | | if (vipInfo.getPassWord() != null) { |
| | | vipInfo.setPassWord(EncrypUtil.getMD5(vipInfo.getPassWord())); |
| | | } |
| | | } catch (UnsupportedEncodingException | NoSuchAlgorithmException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return modify(vipInfoService, vipInfo, "会员信息"); |
| | | } else { |
| | | |
| | | try { |
| | | if (StringUtils.isNotBlank(vipInfo.getPassWord())) { |
| | | vipInfo.setPassWord(EncrypUtil.getMD5(vipInfo.getPassWord())); |
| | | } |
| | | vipInfo.setVipState(Dictionary.VIP_STATE_HY); |
| | | } catch (UnsupportedEncodingException | NoSuchAlgorithmException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | vipInfo.setVipState(Dictionary.VIP_STATE_HY); |
| | | SysUsers users = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); |
| | | vipInfo.setShopId(users.getShopId()); |
| | | if(vipInfo.getShopId()==null){ |
| | | vipInfo.setShopId(users.getShopId()); |
| | | } |
| | | return add(vipInfoService, vipInfo, "会员信息"); |
| | | } |
| | | } |
| | |
| | | @RequestMapping(value = "/del") |
| | | public @ResponseBody |
| | | AjaxResult del(String keys) { |
| | | |
| | | return remove(vipInfoService, keys); |
| | | List<Long> ids = StringUtils.strToCollToLong(keys, ","); |
| | | int i = vipInfoService.removeLogic(ids); |
| | | if (i > 0) { |
| | | return new AjaxResult(AjaxResult.STATUS_SUCCESS, "成功删除" + i + "条数据"); |
| | | } else { |
| | | return new AjaxResult(AjaxResult.STATUS_FAIL, "删除失败"); |
| | | } |
| | | // return remove(vipInfoService, keys); |
| | | } |
| | | |
| | | /** |
| | |
| | | public @ResponseBody |
| | | AjaxResult getVipQuestions(Long id, HttpServletRequest request) { |
| | | // 获取会员所有的答案,分类型 |
| | | List<Question> questions = questionSerivce.findByVipId(id); |
| | | SysUsers user = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY); |
| | | List<Question> questions = questionSerivce.findByVipId(id, user.getCompanyId()); |
| | | request.setAttribute("questions", questions); |
| | | AjaxResult result = new AjaxResult(); |
| | | result.putInMap("questions", questions); |
| | |
| | | SystemDictionary dataDictionary = new SystemDictionary(); |
| | | // 获取到店途径 |
| | | dataDictionary.setType("到店途径"); |
| | | WebUtil.getRequest().setAttribute("ddtj", customerDataDictionaryDao.selectByParentCode("DDTJ",getMe().getCompanyId())); |
| | | WebUtil.getRequest().setAttribute("ddtj", customerDataDictionaryDao.selectByParentCode("DDTJ", getMe().getCompanyId())); |
| | | // 获取生肖 |
| | | dataDictionary.setType("生肖"); |
| | | WebUtil.getRequest().setAttribute("sx", dataDictionaryService.findByModel(dataDictionary)); |
| | |
| | | vipInfo.setVipState(Dictionary.VIP_STATE_HY); |
| | | vipInfo.setStaffId(getMe().getSuId()); |
| | | vipInfo.setShopId(getMe().getShopId()); |
| | | vipInfo.setCompanyId(getMe().getCompanyId()); |
| | | vipInfo.setVipType(Dictionary.VIP_TYPE_NOCARD); |
| | | vipInfoService.add(vipInfo); |
| | | return new AjaxResult(AjaxResult.STATUS_SUCCESS, "会员信息注册成功"); |
| | |
| | | @RequestMapping(value = "/findUserByPhoneOrNo") |
| | | public @ResponseBody |
| | | AjaxResult findUserByPhoneOrNo(String keyWord) { |
| | | LinkedList<SysVipInfo> userList = null; |
| | | // 获取最近查询客户 |
| | | if (WebUtil.getSession().getAttribute(SystemConstance.HISTORY_CUSTOMER) == null) { |
| | | userList = new LinkedList<SysVipInfo>(); |
| | | WebUtil.getSession().setAttribute(SystemConstance.HISTORY_CUSTOMER, userList); |
| | | } else { |
| | | userList = (LinkedList<SysVipInfo>) WebUtil.getSession().getAttribute(SystemConstance.HISTORY_CUSTOMER); |
| | | } |
| | | List<SysVipInfo> vips = vipInfoService.findByVipNoOrTel(keyWord); |
| | | if (vips.size() > 0) { |
| | | // 在session存放当前查询的客户 |
| | | WebUtil.getSession().setAttribute(SystemConstance.CURRENT_CUSTOMER, vips.get(0)); |
| | | // 满20后删除一个 |
| | | if (userList.size() == 20) { |
| | | userList.poll(); |
| | | } |
| | | // 去重标志 |
| | | boolean isNoRepeat = true; |
| | | for (SysVipInfo sysVipInfo : userList) { |
| | | if (vips.get(0).getPhone().equals(sysVipInfo.getPhone())) { |
| | | isNoRepeat = false; |
| | | } |
| | | } |
| | | if (isNoRepeat) { |
| | | userList.add(vips.get(0)); |
| | | } |
| | | } |
| | | return new AjaxResult(AjaxResult.STATUS_SUCCESS, vips, 0); |
| | | |
| | | } |
| | |
| | | } |
| | | |
| | | @RequestMapping(value = "/exportExcel") |
| | | public void report(ModelMap model, HttpServletRequest request, HttpServletResponse response, |
| | | public void report( HttpServletResponse response, |
| | | SysVipInfo vipInfo) throws IOException { |
| | | |
| | | if (vipInfo.getVipType() != null && !(vipInfo.getVipType().equals(""))) { |
| | | vipInfo.setVipType(URLDecoder.decode(vipInfo.getVipType(), "UTF-8")); |
| | | } |
| | | if (vipInfo.getVipName() != null && !"".equals(vipInfo.getVipName())) { |
| | | vipInfo.setVipName(URLDecoder.decode(vipInfo.getVipName(), "UTF-8")); |
| | | } |
| | | if (vipInfo.getArrivalWay() != null && !"".equals(vipInfo.getArrivalWay())) { |
| | | vipInfo.setArrivalWay(URLDecoder.decode(vipInfo.getArrivalWay(), "UTF-8")); |
| | | } |
| | | if (vipInfo.getVipState() != null && !"".equals(vipInfo.getVipState())) { |
| | | vipInfo.setVipState(URLDecoder.decode(vipInfo.getVipState(), "UTF-8")); |
| | | SysUsers sysUsers = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY); |
| | | if(!DataAuthUtil.hasAllShopAuth()){ |
| | | vipInfo.setShopId(sysUsers.getShopId()); |
| | | } |
| | | |
| | | List<ExcelSheetPO> res = new ArrayList<>(); |
| | | ExcelSheetPO orderSheet = new ExcelSheetPO(); |
| | | String title = "每日单据明细"; |
| | | String title = "会员资料"; |
| | | orderSheet.setSheetName(title); |
| | | orderSheet.setTitle(title); |
| | | String[] header = {"会员编号", "姓名", "性别", "手机号码", "会员类型", "会员活跃度", "到店途径", "健康顾问", "所属门店"}; |
| | |
| | | return showList(vipInfoService, info, null); |
| | | } |
| | | |
| | | |
| | | |
| | | @RequestMapping(value = "/importVipInfo") |
| | | @ResponseBody |
| | | public AjaxResult importVipInfo(HttpServletResponse response, HttpServletRequest request, @RequestParam(value = "file", required = false) MultipartFile file) throws IOException { |
| | | |
| | | String fileName = file.getOriginalFilename(); |
| | | String dirPath = PropertiesUtil.getString(AppConstance.FILES_TORAGE_PATH); |
| | | String dirPath = fileStoragePath; |
| | | // String dirPath = "C:/Users/wzy19/Desktop/zq"; |
| | | File fileDir = new File(dirPath); |
| | | LogUtil.info("#----->{}#", fileDir.exists()); |
| | |
| | | public String toImportForm() { |
| | | return "admin/hive/vip/vipImport-form"; |
| | | } |
| | | |
| | | @RequestMapping(value = "/validFlagChange") |
| | | @ResponseBody |
| | | public AjaxResult validFlagChange(Long id) { |
| | | SysVipInfo sysVipInfo = vipInfoService.findById(id); |
| | | |
| | | if (sysVipInfo == null) { |
| | | return AjaxResult.buildFailInstance("用户不存在"); |
| | | } |
| | | |
| | | if (SysVipInfo.VALID_FLAG_Y == sysVipInfo.getValidFlag()) { |
| | | sysVipInfo.setValidFlag(SysVipInfo.VALID_FLAG_N); |
| | | } else { |
| | | sysVipInfo.setValidFlag(SysVipInfo.VALID_FLAG_Y); |
| | | } |
| | | |
| | | vipInfoService.modify(sysVipInfo); |
| | | return AjaxResult.buildSuccessInstance("设置成功"); |
| | | } |
| | | } |