|
@@ -0,0 +1,415 @@
|
|
|
+package com.caimei.modules.bulkpurchase.web;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.caimei.modules.bulkpurchase.entity.ProductPrivilege;
|
|
|
+import com.caimei.modules.bulkpurchase.entity.PurchaseProduct;
|
|
|
+import com.caimei.modules.bulkpurchase.service.PurchaseProductService;
|
|
|
+import com.caimei.modules.coupon.service.CmCouponService;
|
|
|
+import com.caimei.modules.product.dao.ProductDao;
|
|
|
+import com.caimei.modules.product.entity.*;
|
|
|
+import com.caimei.modules.product.service.CmPromotionService;
|
|
|
+import com.caimei.modules.svip.entity.CmSvipProduct;
|
|
|
+import com.caimei.utils.MathUtil;
|
|
|
+import com.foxinmy.weixin4j.util.StringUtil;
|
|
|
+import com.thinkgem.jeesite.common.config.Global;
|
|
|
+import com.thinkgem.jeesite.common.persistence.Page;
|
|
|
+import com.thinkgem.jeesite.common.utils.StringUtils;
|
|
|
+import com.thinkgem.jeesite.common.web.BaseController;
|
|
|
+import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
+import org.springframework.ui.Model;
|
|
|
+import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
+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.servlet.mvc.support.RedirectAttributes;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import javax.servlet.http.HttpSession;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+
|
|
|
+@Controller
|
|
|
+@RequestMapping(value = "${adminPath}/bulkpurchase/purchaseProduct")
|
|
|
+public class PurchaseProductController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PurchaseProductService purchaseProductService;
|
|
|
+ @Autowired
|
|
|
+ private ProductDao productDao;
|
|
|
+ @Autowired
|
|
|
+ private CmPromotionService cmPromotionService;
|
|
|
+ @Autowired
|
|
|
+ private CmCouponService cmCouponService;
|
|
|
+
|
|
|
+ @ModelAttribute
|
|
|
+ public PurchaseProduct get(@RequestParam(required = false) String id) {
|
|
|
+ PurchaseProduct entity = null;
|
|
|
+ if (StringUtils.isNotBlank(id)) {
|
|
|
+ entity = purchaseProductService.get(id);
|
|
|
+ }
|
|
|
+ if (entity == null) {
|
|
|
+ entity = new PurchaseProduct();
|
|
|
+ }
|
|
|
+ return entity;
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = {"list", ""})
|
|
|
+ public String list(PurchaseProduct purchaseProduct, HttpServletRequest request, HttpServletResponse response, Model model) {
|
|
|
+ Page<PurchaseProduct> page = purchaseProductService.findPage(new Page<PurchaseProduct>(request, response), purchaseProduct);
|
|
|
+ List<PurchaseProduct> list = page.getList();
|
|
|
+ // 是否取普通用户的价格
|
|
|
+ boolean priceFlag = "normal".equals(purchaseProduct.getPriceType());
|
|
|
+ //通过用户id判断当前会所是否存在价格库价格,存在则使用价格库价格
|
|
|
+ Integer userId = purchaseProduct.getUserId();
|
|
|
+ model.addAttribute("userId", userId);
|
|
|
+ if (priceFlag) {
|
|
|
+ model.addAttribute("priceType", "normal");
|
|
|
+ }
|
|
|
+ for (PurchaseProduct p : list) {
|
|
|
+ if (p != null) {
|
|
|
+ //是否有优惠券可以查看
|
|
|
+ Boolean couponsLogo = cmCouponService.setCouponsLogo(userId, p.getProductId().intValue(), Integer.valueOf(p.getShopId()), p.getCommodityType());
|
|
|
+ if (couponsLogo) {
|
|
|
+ p.setCouponsLogo(2);
|
|
|
+ } else {
|
|
|
+ p.setCouponsLogo(1);
|
|
|
+ }
|
|
|
+ List<CmSku> skuList = productDao.findSkuList(p.getProductId().intValue());
|
|
|
+ skuList.forEach(s -> {
|
|
|
+ if (1 == s.getLadderPriceFlag()) {
|
|
|
+ s.setLadderPriceList(productDao.findLadderPriceBySku(s.getSkuId()));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 超级会员价赋值
|
|
|
+ if (null != skuList.get(0).getPriceType()) {
|
|
|
+ p.setSvipPriceType(skuList.get(0).getPriceType());
|
|
|
+ if (1 == skuList.get(0).getPriceType()) {
|
|
|
+ p.setSvipDiscount(skuList.get(0).getDiscount());
|
|
|
+ } else {
|
|
|
+ p.setSvipDiscountPrice(skuList.get(0).getDiscountPrice());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ p.setSkuId(skuList.get(0).getSkuId());
|
|
|
+ p.setPrice(skuList.get(0).getPrice().toString());
|
|
|
+ if (1 == skuList.get(0).getLadderPriceFlag()) {
|
|
|
+ p.setLadderPriceFlag(1);
|
|
|
+ p.setLadderPriceList(productDao.findLadderPrice(skuList.get(0).getSkuId()));
|
|
|
+ }
|
|
|
+ p.setSkuList(skuList);
|
|
|
+ if (priceFlag) {
|
|
|
+ p.setPrice(p.getNormalPrice());
|
|
|
+ }
|
|
|
+ //1固定成本 2 比例成本
|
|
|
+ String costCheckFlag = p.getCostCheckFlag();
|
|
|
+ if (StringUtils.equals("1", costCheckFlag)) {
|
|
|
+ //固定成本价
|
|
|
+ String costPrice = p.getCostPrice();
|
|
|
+ //只有固定成本,应付供应商的金额=添加商品时的成本价
|
|
|
+ p.setShopFee1(costPrice);
|
|
|
+ }
|
|
|
+ if (StringUtils.equals("2", costCheckFlag)) {
|
|
|
+ //比例成本价
|
|
|
+ String costProportional = p.getCostProportional();
|
|
|
+ String price = p.getPrice();
|
|
|
+ if (StringUtils.isNotEmpty(costProportional)) {
|
|
|
+ BigDecimal shopFee1 = (MathUtil.div(MathUtil.mul(costProportional, price), 100)).setScale(2, BigDecimal.ROUND_UP);
|
|
|
+ p.setShopFee1(String.valueOf(shopFee1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //查询该商品的促销活动
|
|
|
+ CmPromotion cmPromotion = cmPromotionService.findProductPromotion(p.getShopId(), p.getProductId());
|
|
|
+ //设置商品的税率
|
|
|
+ if ("2".equals(p.getIncludedTax()) || StringUtils.isEmpty(p.getIncludedTax()) || ("0".equals(p.getIncludedTax()) && "3".equals(p.getInvoiceType()))) {
|
|
|
+ p.setTaxRate("0");
|
|
|
+ p.setSupplierTaxRate("0");
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(p.getTaxRate())) {
|
|
|
+ p.setTaxRate("0");
|
|
|
+ }
|
|
|
+ if (StringUtils.isEmpty(p.getSupplierTaxRate())) {
|
|
|
+ p.setSupplierTaxRate(p.getTaxRate());
|
|
|
+ p.setOldProductFlag("1");
|
|
|
+ }
|
|
|
+ // 初始化超级会员优惠
|
|
|
+ p.setSvipReduction(0d);
|
|
|
+ if (1 == p.getSvipPriceFlag()) {
|
|
|
+ if (1 == p.getSvipPriceType()) {
|
|
|
+ p.setSvipDiscountPrice(MathUtil.div(MathUtil.mul(new Double(p.getPrice()), p.getSvipDiscount()), 100, 2).doubleValue());
|
|
|
+ }
|
|
|
+ // 商品的超级会员优惠=原价-超级会员优惠价
|
|
|
+ p.setSvipReduction(MathUtil.sub(p.getPrice(), p.getSvipDiscountPrice()).doubleValue());
|
|
|
+ if ("0".equals(p.getIncludedTax()) && ("1".equals(p.getInvoiceType()) || "2".equals(p.getInvoiceType()))) {
|
|
|
+ // 计算优惠的税费
|
|
|
+ BigDecimal taxReduction = MathUtil.div(MathUtil.mul(p.getSvipReduction(), p.getTaxRate()), 100);
|
|
|
+ p.setSvipReduction(MathUtil.add(p.getSvipReduction(), taxReduction).doubleValue());
|
|
|
+ p.setSvipTaxReduction(taxReduction.doubleValue());
|
|
|
+ }
|
|
|
+ } else if (null != cmPromotion) {
|
|
|
+ if ("1".equals(cmPromotion.getMode())) {
|
|
|
+ // 优惠价取sku优惠价
|
|
|
+ cmPromotion.setTouchPrice(skuList.get(0).getTouchPrice());
|
|
|
+ }
|
|
|
+ p.setCmPromotion(cmPromotion);
|
|
|
+ p.setLadderPriceFlag(0);
|
|
|
+ }
|
|
|
+// else {
|
|
|
+// if (p.getLadderPriceFlag().equals(1)) {
|
|
|
+// // 查询阶梯价格
|
|
|
+// List<ProductLadderPrice> ladderPriceList = purchaseProductService.findLadderPriceList(p.getProductId());
|
|
|
+// if (null != ladderPriceList && ladderPriceList.size() > 0) {
|
|
|
+// p.setPrice(ladderPriceList.get(0).getBuyPrice().toString());
|
|
|
+// p.setNum(ladderPriceList.get(0).getBuyNum().toString());
|
|
|
+// IntStream.range(0, ladderPriceList.size()).forEach(i -> {
|
|
|
+// if (i == ladderPriceList.size() - 1) {
|
|
|
+// ladderPriceList.get(i).setBuyNumRangeShow("≥" + ladderPriceList.get(i).getBuyNum());
|
|
|
+// } else {
|
|
|
+// String buyNumRangeShow = ladderPriceList.get(i).getBuyNum() + "~" + (ladderPriceList.get(i + 1).getBuyNum() - 1);
|
|
|
+// ladderPriceList.get(i).setBuyNumRangeShow(buyNumRangeShow);
|
|
|
+// }
|
|
|
+// });
|
|
|
+// p.setLadderPriceList(ladderPriceList);
|
|
|
+// } else {
|
|
|
+// p.setLadderPriceFlag(0);
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// // 复购价
|
|
|
+// if (null != userId) {
|
|
|
+// String priceProductList = repeatPurchasePriceService.findPriceProductList(userId);
|
|
|
+// boolean contains = false;
|
|
|
+// if (StringUtils.isNotEmpty(priceProductList)) {
|
|
|
+// contains = priceProductList.contains(String.valueOf(productId));
|
|
|
+// }
|
|
|
+// if (contains) {//该商品存在价格库商品---修改价格为价格库价格
|
|
|
+// p.setBuyAgainPriceFlag("1");//商品是否使用复购价格购买标识 0否 1是
|
|
|
+// RepeatPurchasePrice lastBuyPrice = repeatPurchasePriceService.getLastBuyPrice(null, userId, Integer.parseInt(String.valueOf(productId)));
|
|
|
+// if (null != lastBuyPrice && MathUtil.compare(p.getPrice(), lastBuyPrice.getCurrentPrice()) > 0) {
|
|
|
+// discountPrice = lastBuyPrice.getCurrentPrice();
|
|
|
+// p.setDiscountPrice(discountPrice);
|
|
|
+// // 计算折扣(折扣=折后单价/单价)[取值1-100]---四舍五入保留6位百分比小数,例如12.341234%
|
|
|
+// BigDecimal discount = MathUtil.round((MathUtil.mul((MathUtil.div(discountPrice, p.getPrice(), 8)), 100)), 6);
|
|
|
+// p.setDiscount(String.valueOf(discount));
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ model.addAttribute("page", page);
|
|
|
+ if (StringUtils.equals(purchaseProduct.getFlag(), "1")) {
|
|
|
+ //直接生成订单中的添加商品
|
|
|
+ return "modules/bulkpurchase/orderPurchaseProductList";
|
|
|
+ }
|
|
|
+ // 合同中的添加商品
|
|
|
+ return "modules/bulkpurchase/purchaseProductList";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 二手商品添加列表
|
|
|
+ *
|
|
|
+ * @param purchaseProduct
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ * @param model
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = {"secondProductList"})
|
|
|
+ public String secondProductList(PurchaseProduct purchaseProduct, HttpServletRequest request, Page<PurchaseProduct> page, HttpServletResponse response, Model model) {
|
|
|
+ int pageNo = page.getPageNo();
|
|
|
+ if (0 == pageNo) {
|
|
|
+ page.setPageNo(1);
|
|
|
+ }
|
|
|
+ page.setPageSize(10);
|
|
|
+ purchaseProduct.setPage(page);
|
|
|
+ List<PurchaseProduct> list = purchaseProductService.findSencondProductPage(purchaseProduct);
|
|
|
+ //通过用户id判断当前会所是否存在价格库价格,存在则使用价格库价格
|
|
|
+ Integer userId = purchaseProduct.getUserId();
|
|
|
+ model.addAttribute("userId", userId);
|
|
|
+ for (PurchaseProduct p : list) {
|
|
|
+ //1固定成本 2比例成本
|
|
|
+ String costCheckFlag = p.getCostCheckFlag();
|
|
|
+ if (StringUtils.equals("1", costCheckFlag)) {
|
|
|
+ //固定成本价
|
|
|
+ String costPrice = p.getCostPrice();
|
|
|
+ //只有固定成本,应付供应商的金额=添加商品时的成本价
|
|
|
+ p.setShopFee1(costPrice);
|
|
|
+ }
|
|
|
+ if (StringUtils.equals("2", costCheckFlag)) {
|
|
|
+ //比例成本价
|
|
|
+ String costProportional = p.getCostProportional();
|
|
|
+ String price = p.getPrice();
|
|
|
+ if (StringUtils.isNotEmpty(costProportional)) {
|
|
|
+ BigDecimal shopFee1 = (MathUtil.div(MathUtil.mul(costProportional, price), 100)).setScale(2, BigDecimal.ROUND_UP);
|
|
|
+ p.setShopFee1(String.valueOf(shopFee1));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ p.setTaxRate("0");
|
|
|
+ p.setSupplierTaxRate("0");
|
|
|
+ }
|
|
|
+ page.setList(list);
|
|
|
+ model.addAttribute("page", page);
|
|
|
+ return "modules/bulkpurchase/secondProductList";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @RequestMapping(value = "editProduct")
|
|
|
+ public String editProduct(PurchaseProduct purchaseProduct, HttpServletRequest request, HttpServletResponse response, Model model) {
|
|
|
+
|
|
|
+ HttpSession session = request.getSession();
|
|
|
+ PurchaseProduct purchaseProduct1 = (PurchaseProduct) session.getAttribute("purchaseProduct");
|
|
|
+ session.removeAttribute("purchaseProduct");
|
|
|
+ model.addAttribute("purchaseProduct", purchaseProduct1);
|
|
|
+ return "modules/bulkpurchase/purchaseProductEdit";
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "form")
|
|
|
+ public String form(PurchaseProduct purchaseProduct, Model model) {
|
|
|
+ model.addAttribute("purchaseProduct", purchaseProduct);
|
|
|
+ return "modules/bulkpurchase/purchaseProductForm";
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "save")
|
|
|
+ public String save(PurchaseProduct purchaseProduct, Model model, RedirectAttributes redirectAttributes) {
|
|
|
+ if (!beanValidator(model, purchaseProduct)) {
|
|
|
+ return form(purchaseProduct, model);
|
|
|
+ }
|
|
|
+ purchaseProductService.save(purchaseProduct);
|
|
|
+ addMessage(redirectAttributes, "保存大宗采购商品信息成功");
|
|
|
+ return "redirect:" + Global.getAdminPath() + "/bulkpurchase/purchaseProduct/?repage";
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "delete")
|
|
|
+ public String delete(PurchaseProduct purchaseProduct, RedirectAttributes redirectAttributes) {
|
|
|
+ purchaseProductService.delete(purchaseProduct);
|
|
|
+ addMessage(redirectAttributes, "删除大宗采购商品信息成功");
|
|
|
+ return "redirect:" + Global.getAdminPath() + "/bulkpurchase/purchaseProduct/?repage";
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "returnProduct")
|
|
|
+ @ResponseBody
|
|
|
+ public Map<String, Object> returnProduct(@RequestParam("product") String product, @RequestParam(value = "test", defaultValue = "") String test, HttpServletRequest request) {
|
|
|
+ JSONObject object = JSONObject.parseObject(product);
|
|
|
+ Map<String, Object> map = new HashMap();
|
|
|
+ PurchaseProduct purchaseProduct = JSONObject.toJavaObject(object, PurchaseProduct.class);
|
|
|
+ if (StringUtils.isBlank(purchaseProduct.getDiscount())) {
|
|
|
+ //如果商品折扣为空,则设置为100%
|
|
|
+ purchaseProduct.setDiscount(100 + "");
|
|
|
+ purchaseProduct.setDiscountPrice(purchaseProduct.getPrice());
|
|
|
+ }
|
|
|
+ List<ProductPrivilege> list = new ArrayList<>();
|
|
|
+ if (!test.equals("")) {
|
|
|
+ List<ProductPrivilege> productPrivileges = JSONArray.parseArray(test, ProductPrivilege.class);
|
|
|
+ purchaseProduct.setProductPrivilege(productPrivileges);
|
|
|
+ }
|
|
|
+ map.put("purchaseProduct", purchaseProduct);
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "putProductToSession")
|
|
|
+ @ResponseBody
|
|
|
+ public Map<String, Object> putProductToSession(@RequestParam("product") String product, HttpServletRequest request) {
|
|
|
+ Map<String, Object> map = new HashMap();
|
|
|
+ try {
|
|
|
+ JSONObject object = JSONObject.parseObject(product);
|
|
|
+ PurchaseProduct purchaseProduct = JSONObject.toJavaObject(object, PurchaseProduct.class);
|
|
|
+ HttpSession session = request.getSession();
|
|
|
+ session.setAttribute("purchaseProduct", purchaseProduct);
|
|
|
+ } catch (Exception e) {
|
|
|
+ map.put("message", "后台错误");
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @RequestMapping(value = "formOrderProduct")
|
|
|
+ public String formOrderProduct(PurchaseProduct purchaseProduct, Model model) {
|
|
|
+ if (purchaseProduct != null) {
|
|
|
+ purchaseProduct.setLadderPriceFlag(0);
|
|
|
+ Product product = productDao.get(purchaseProduct.getProductId().toString());
|
|
|
+ if (product != null) {
|
|
|
+ List<CmSku> skus = productDao.findSkuList(product.getProductID());
|
|
|
+ purchaseProduct.setSkuId(skus.get(0).getSkuId());
|
|
|
+ purchaseProduct.setPrice(skus.get(0).getPrice().toString());
|
|
|
+ skus.forEach(s -> {
|
|
|
+ if (1 == s.getLadderPriceFlag()) {
|
|
|
+ s.setLadderPriceList(productDao.findLadderPriceBySku(s.getSkuId()));
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // 超级会员价赋值
|
|
|
+ if (null != skus.get(0).getPriceType()) {
|
|
|
+ purchaseProduct.setPriceType(skus.get(0).getPriceType().toString());
|
|
|
+ if (1 == skus.get(0).getPriceType()) {
|
|
|
+ purchaseProduct.setDiscount(skus.get(0).getDiscount().toString());
|
|
|
+ } else {
|
|
|
+ purchaseProduct.setDiscountPrice(skus.get(0).getDiscountPrice().toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ purchaseProduct.setSkuList(skus);
|
|
|
+ CmSvipProduct svipProduct = purchaseProductService.getSvipProduct(purchaseProduct.getProductId(), purchaseProduct.getUserId());
|
|
|
+ CmPromotion productPromotion = cmPromotionService.findProductPromotion(product.getShopID().toString(), Long.parseLong(product.getProductID().toString()));
|
|
|
+ if (null != svipProduct && 1 == svipProduct.getSvipPriceFlag()) {
|
|
|
+ purchaseProduct.setSvipPriceFlag(1);
|
|
|
+ purchaseProduct.setSvipPriceType(svipProduct.getPriceType());
|
|
|
+ } else if (productPromotion != null) {
|
|
|
+ // 优惠价的时候给赋值优惠价
|
|
|
+ if("1".equals(productPromotion.getMode())){
|
|
|
+ productPromotion.setTouchPrice(skus.get(0).getTouchPrice());
|
|
|
+ }
|
|
|
+ purchaseProduct.setCmPromotion(productPromotion);
|
|
|
+ } else {
|
|
|
+ if (1 == skus.get(0).getLadderPriceFlag()) {
|
|
|
+ purchaseProduct.setLadderPriceFlag(1);
|
|
|
+ purchaseProduct.setLadderPriceList(productDao.findLadderPrice(skus.get(0).getSkuId()));
|
|
|
+ } else {
|
|
|
+ purchaseProduct.setLadderPriceFlag(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ model.addAttribute("purchaseProduct", purchaseProduct);
|
|
|
+ return "modules/bulkpurchase/orderPurchaseProductForm";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 订单设置二手商品
|
|
|
+ *
|
|
|
+ * @param purchaseProduct
|
|
|
+ * @param model
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "orderSecondHandProductForm")
|
|
|
+ public String orderSecondHandProductForm(PurchaseProduct purchaseProduct, Model model) {
|
|
|
+ model.addAttribute("purchaseProduct", purchaseProduct);
|
|
|
+ return "modules/bulkpurchase/orderSecondHandProductForm";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @RequiresPermissions("orderproduct:orderProduct:edit")
|
|
|
+ @RequestMapping(value = "promotionDetail")
|
|
|
+ public String formShopFee(@RequestParam("promotionId") String promotionId, Model model) {
|
|
|
+ CmPromotion cmPromotion = cmPromotionService.get(promotionId);
|
|
|
+ List<Product> promotionProducts = new ArrayList<>();
|
|
|
+ List<Product> giftProducts = new ArrayList<>();
|
|
|
+ List<Shop> promotionShops = new ArrayList<>();
|
|
|
+ if (cmPromotion != null && StringUtil.isNotBlank(promotionId)) {
|
|
|
+ if (!"3".equals(cmPromotion.getType())) {
|
|
|
+ promotionProducts.addAll(cmPromotionService.findPromotionProduct(cmPromotion));
|
|
|
+ } else {
|
|
|
+ promotionShops.addAll(cmPromotionService.findPromotionShops(cmPromotion));
|
|
|
+ }
|
|
|
+ if ("3".equals(cmPromotion.getMode())) {
|
|
|
+ giftProducts.addAll(cmPromotionService.findGiftProduct(cmPromotion.getId()));
|
|
|
+ }
|
|
|
+ cmPromotion.setPromotionProducts(promotionProducts);
|
|
|
+ cmPromotion.setGiftProducts(giftProducts);
|
|
|
+ cmPromotion.setPromotionShops(promotionShops);
|
|
|
+ }
|
|
|
+ model.addAttribute("cmPromotion", cmPromotion);
|
|
|
+ return "modules/bulkpurchase/productPromotionDetail";
|
|
|
+ }
|
|
|
+}
|