|
|
@@ -1,6 +1,10 @@
|
|
|
package net.mingsoft.tf.wx;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.collection.CollUtil;
|
|
|
+import cn.hutool.core.map.CaseInsensitiveMap;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import io.swagger.v3.oas.annotations.Operation;
|
|
|
import io.swagger.v3.oas.annotations.Parameter;
|
|
|
import io.swagger.v3.oas.annotations.Parameters;
|
|
|
@@ -9,27 +13,35 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
|
import jakarta.servlet.http.HttpServletResponse;
|
|
|
import net.mingsoft.base.entity.ResultData;
|
|
|
+import net.mingsoft.basic.bean.EUListBean;
|
|
|
import net.mingsoft.basic.bean.UploadConfigBean;
|
|
|
+import net.mingsoft.basic.util.BasicUtil;
|
|
|
+import net.mingsoft.mdiy.biz.IModelBiz;
|
|
|
+import net.mingsoft.mdiy.biz.IModelDataBiz;
|
|
|
+import net.mingsoft.mdiy.entity.ModelEntity;
|
|
|
import net.mingsoft.people.action.BaseAction;
|
|
|
import net.mingsoft.people.action.people.FileAction;
|
|
|
+import net.mingsoft.people.biz.IPeopleBiz;
|
|
|
+import net.mingsoft.people.entity.PeopleEntity;
|
|
|
import net.mingsoft.people.util.PeopleUtil;
|
|
|
import net.mingsoft.tf.biz.*;
|
|
|
import net.mingsoft.tf.biz.impl.ExhibitorBizImpl;
|
|
|
-import net.mingsoft.tf.entity.ExhibitionEntity;
|
|
|
-import net.mingsoft.tf.entity.ExhibitorEntity;
|
|
|
+import net.mingsoft.tf.entity.*;
|
|
|
+import net.mingsoft.tf.www.dto.EnterpriseProductsListResponse;
|
|
|
import net.mingsoft.tf.wx.dto.ExhibitorInfoResponse;
|
|
|
import net.mingsoft.tf.wx.dto.ExhibitorQueryResponse;
|
|
|
+import net.mingsoft.tf.wx.dto.WxRegisterRequest;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.ui.ExtendedModelMap;
|
|
|
+import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
-import java.util.Collection;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Optional;
|
|
|
+import java.util.*;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@Tag(name = "微信-展商")
|
|
|
@@ -37,6 +49,8 @@ import java.util.stream.Collectors;
|
|
|
@Controller
|
|
|
public class ExhibitorAction extends BaseAction {
|
|
|
@Autowired
|
|
|
+ private IPeopleBiz peopleBiz;
|
|
|
+ @Autowired
|
|
|
private FileAction fileAction;
|
|
|
@Autowired
|
|
|
private net.mingsoft.tf.action.ExhibitorAction exhibitorAction;
|
|
|
@@ -50,6 +64,72 @@ public class ExhibitorAction extends BaseAction {
|
|
|
private IPeopleExhibitorBiz peopleExhibitorBiz;
|
|
|
@Autowired
|
|
|
private IBoothBiz boothBiz;
|
|
|
+ @Autowired
|
|
|
+ private IModelDataBiz modelDataBiz;
|
|
|
+ @Autowired
|
|
|
+ private IModelBiz modelBiz;
|
|
|
+ @Autowired
|
|
|
+ private ICollectionBiz collectionBiz;
|
|
|
+ @Autowired
|
|
|
+ private IEnterpriseProductsBiz enterpriseProductsBiz;
|
|
|
+ @Autowired
|
|
|
+ private IDesignBiz designBiz;
|
|
|
+ @Autowired
|
|
|
+ private IGateService gateService;
|
|
|
+
|
|
|
+ @Operation(summary = "微信-用户注册")
|
|
|
+ @Parameters({
|
|
|
+// @Parameter(name = "peopleName", description = "openid", required = true, in = ParameterIn.QUERY),
|
|
|
+ @Parameter(name = "puIcon", description = "微信头像", required = true, in = ParameterIn.QUERY),
|
|
|
+ @Parameter(name = "puNickname", description = "微信昵称", required = true, in = ParameterIn.QUERY),
|
|
|
+// @Parameter(name = "puRealName", description = "真实姓名", required = true, in = ParameterIn.QUERY),
|
|
|
+ @Parameter(name = "peoplePhone", description = "手机号", required = true, in = ParameterIn.QUERY),
|
|
|
+// @Parameter(name = "puCard", description = "身份证", required = true, in = ParameterIn.QUERY),
|
|
|
+ @Parameter(name = "puLevel", description = "身份类型-编码", required = true, in = ParameterIn.QUERY),
|
|
|
+ @Parameter(name = "puLevelName", description = "身份类型-名称", required = true, in = ParameterIn.QUERY),
|
|
|
+ @Parameter(name = "companyName", description = "公司名称", required = true, in = ParameterIn.QUERY),
|
|
|
+ @Parameter(name = "position", description = "职位", required = true, in = ParameterIn.QUERY),
|
|
|
+ @Parameter(name = "invitationCode", description = "展商邀请码", required = true, in = ParameterIn.QUERY),
|
|
|
+ @Parameter(name = "channel", description = "了解渠道", required = true, in = ParameterIn.QUERY),
|
|
|
+ @Parameter(name = "purpose", description = "参观目的", required = true, in = ParameterIn.QUERY),
|
|
|
+ })
|
|
|
+ @PostMapping(value = "/edit")
|
|
|
+ @ResponseBody
|
|
|
+ public ResultData update(@RequestBody WxRegisterRequest people, String modelId, HttpServletRequest request, HttpServletResponse response) {
|
|
|
+ PeopleEntity user = peopleBiz.getEntityByUserName(PeopleUtil.getPeopleBean().getPeopleName());
|
|
|
+ if (user == null) {
|
|
|
+ return ResultData.build().error("用户不存在");
|
|
|
+ }
|
|
|
+ people.setPeopleName(null);
|
|
|
+ people.setPuRealName(null);
|
|
|
+ people.setPuCard(null);
|
|
|
+ String linkId = user.getId();
|
|
|
+ people.setId(linkId);
|
|
|
+ people.setPeopleId(linkId);
|
|
|
+ peopleBiz.updatePeople(people);
|
|
|
+ ModelMap modelData = new ExtendedModelMap();
|
|
|
+ modelData.put("companyName", people.getCompanyName());
|
|
|
+ modelData.put("position", people.getPosition());
|
|
|
+ modelData.put("channel", people.getChannel());
|
|
|
+ modelData.put("purpose", people.getPurpose());
|
|
|
+ modelData.put("linkId", linkId);
|
|
|
+ ModelEntity model = modelBiz.getById(modelId);
|
|
|
+ String id = this.modelBiz.queryForList(StrUtil.format("select id from {} where link_id = ?", model.getModelTableName()), people.getId())
|
|
|
+ .stream()
|
|
|
+ .map(map -> map.get("id").toString())
|
|
|
+ .findFirst()
|
|
|
+ .orElse(null);
|
|
|
+ if (id == null) {
|
|
|
+ // 保存扩展表数据
|
|
|
+ modelDataBiz.spliceInsertSql(model, new CaseInsensitiveMap<>(modelData));
|
|
|
+ } else {
|
|
|
+ modelData.put("id", id);
|
|
|
+ // 修改扩展表数据
|
|
|
+ modelDataBiz.spliceUpdateSql(model, new CaseInsensitiveMap<>(modelData));
|
|
|
+ }
|
|
|
+ return ResultData.build().success();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Operation(summary = "微信-关联邀请关系")
|
|
|
@Parameters({
|
|
|
@@ -91,8 +171,10 @@ public class ExhibitorAction extends BaseAction {
|
|
|
@GetMapping(value = "/qrcode")
|
|
|
@ResponseBody
|
|
|
public ResultData qrcode() {
|
|
|
- // TODO 生成入场二维码
|
|
|
- return null;
|
|
|
+ String user = PeopleUtil.getPeopleBean().getPeopleId();
|
|
|
+ gateService.failureCode(user);
|
|
|
+ // TODO 转图片base64
|
|
|
+ return ResultData.build().success(gateService.createCode(user));
|
|
|
}
|
|
|
|
|
|
@Operation(summary = "微信-展商-上传LOGO")
|
|
|
@@ -179,4 +261,98 @@ public class ExhibitorAction extends BaseAction {
|
|
|
.map(ResultData.build()::success)
|
|
|
.orElseGet(ResultData.build()::success);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 收藏
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/collection/save")
|
|
|
+ @ResponseBody
|
|
|
+ public ResultData collectionSave(Integer type, String id, Boolean check) {
|
|
|
+ String user = PeopleUtil.getPeopleBean().getPeopleId();
|
|
|
+ boolean c = collectionBiz.check(user, type, id);
|
|
|
+ if (check != null && !check) {
|
|
|
+ if (!c) {
|
|
|
+ // 不存在,才保存
|
|
|
+ CollectionEntity collectionEntity = new CollectionEntity();
|
|
|
+ collectionEntity.setCollectionUser(user);
|
|
|
+ collectionEntity.setCollectionType(type.toString());
|
|
|
+ collectionEntity.setCollectionValue(id);
|
|
|
+ collectionEntity.setCreateDate(new Date());
|
|
|
+ collectionBiz.save(collectionEntity);
|
|
|
+ }
|
|
|
+ return ResultData.build().success();
|
|
|
+ } else {
|
|
|
+ return ResultData.build().success(c);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 收藏
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/collection/delete")
|
|
|
+ @ResponseBody
|
|
|
+ public ResultData collectionDelete(Integer type, String id, Boolean check) {
|
|
|
+ String user = PeopleUtil.getPeopleBean().getPeopleId();
|
|
|
+ collectionBiz.delete(user, type, id);
|
|
|
+ return ResultData.build().success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查收藏
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/collection/list")
|
|
|
+ @ResponseBody
|
|
|
+ public ResultData collectionList(Integer type) {
|
|
|
+ String user = PeopleUtil.getPeopleBean().getPeopleId();
|
|
|
+ String sql = "select COLLECTION_VALUE from MDIY_FORM_COLLECTION where COLLECTION_USER=" + user + " and COLLECTION_TYPE=" + type;
|
|
|
+ switch (type) {
|
|
|
+ case 1 -> {
|
|
|
+ // 公司
|
|
|
+ BasicUtil.startPage();
|
|
|
+ LambdaQueryWrapper<EnterpriseEntity> wrapper = new LambdaQueryWrapper<>(EnterpriseEntity.class);
|
|
|
+ wrapper.inSql(EnterpriseEntity::getId, sql);
|
|
|
+ wrapper = wrapper.orderByDesc(EnterpriseEntity::getCreateDate);
|
|
|
+ List<EnterpriseEntity> enterpriseList = enterpriseBiz.list(wrapper);
|
|
|
+ return ResultData.build().success(new EUListBean(enterpriseList, (int) BasicUtil.endPage(enterpriseList).getTotal()));
|
|
|
+ }
|
|
|
+ case 2 -> {
|
|
|
+ // 产品
|
|
|
+ BasicUtil.startPage();
|
|
|
+ LambdaQueryWrapper<EnterpriseProductsEntity> wrapper = new LambdaQueryWrapper<>(EnterpriseProductsEntity.class).orderByDesc(EnterpriseProductsEntity::getCreateDate);
|
|
|
+ wrapper.inSql(EnterpriseProductsEntity::getId, sql);
|
|
|
+ List<EnterpriseProductsEntity> enterpriseProductsList = enterpriseProductsBiz.list(wrapper);
|
|
|
+ if (CollUtil.isEmpty(enterpriseProductsList)) {
|
|
|
+ return ResultData.build().success(new EUListBean(enterpriseProductsList, (int) BasicUtil.endPage(enterpriseProductsList).getTotal()));
|
|
|
+ }
|
|
|
+ // 2. 批量查询关联企业信息
|
|
|
+ Map<String, EnterpriseEntity> enterpriseMap = enterpriseBiz.listByIds(
|
|
|
+ enterpriseProductsList.stream().map(EnterpriseProductsEntity::getProductEnterpriseId).collect(Collectors.toList())
|
|
|
+ ).stream().collect(Collectors.toMap(EnterpriseEntity::getId, Function.identity()));
|
|
|
+ // 3. 组合数据到Response对象
|
|
|
+ List<EnterpriseProductsListResponse> responses = enterpriseProductsList.stream().map(p -> {
|
|
|
+ EnterpriseProductsListResponse res = new EnterpriseProductsListResponse();
|
|
|
+ BeanUtil.copyProperties(p, res);
|
|
|
+ EnterpriseEntity e = enterpriseMap.get(p.getProductEnterpriseId());
|
|
|
+ if (e != null) {
|
|
|
+ res.setEnterpriseName(e.getEnterpriseName());
|
|
|
+ res.setEnterpriseLogo(e.getEnterpriseLogo());
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ return ResultData.build().success(new EUListBean(responses, (int) BasicUtil.endPage(enterpriseProductsList).getTotal()));
|
|
|
+ }
|
|
|
+ case 3 -> {
|
|
|
+ // 设计
|
|
|
+ BasicUtil.startPage();
|
|
|
+ LambdaQueryWrapper<DesignEntity> wrapper = new LambdaQueryWrapper<>(DesignEntity.class);
|
|
|
+ wrapper.inSql(DesignEntity::getId, sql);
|
|
|
+ wrapper = wrapper.orderByDesc(DesignEntity::getCreateDate);
|
|
|
+ List<DesignEntity> list = designBiz.list(wrapper);
|
|
|
+ return ResultData.build().success(new EUListBean(list, (int) BasicUtil.endPage(list).getTotal()));
|
|
|
+ }
|
|
|
+ default -> {
|
|
|
+ return ResultData.build().error("未知类型 " + type);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|