package com.ltkj.web.controller.app;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.ltkj.common.core.controller.BaseController;
|
import com.ltkj.common.core.domain.AjaxResult;
|
import com.ltkj.framework.config.UserHoder;
|
import com.ltkj.hosp.domain.TjPackage;
|
import com.ltkj.hosp.domain.TjPackageProject;
|
import com.ltkj.hosp.domain.TjProject;
|
import com.ltkj.hosp.domain.Wxuser;
|
import com.ltkj.hosp.service.ITjPackageProjectService;
|
import com.ltkj.hosp.service.ITjPackageService;
|
import com.ltkj.hosp.service.ITjProjectService;
|
import com.ltkj.mall.domain.MallCategory;
|
import com.ltkj.mall.domain.MallFootprint;
|
import com.ltkj.mall.domain.MallKeyword;
|
import com.ltkj.mall.domain.MallSearchHistory;
|
import com.ltkj.mall.service.IMallCategoryService;
|
import com.ltkj.mall.service.IMallFootprintService;
|
import com.ltkj.mall.service.IMallKeywordService;
|
import com.ltkj.mall.service.IMallSearchHistoryService;
|
import com.ltkj.system.service.ISysConfigService;
|
import freemarker.template.utility.StringUtil;
|
import io.swagger.annotations.Api;
|
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiParam;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.web.bind.annotation.*;
|
|
import javax.annotation.Resource;
|
import java.math.BigDecimal;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
/**
|
* @Author: 西安路泰科技有限公司/lige
|
* @Date: 2023/1/10 16:37
|
*/
|
|
@RestController
|
@RequestMapping("/cus/package")
|
@Api(tags = "小程序-体检套餐")
|
public class PackageController extends BaseController {
|
|
@Resource
|
private ITjPackageService tjPackageService;
|
|
@Autowired
|
private IMallCategoryService mallCategoryService;
|
|
@Resource
|
private ITjPackageProjectService ppservice;
|
|
@Autowired
|
private IMallKeywordService mallKeywordService;
|
|
@Resource
|
private ITjProjectService tjProjectService;
|
|
@Autowired
|
private IMallFootprintService footprintService;
|
|
@Resource
|
private ISysConfigService configService;
|
|
@Autowired
|
private IMallSearchHistoryService mallSearchHistoryService;
|
|
/**
|
* 小程序查询体检套餐列表
|
*/
|
@GetMapping("/getPackageList")
|
@ApiOperation(value = "小程序查询体检套餐列表")
|
public AjaxResult getPackageList(@RequestParam(required = false) @ApiParam(value = "分类Id") String categoryId,
|
@RequestParam(required = false) @ApiParam(value = "套餐名") String pacName) {
|
List<TjPackage> packageList = null;
|
LambdaQueryWrapper<TjPackage> wq = new LambdaQueryWrapper<>();
|
wq.eq(TjPackage::getPacStatus, 0);
|
wq.orderByAsc(TjPackage::getSort);
|
if (null != pacName) {
|
wq.like(TjPackage::getPacName, pacName);
|
//添加搜索历史
|
Wxuser wxuser = UserHoder.getWxuser();
|
if (null != wxuser) {
|
MallSearchHistory mallSearchHistory=new MallSearchHistory();
|
mallSearchHistory.setUserId(wxuser.getId());
|
mallSearchHistory.setFromType("小程序");
|
mallSearchHistory.setKeyword(pacName);
|
mallSearchHistoryService.insertMallSearchHistory(mallSearchHistory);
|
}
|
}
|
if (categoryId == null) {
|
//查询所有套餐
|
packageList = tjPackageService.list(wq);
|
} else {
|
LambdaQueryWrapper<TjPackage> wqqq=new LambdaQueryWrapper<>();
|
wqqq.eq(TjPackage::getCategoryId,categoryId);
|
packageList =tjPackageService.list(wqqq);
|
}
|
if (null != packageList && packageList.size() > 0) {
|
for (TjPackage tjPackage : packageList) {
|
|
StringBuffer a = new StringBuffer();
|
List<String> b = new ArrayList<>();
|
final String keywords = tjPackage.getKeywords();
|
if (keywords != null) {
|
final String[] strings = keywords.split(",");
|
for (String string : strings) {
|
final MallKeyword byId = mallKeywordService.getById(string);
|
if (byId != null) {
|
a.append(byId.getKeyword());
|
a.append(";");
|
b.add((byId.getId()).toString());
|
}
|
}
|
tjPackage.setKeyNames(String.valueOf(a));
|
tjPackage.setKeyIds(b);
|
}
|
}
|
}
|
return AjaxResult.success(packageList);
|
}
|
|
|
/**
|
* 小程序点击套餐获取项目详情
|
*/
|
@GetMapping("/projectListByPacId/{pacId}")
|
@ApiOperation(value = "小程序点击套餐获取项目详情")
|
public AjaxResult projectListByPacId(@ApiParam(value = "体检套餐id") @PathVariable("pacId") String pacId) {
|
if (pacId != null) {
|
TjPackage tjPackage = tjPackageService.getById(Long.valueOf(pacId));
|
List<TjPackageProject> packageProjectList = ppservice.getTjPackageProjectListByPacId(pacId);
|
BigDecimal money = new BigDecimal(0);
|
if (null != packageProjectList && packageProjectList.size() > 0) {
|
List<TjProject> projectList = tjProjectService.getTjParentProjectListByPacId(pacId);
|
tjPackage.setAllProName(tjProjectService.getAllNamesByPacId(pacId));
|
for (TjProject tjProject : projectList) {
|
tjProject.setTjProjectList(tjProjectService.getTjProjectListBySoneId(String.valueOf(tjProject.getProId())));
|
money = money.add(tjProjectService.getMoneys(String.valueOf(tjProject.getProId())));
|
tjProject.setAllSonProName(tjProjectService.getAllSonNames(String.valueOf(tjProject.getProId())));
|
}
|
tjPackage.setYuanjia(money.setScale(Integer.parseInt(configService.selectConfigByKey("sys.price.save")), Integer.parseInt(configService.selectConfigByKey("sys.price")))); //保留两位小数
|
tjPackage.setProNumber(projectList.size());
|
tjPackage.setTjProjectList(projectList);
|
|
// 记录用户的足迹
|
Wxuser wxuser = UserHoder.getWxuser();
|
if (null != wxuser) {
|
LambdaQueryWrapper<MallFootprint> wq=new LambdaQueryWrapper<>();
|
wq.eq(MallFootprint::getUserId,wxuser.getId());
|
wq.eq(MallFootprint::getGoodsId,pacId);
|
final List<MallFootprint> list = footprintService.list(wq);
|
if (list!=null&&list.size()==0){
|
MallFootprint footprint = new MallFootprint();
|
footprint.setUserId(wxuser.getId());
|
footprint.setGoodsId(pacId);
|
footprintService.insertMallFootprint(footprint);
|
}
|
}
|
return AjaxResult.success(tjPackage);
|
}
|
return success("暂时没有数据");
|
}
|
return error("套餐ID不能为空");
|
}
|
}
|