|
|
@@ -1,17 +1,30 @@
|
|
|
-package com.sqx.modules.activityManage.controller;
|
|
|
+package com.sqx.modules.printInfo.controller;
|
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
+import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
import com.sqx.common.utils.Result;
|
|
|
-import com.sqx.modules.activityManage.entity.ActivityManage;
|
|
|
-import com.sqx.modules.activityManage.service.ActivityManageService;
|
|
|
+import com.sqx.modules.address.entity.Address;
|
|
|
import com.sqx.modules.goods.entity.GoodsShop;
|
|
|
+import com.sqx.modules.goods.service.GoodsShopService;
|
|
|
+import com.sqx.modules.order.entity.TbOrder;
|
|
|
+import com.sqx.modules.order.service.AppOrderService;
|
|
|
+import com.sqx.modules.order.service.impl.AppAppOrderServiceImpl;
|
|
|
+import com.sqx.modules.printInfo.entity.*;
|
|
|
+import com.sqx.modules.printInfo.service.PrintInfoService;
|
|
|
+import com.sqx.modules.printInfo.service.PrintInfoShopService;
|
|
|
+import com.sqx.modules.utils.fieYun.FeiYunUtils;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiModelProperty;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.GetMapping;
|
|
|
-import org.springframework.web.bind.annotation.PostMapping;
|
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
|
@@ -22,54 +35,349 @@ import org.springframework.web.bind.annotation.RestController;
|
|
|
* @since 2022-11-04
|
|
|
*/
|
|
|
@RestController
|
|
|
-@RequestMapping("/admin/activityManage/")
|
|
|
-public class AdminActivityManageController {
|
|
|
+@Api(value = "管理端-打印模板信息", tags = {"管理端-打印模板信息"})
|
|
|
+@RequestMapping("/admin/printInfo/")
|
|
|
+public class PrintInfoController {
|
|
|
@Autowired
|
|
|
- private ActivityManageService activityManageService;
|
|
|
+ private PrintInfoService printInfoService;
|
|
|
|
|
|
- @PostMapping("addActivity")
|
|
|
- @ApiOperation("添加活动")
|
|
|
- public Result addActivity(ActivityManage activityManage) {
|
|
|
- return activityManageService.addActivity(activityManage);
|
|
|
+ @Autowired
|
|
|
+ private PrintInfoShopService printInfoShopService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private AppAppOrderServiceImpl appAppOrderService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private GoodsShopService goodsShopService;
|
|
|
+
|
|
|
+ @GetMapping("testPrintModel")
|
|
|
+ @ApiOperation("获取打印信息列表")
|
|
|
+ public Result testPrintModel(Long orderId) {
|
|
|
+ // 查询订单信息
|
|
|
+ TbOrder tbOrder = appAppOrderService.selectOrderByIds(orderId);
|
|
|
+ Long shopId = tbOrder.getShopId();
|
|
|
+
|
|
|
+ // 查询店铺信息
|
|
|
+ GoodsShop goodsShop = goodsShopService.selectGoodDatas(shopId);
|
|
|
+
|
|
|
+ // 查询当天店铺所有已支付的订单号,按支付时间排序
|
|
|
+ tbOrder.setCountOrder(3);
|
|
|
+
|
|
|
+ if (StringUtils.isNotEmpty(goodsShop.getSnCode())) {
|
|
|
+ FeiYunUtils.print(goodsShop.getSnCode(), null, tbOrder);
|
|
|
+ } else {
|
|
|
+ return Result.error("当前商家未绑定打印机!");
|
|
|
+ }
|
|
|
+ return Result.success();
|
|
|
}
|
|
|
|
|
|
- @PostMapping("updateActivity")
|
|
|
- @ApiOperation("修改活动")
|
|
|
- public Result updateActivity(ActivityManage activityManage) {
|
|
|
- return activityManageService.updateActivity(activityManage);
|
|
|
+
|
|
|
+ @GetMapping("getPrintInfoList")
|
|
|
+ @ApiOperation("获取打印信息列表")
|
|
|
+ public Result getPrintInfoList(Integer page, Integer limit) {
|
|
|
+ return printInfoService.selectPrintInfoList(page, limit);
|
|
|
}
|
|
|
|
|
|
- @PostMapping("deleteActivity")
|
|
|
- @ApiOperation("删除活动")
|
|
|
- public Result deleteActivity(Long activityId) {
|
|
|
- return activityManageService.deleteActivity(activityId);
|
|
|
+ @GetMapping("getPrintInfo")
|
|
|
+ @ApiOperation("获取打印信息")
|
|
|
+ public Result getPrintInfoInfo(Integer id) {
|
|
|
+ return printInfoService.selectPrintInfoById(id);
|
|
|
}
|
|
|
|
|
|
- @GetMapping("getActivityList")
|
|
|
- @ApiOperation("获取活动列表")
|
|
|
- public Result getActivityList(Integer page, Integer limit, ActivityManage activityManage) {
|
|
|
- return Result.success().put("data", activityManageService.getActivityList(page, limit, activityManage));
|
|
|
+ @PostMapping("insertPrintInfo")
|
|
|
+ @ApiOperation("新增打印信息")
|
|
|
+ public Result insertPrintInfo(@RequestBody PrintInfo printInfo) {
|
|
|
+ return printInfoService.insertPrintInfo(printInfo);
|
|
|
}
|
|
|
- @GetMapping("getActivityInfo")
|
|
|
- @ApiOperation("获取活动信息")
|
|
|
- public Result getActivityInfo(Long activityId){
|
|
|
- return Result.success().put("data", activityManageService.getActivityInfo(activityId));
|
|
|
|
|
|
+ @GetMapping("updatePrintInfo")
|
|
|
+ @ApiOperation("更新打印信息")
|
|
|
+ private Result updatePrintInfo(@RequestBody PrintInfo printInfo) {
|
|
|
+ return printInfoService.updatePrintInfo(printInfo);
|
|
|
}
|
|
|
- @GetMapping("getShoActivityShopList")
|
|
|
- @ApiOperation("根据活动查找商家列表")
|
|
|
- public Result getShoActivityShopList(Integer page, Integer limit, GoodsShop goodsShop) {
|
|
|
- return Result.success().put("data", activityManageService.getAdminShoActivityShopList(page, limit, goodsShop));
|
|
|
+
|
|
|
+ @GetMapping("getPrintDropList")
|
|
|
+ @ApiOperation("获取打印信息类型下拉列表")
|
|
|
+ public Result getPrintDropList() {
|
|
|
+
|
|
|
+ int length = ePrintStatu.values().length;
|
|
|
+ List<PrintDropVo> result = new ArrayList<>();
|
|
|
+ for (int i = 1; i < length + 1; i++) {
|
|
|
+ PrintDropVo data = new PrintDropVo();
|
|
|
+ data.setId(i);
|
|
|
+ data.setName(ePrintStatu.stringOf(i));
|
|
|
+ result.add(data);
|
|
|
+ }
|
|
|
+ return Result.success().put("data", result);
|
|
|
}
|
|
|
- @GetMapping("cancelActivityShop")
|
|
|
- @ApiOperation("删除活动中的商家")
|
|
|
- public Result cancelActivityShop(Long activityId,Long shopId){
|
|
|
- return activityManageService.cancelActivityShop(activityId,shopId);
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据店铺ID获取对应店铺的打印模板信息
|
|
|
+ *
|
|
|
+ * @param shopId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("getPrintModelData")
|
|
|
+ @ApiOperation("获取打印模板信息")
|
|
|
+ public Result getPrintModelData(Integer shopId) throws JsonProcessingException {
|
|
|
+
|
|
|
+ if (shopId == null) {
|
|
|
+ return Result.error("商铺ID不能为空");
|
|
|
+ }
|
|
|
+ PrintResultModelVo resultData = new PrintResultModelVo();
|
|
|
+ resultData.setShopId(shopId);
|
|
|
+ List<PrintModelResult> result = new ArrayList<>();
|
|
|
+ List<PrintInfo> infos = printInfoService.printInfos();
|
|
|
+ List<Integer> typeIds = infos.stream().map(PrintInfo::getTypeId).distinct().collect(Collectors.toList());
|
|
|
+ PrintInfoShop pis = printInfoShopService.selectPrintInfoShopById(shopId);
|
|
|
+ if (pis == null) {
|
|
|
+ for (Integer typeId : typeIds) {
|
|
|
+ List<PrintInfo> nowInfos = infos.stream().filter(e -> e.getTypeId().intValue() == typeId.intValue()).collect(Collectors.toList());
|
|
|
+ PrintModelResult data = new PrintModelResult();
|
|
|
+ List<PrintModelDetailResult> details = new ArrayList<>();
|
|
|
+ List<PrintModelTypeResult> types = new ArrayList<>();
|
|
|
+ for (PrintInfo nowInfo : nowInfos) {
|
|
|
+ PrintModelDetailResult detailData = new PrintModelDetailResult();
|
|
|
+ detailData.setId(nowInfo.getId());
|
|
|
+ detailData.setPrintField(nowInfo.getPrintField());
|
|
|
+ detailData.setPrintName(nowInfo.getPrintName());
|
|
|
+ detailData.setIsCheck(0);
|
|
|
+ details.add(detailData);
|
|
|
+
|
|
|
+ PrintModelTypeResult typeData = new PrintModelTypeResult();
|
|
|
+ typeData.setId(nowInfo.getId());
|
|
|
+ typeData.setIsBlod(0);
|
|
|
+ typeData.setWordSize(0);
|
|
|
+ typeData.setPrintField(nowInfo.getPrintField());
|
|
|
+ typeData.setPrintName(nowInfo.getPrintName());
|
|
|
+ types.add(typeData);
|
|
|
+
|
|
|
+ }
|
|
|
+ if (nowInfos != null && nowInfos.size() > 0) {
|
|
|
+ data.setId(typeId);
|
|
|
+ data.setName(nowInfos.get(0).getTypeName());
|
|
|
+ }
|
|
|
+ data.setDetails(details);
|
|
|
+ data.setTypes(types);
|
|
|
+ result.add(data);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //要修改获取逻辑
|
|
|
+ resultData.setId(pis.getId());
|
|
|
+ if (pis.getBaseInfo().isEmpty()) {
|
|
|
+ PrintModelResult data = new PrintModelResult();
|
|
|
+ List<PrintInfo> nowInfos = infos.stream().filter(e -> e.getTypeId().intValue() == ePrintStatu.Base.getValue()).collect(Collectors.toList());
|
|
|
+ List<PrintModelDetailResult> details = new ArrayList<>();
|
|
|
+ List<PrintModelTypeResult> types = new ArrayList<>();
|
|
|
+ for (PrintInfo nowInfo : nowInfos) {
|
|
|
+ PrintModelDetailResult detailData = new PrintModelDetailResult();
|
|
|
+ detailData.setId(nowInfo.getId());
|
|
|
+ detailData.setPrintField(nowInfo.getPrintField());
|
|
|
+ detailData.setPrintName(nowInfo.getPrintName());
|
|
|
+ detailData.setIsCheck(0);
|
|
|
+ details.add(detailData);
|
|
|
+
|
|
|
+ PrintModelTypeResult typeData = new PrintModelTypeResult();
|
|
|
+ typeData.setId(nowInfo.getId());
|
|
|
+ typeData.setIsBlod(0);
|
|
|
+ typeData.setWordSize(0);
|
|
|
+ typeData.setPrintField(nowInfo.getPrintField());
|
|
|
+ typeData.setPrintName(nowInfo.getPrintName());
|
|
|
+ types.add(typeData);
|
|
|
+ }
|
|
|
+ data.setId(ePrintStatu.Base.getValue());
|
|
|
+ data.setName(nowInfos.get(0).getTypeName());
|
|
|
+ data.setDetails(details);
|
|
|
+ data.setTypes(types);
|
|
|
+ result.add(data);
|
|
|
+ } else {
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ PrintModelResult data = objectMapper.readValue(pis.getBaseInfo(), PrintModelResult.class);
|
|
|
+ result.add(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pis.getGoodInfo().isEmpty()) {
|
|
|
+ PrintModelResult data = new PrintModelResult();
|
|
|
+ List<PrintInfo> nowInfos = infos.stream().filter(e -> e.getTypeId().intValue() == ePrintStatu.Good.getValue()).collect(Collectors.toList());
|
|
|
+ List<PrintModelDetailResult> details = new ArrayList<>();
|
|
|
+ List<PrintModelTypeResult> types = new ArrayList<>();
|
|
|
+ for (PrintInfo nowInfo : nowInfos) {
|
|
|
+ PrintModelDetailResult detailData = new PrintModelDetailResult();
|
|
|
+ detailData.setId(nowInfo.getId());
|
|
|
+ detailData.setPrintField(nowInfo.getPrintField());
|
|
|
+ detailData.setPrintName(nowInfo.getPrintName());
|
|
|
+ detailData.setIsCheck(0);
|
|
|
+ details.add(detailData);
|
|
|
+
|
|
|
+ PrintModelTypeResult typeData = new PrintModelTypeResult();
|
|
|
+ typeData.setId(nowInfo.getId());
|
|
|
+ typeData.setIsBlod(0);
|
|
|
+ typeData.setWordSize(0);
|
|
|
+ typeData.setPrintField(nowInfo.getPrintField());
|
|
|
+ typeData.setPrintName(nowInfo.getPrintName());
|
|
|
+ types.add(typeData);
|
|
|
+ }
|
|
|
+ data.setId(ePrintStatu.Good.getValue());
|
|
|
+ data.setName(nowInfos.get(0).getTypeName());
|
|
|
+ data.setDetails(details);
|
|
|
+ data.setTypes(types);
|
|
|
+ result.add(data);
|
|
|
+ } else {
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ PrintModelResult data = objectMapper.readValue(pis.getGoodInfo(), PrintModelResult.class);
|
|
|
+ result.add(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pis.getPayInfo().isEmpty()) {
|
|
|
+ PrintModelResult data = new PrintModelResult();
|
|
|
+ List<PrintInfo> nowInfos = infos.stream().filter(e -> e.getTypeId().intValue() == ePrintStatu.Pay.getValue()).collect(Collectors.toList());
|
|
|
+ List<PrintModelDetailResult> details = new ArrayList<>();
|
|
|
+ List<PrintModelTypeResult> types = new ArrayList<>();
|
|
|
+ for (PrintInfo nowInfo : nowInfos) {
|
|
|
+ PrintModelDetailResult detailData = new PrintModelDetailResult();
|
|
|
+ detailData.setId(nowInfo.getId());
|
|
|
+ detailData.setPrintField(nowInfo.getPrintField());
|
|
|
+ detailData.setPrintName(nowInfo.getPrintName());
|
|
|
+ detailData.setIsCheck(0);
|
|
|
+ details.add(detailData);
|
|
|
+
|
|
|
+ PrintModelTypeResult typeData = new PrintModelTypeResult();
|
|
|
+ typeData.setId(nowInfo.getId());
|
|
|
+ typeData.setIsBlod(0);
|
|
|
+ typeData.setWordSize(0);
|
|
|
+ typeData.setPrintField(nowInfo.getPrintField());
|
|
|
+ typeData.setPrintName(nowInfo.getPrintName());
|
|
|
+ types.add(typeData);
|
|
|
+ }
|
|
|
+ data.setId(ePrintStatu.Pay.getValue());
|
|
|
+ data.setName(nowInfos.get(0).getTypeName());
|
|
|
+ data.setDetails(details);
|
|
|
+ data.setTypes(types);
|
|
|
+ result.add(data);
|
|
|
+ } else {
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ PrintModelResult data = objectMapper.readValue(pis.getPayInfo(), PrintModelResult.class);
|
|
|
+ result.add(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (pis.getUserInfo().isEmpty()) {
|
|
|
+ PrintModelResult data = new PrintModelResult();
|
|
|
+ List<PrintInfo> nowInfos = infos.stream().filter(e -> e.getTypeId().intValue() == ePrintStatu.User.getValue()).collect(Collectors.toList());
|
|
|
+ List<PrintModelDetailResult> details = new ArrayList<>();
|
|
|
+ List<PrintModelTypeResult> types = new ArrayList<>();
|
|
|
+ for (PrintInfo nowInfo : nowInfos) {
|
|
|
+ PrintModelDetailResult detailData = new PrintModelDetailResult();
|
|
|
+ detailData.setId(nowInfo.getId());
|
|
|
+ detailData.setPrintField(nowInfo.getPrintField());
|
|
|
+ detailData.setPrintName(nowInfo.getPrintName());
|
|
|
+ detailData.setIsCheck(0);
|
|
|
+ details.add(detailData);
|
|
|
+
|
|
|
+ PrintModelTypeResult typeData = new PrintModelTypeResult();
|
|
|
+ typeData.setId(nowInfo.getId());
|
|
|
+ typeData.setIsBlod(0);
|
|
|
+ typeData.setWordSize(0);
|
|
|
+ typeData.setPrintField(nowInfo.getPrintField());
|
|
|
+ typeData.setPrintName(nowInfo.getPrintName());
|
|
|
+ types.add(typeData);
|
|
|
+ }
|
|
|
+ data.setId(ePrintStatu.User.getValue());
|
|
|
+ data.setName(nowInfos.get(0).getTypeName());
|
|
|
+ data.setDetails(details);
|
|
|
+ data.setTypes(types);
|
|
|
+ result.add(data);
|
|
|
+ } else {
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ PrintModelResult data = objectMapper.readValue(pis.getUserInfo(), PrintModelResult.class);
|
|
|
+ result.add(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ resultData.setModelDatas(result);
|
|
|
+ return Result.success().put("data", resultData);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据店铺ID获取对应店铺的打印模板信息
|
|
|
+ *
|
|
|
+ * @param printResult 模板信息数据
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("insertPrintModelData")
|
|
|
+ @ApiOperation("新增打印模板信息")
|
|
|
+ public Result insertPrintModelData(@RequestBody PrintResultModelVo printResult) {
|
|
|
+ PrintInfoShop pis = new PrintInfoShop();
|
|
|
+ pis.setShopId(printResult.getShopId());
|
|
|
+ if (printResult != null && printResult.getModelDatas() != null && printResult.getModelDatas().size() > 0) {
|
|
|
+ for (PrintModelResult pmr : printResult.getModelDatas()) {
|
|
|
+ switch (pmr.getId().intValue()) {
|
|
|
+ case 1://基本信息:1
|
|
|
+ pis.setBaseInfo(JSON.toJSONString(pmr));
|
|
|
+ break;
|
|
|
+ case 2:// 商品信息:2
|
|
|
+ pis.setGoodInfo(JSON.toJSONString(pmr));
|
|
|
+ break;
|
|
|
+ case 3:// 支付信息:3
|
|
|
+ pis.setPayInfo(JSON.toJSONString(pmr));
|
|
|
+ break;
|
|
|
+ case 4:// 用户信息:4
|
|
|
+ pis.setUserInfo(JSON.toJSONString(pmr));
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return printInfoShopService.insertPrintInfoShop(pis);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据店铺ID获取对应店铺的打印模板信息
|
|
|
+ *
|
|
|
+ * @param printResult 模板信息数据
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PostMapping("updatePrintModelData")
|
|
|
+ @ApiOperation("更新打印模板信息")
|
|
|
+ public Result updatePrintModelData(@RequestBody PrintResultModelVo printResult) {
|
|
|
+ PrintInfoShop pis = new PrintInfoShop();
|
|
|
+ pis.setId(printResult.getId());
|
|
|
+ pis.setShopId(printResult.getShopId());
|
|
|
+ if (printResult != null && printResult.getModelDatas() != null && printResult.getModelDatas().size() > 0) {
|
|
|
+ for (PrintModelResult pmr : printResult.getModelDatas()) {
|
|
|
+ switch (pmr.getId().intValue()) {
|
|
|
+ case 1://基本信息:1
|
|
|
+ pis.setBaseInfo(JSON.toJSONString(pmr));
|
|
|
+ break;
|
|
|
+ case 2:// 商品信息:2
|
|
|
+ pis.setGoodInfo(JSON.toJSONString(pmr));
|
|
|
+ break;
|
|
|
+ case 3:// 支付信息:3
|
|
|
+ pis.setPayInfo(JSON.toJSONString(pmr));
|
|
|
+ break;
|
|
|
+ case 4:// 用户信息:4
|
|
|
+ pis.setUserInfo(JSON.toJSONString(pmr));
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return printInfoShopService.updatePrintInfoShop(pis);
|
|
|
}
|
|
|
- @GetMapping("shopJoinActivity")
|
|
|
- @ApiOperation("将商家加入活动")
|
|
|
- private Result shopJoinActivity(Long shopId, Long activityId) {
|
|
|
- return activityManageService.shopJoinActivity(shopId, activityId,1);
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 测试打印功能
|
|
|
+ */
|
|
|
+ @GetMapping("testPrintInfo")
|
|
|
+ @ApiOperation("测试打印功能")
|
|
|
+ public Result testPrintInfo(String sn) {
|
|
|
+ FeiYunUtils.testPrint(sn);
|
|
|
+ return Result.success();
|
|
|
}
|
|
|
}
|
|
|
|