|
@@ -34,6 +34,7 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
|
|
private CmPromotionDao cmPromotionDao;
|
|
private CmPromotionDao cmPromotionDao;
|
|
@Autowired
|
|
@Autowired
|
|
private ProductDao productDao;
|
|
private ProductDao productDao;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public CmPromotion get(String id) {
|
|
public CmPromotion get(String id) {
|
|
return super.get(id);
|
|
return super.get(id);
|
|
@@ -50,8 +51,10 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
|
|
List<Product> giftProducts = new ArrayList<>();
|
|
List<Product> giftProducts = new ArrayList<>();
|
|
List<Shop> promotionShops = new ArrayList<>();
|
|
List<Shop> promotionShops = new ArrayList<>();
|
|
if (CollectionUtils.isNotEmpty(promotionList)) {
|
|
if (CollectionUtils.isNotEmpty(promotionList)) {
|
|
- for (CmPromotion promotion : promotionList
|
|
|
|
- ) {
|
|
|
|
|
|
+ for (CmPromotion promotion : promotionList) {
|
|
|
|
+ if("1".equals(promotion.getType())){
|
|
|
|
+ promotion.setSkus(productDao.findSkuByPromotion(promotion.getId()));
|
|
|
|
+ }
|
|
if (StringUtils.isNotBlank(cmPromotion.getProductName())) {
|
|
if (StringUtils.isNotBlank(cmPromotion.getProductName())) {
|
|
promotion.setProductName(cmPromotion.getProductName());
|
|
promotion.setProductName(cmPromotion.getProductName());
|
|
}
|
|
}
|
|
@@ -77,13 +80,13 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
|
|
//未开始
|
|
//未开始
|
|
promotion.setDelFlag1("1");
|
|
promotion.setDelFlag1("1");
|
|
}
|
|
}
|
|
- }else {
|
|
|
|
|
|
+ } else {
|
|
promotion.setDelFlag1("0");
|
|
promotion.setDelFlag1("0");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }else if("1".equals(promotion.getDelFlag1())){
|
|
|
|
|
|
+ } else if ("1".equals(promotion.getDelFlag1())) {
|
|
promotion.setDelFlag1("0");
|
|
promotion.setDelFlag1("0");
|
|
- }else if("2".equals(promotion.getDelFlag1())){
|
|
|
|
|
|
+ } else if ("2".equals(promotion.getDelFlag1())) {
|
|
promotion.setDelFlag1("4");
|
|
promotion.setDelFlag1("4");
|
|
}
|
|
}
|
|
//非店铺促销下设置促销产品
|
|
//非店铺促销下设置促销产品
|
|
@@ -91,7 +94,8 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
|
|
//根据促销id和商品名查询
|
|
//根据促销id和商品名查询
|
|
promotionProducts = findPromotionProduct(promotion);
|
|
promotionProducts = findPromotionProduct(promotion);
|
|
promotion.setPromotionProducts(promotionProducts);
|
|
promotion.setPromotionProducts(promotionProducts);
|
|
- }else {
|
|
|
|
|
|
+
|
|
|
|
+ } else {
|
|
promotionShops = findPromotionShops(promotion);
|
|
promotionShops = findPromotionShops(promotion);
|
|
promotion.setPromotionShops(promotionShops);
|
|
promotion.setPromotionShops(promotionShops);
|
|
}
|
|
}
|
|
@@ -134,6 +138,7 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
|
|
String wwwServer = Global.getConfig("wwwServer");
|
|
String wwwServer = Global.getConfig("wwwServer");
|
|
for (Product product : products) {
|
|
for (Product product : products) {
|
|
if (product != null) {
|
|
if (product != null) {
|
|
|
|
+ product.setSkuList(productDao.findSkuList(product.getProductID()));
|
|
product.setStoreStatus(true);
|
|
product.setStoreStatus(true);
|
|
product.setMainImage(AppUtils.getImageURL("product", product.getMainImage(), 0, wwwServer));
|
|
product.setMainImage(AppUtils.getImageURL("product", product.getMainImage(), 0, wwwServer));
|
|
}
|
|
}
|
|
@@ -159,7 +164,7 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
|
|
/**
|
|
/**
|
|
* 根据促销活动id查询促销赠品(订单)
|
|
* 根据促销活动id查询促销赠品(订单)
|
|
*/
|
|
*/
|
|
- public List<PurchaseProduct> findGiftPurchaseProduct(String id){
|
|
|
|
|
|
+ public List<PurchaseProduct> findGiftPurchaseProduct(String id) {
|
|
List<PurchaseProduct> list = cmPromotionDao.findGiftPurchaseProduct(id);
|
|
List<PurchaseProduct> list = cmPromotionDao.findGiftPurchaseProduct(id);
|
|
for (PurchaseProduct p : list) {
|
|
for (PurchaseProduct p : list) {
|
|
if (p != null) {
|
|
if (p != null) {
|
|
@@ -186,6 +191,7 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
|
|
}
|
|
}
|
|
return list;
|
|
return list;
|
|
}
|
|
}
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查询促销可用商品
|
|
* 查询促销可用商品
|
|
*/
|
|
*/
|
|
@@ -216,7 +222,7 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
|
|
delList.add(Integer.parseInt(productId));
|
|
delList.add(Integer.parseInt(productId));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- }else {
|
|
|
|
|
|
+ } else {
|
|
delList.add(Integer.parseInt(product.getDelProductIds()));
|
|
delList.add(Integer.parseInt(product.getDelProductIds()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -225,7 +231,7 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
|
|
//当选择促销商品时,需要排除掉相同促销类型下已参与促销的商品
|
|
//当选择促销商品时,需要排除掉相同促销类型下已参与促销的商品
|
|
productList = cmPromotionDao.findAllProduct(product);
|
|
productList = cmPromotionDao.findAllProduct(product);
|
|
String wwwServer = Global.getConfig("wwwServer");
|
|
String wwwServer = Global.getConfig("wwwServer");
|
|
- productList.forEach(item ->{
|
|
|
|
|
|
+ productList.forEach(item -> {
|
|
List<CmSku> skuList = productDao.findSkuList(item.getProductID());
|
|
List<CmSku> skuList = productDao.findSkuList(item.getProductID());
|
|
List<CmSku> collect = skuList.stream().sorted(Comparator.comparing(CmSku::getPrice)).collect(Collectors.toList());
|
|
List<CmSku> collect = skuList.stream().sorted(Comparator.comparing(CmSku::getPrice)).collect(Collectors.toList());
|
|
item.setSkuList(collect);
|
|
item.setSkuList(collect);
|
|
@@ -242,7 +248,7 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
|
|
public Page findShopPage(Page<Shop> shopPage, Shop shop) {
|
|
public Page findShopPage(Page<Shop> shopPage, Shop shop) {
|
|
shop.setPage(shopPage);
|
|
shop.setPage(shopPage);
|
|
List<Integer> list = new ArrayList<>();
|
|
List<Integer> list = new ArrayList<>();
|
|
- if (StringUtil.isNotBlank(shop.getShopIds()) ) {
|
|
|
|
|
|
+ if (StringUtil.isNotBlank(shop.getShopIds())) {
|
|
if (shop.getShopIds().contains(",")) {
|
|
if (shop.getShopIds().contains(",")) {
|
|
String[] split = shop.getShopIds().split(",");
|
|
String[] split = shop.getShopIds().split(",");
|
|
for (String shopId : split) {
|
|
for (String shopId : split) {
|
|
@@ -283,19 +289,19 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
|
|
}
|
|
}
|
|
cmPromotion.setUpdateTime(new Date());
|
|
cmPromotion.setUpdateTime(new Date());
|
|
if (StringUtils.isNotBlank(cmPromotion.getType()) && StringUtils.isNotBlank(cmPromotion.getMode())) {
|
|
if (StringUtils.isNotBlank(cmPromotion.getType()) && StringUtils.isNotBlank(cmPromotion.getMode())) {
|
|
- if ("1".equals(cmPromotion.getType()) && "1".equals(cmPromotion.getMode())){
|
|
|
|
|
|
+ if ("1".equals(cmPromotion.getType()) && "1".equals(cmPromotion.getMode())) {
|
|
// 优惠价
|
|
// 优惠价
|
|
cmPromotion.setName("优惠价");
|
|
cmPromotion.setName("优惠价");
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
String type = "1".equals(cmPromotion.getType()) ? "单品" : "2".equals(cmPromotion.getType()) ? "凑单" : "3".equals(cmPromotion.getType()) ? "店铺" : "优惠";
|
|
String type = "1".equals(cmPromotion.getType()) ? "单品" : "2".equals(cmPromotion.getType()) ? "凑单" : "3".equals(cmPromotion.getType()) ? "店铺" : "优惠";
|
|
String mode = "2".equals(cmPromotion.getMode()) ? "满减" : "3".equals(cmPromotion.getMode()) ? "满赠" : "优惠";
|
|
String mode = "2".equals(cmPromotion.getMode()) ? "满减" : "3".equals(cmPromotion.getMode()) ? "满赠" : "优惠";
|
|
cmPromotion.setName(type + mode);
|
|
cmPromotion.setName(type + mode);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (cmPromotion.getIsNewRecord()){
|
|
|
|
|
|
+ if (cmPromotion.getIsNewRecord()) {
|
|
cmPromotion.preInsert();
|
|
cmPromotion.preInsert();
|
|
cmPromotionDao.insert(cmPromotion);
|
|
cmPromotionDao.insert(cmPromotion);
|
|
- }else{
|
|
|
|
|
|
+ } else {
|
|
cmPromotion.preUpdate();
|
|
cmPromotion.preUpdate();
|
|
cmPromotionDao.update(cmPromotion);
|
|
cmPromotionDao.update(cmPromotion);
|
|
}
|
|
}
|
|
@@ -303,11 +309,11 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
|
|
//删除数据库中该促销活动原来的商品、赠品和商店
|
|
//删除数据库中该促销活动原来的商品、赠品和商店
|
|
cmPromotionDao.deleteAllPromotionProductsAndShops(promotionId);
|
|
cmPromotionDao.deleteAllPromotionProductsAndShops(promotionId);
|
|
cmPromotionDao.deleteAllPromotionGifts(promotionId);
|
|
cmPromotionDao.deleteAllPromotionGifts(promotionId);
|
|
- if ("1".equals(cmPromotion.getType()) && "1".equals(cmPromotion.getMode())){
|
|
|
|
|
|
+ if ("1".equals(cmPromotion.getType()) && "1".equals(cmPromotion.getMode())) {
|
|
// 单品优惠价的时候,删除优惠商品之前的优惠价(新增保存不会删除)
|
|
// 单品优惠价的时候,删除优惠商品之前的优惠价(新增保存不会删除)
|
|
cmPromotionDao.deleteOldTouchPrice(promotionId);
|
|
cmPromotionDao.deleteOldTouchPrice(promotionId);
|
|
// 保存新的sku优惠价
|
|
// 保存新的sku优惠价
|
|
- cmPromotion.getSkus().forEach(s->cmPromotionDao.insertNewTouchPrice(s.getSkuId(),s.getTouchPrice(),promotionId));
|
|
|
|
|
|
+ cmPromotion.getSkus().forEach(s -> cmPromotionDao.insertNewTouchPrice(s.getSkuId(), s.getTouchPrice(), promotionId));
|
|
}
|
|
}
|
|
|
|
|
|
if (StringUtil.isNotBlank(cmPromotion.getProductIds())) {
|
|
if (StringUtil.isNotBlank(cmPromotion.getProductIds())) {
|
|
@@ -345,17 +351,17 @@ public class CmPromotionService extends CrudService<CmPromotionDao, CmPromotion>
|
|
* 查询供应商信息
|
|
* 查询供应商信息
|
|
*/
|
|
*/
|
|
public Shop findShop(String shopId) {
|
|
public Shop findShop(String shopId) {
|
|
- return cmPromotionDao.findShop(shopId);
|
|
|
|
|
|
+ return cmPromotionDao.findShop(shopId);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
* 查询产品对应的促销活动
|
|
* 查询产品对应的促销活动
|
|
*/
|
|
*/
|
|
public CmPromotion findProductPromotion(String shopId, Long productId) {
|
|
public CmPromotion findProductPromotion(String shopId, Long productId) {
|
|
- return cmPromotionDao.findProductPromotion(shopId, productId);
|
|
|
|
|
|
+ return cmPromotionDao.findProductPromotion(shopId, productId);
|
|
}
|
|
}
|
|
|
|
|
|
public void delPromotion(String id, Integer skuId) {
|
|
public void delPromotion(String id, Integer skuId) {
|
|
- cmPromotionDao.deletePromotion(id,skuId);
|
|
|
|
|
|
+ cmPromotionDao.deletePromotion(id, skuId);
|
|
}
|
|
}
|
|
}
|
|
}
|