Merge remote-tracking branch 'origin/master'

This commit is contained in:
chc 2024-01-24 11:32:43 +08:00
commit 239b520939
16 changed files with 269 additions and 126 deletions

View File

@ -68,6 +68,8 @@ CREATE TABLE `li_order_package_item` (
*/
ALTER TABLE li_order_item ADD `deliver_number` int DEFAULT NULL COMMENT '发货数量';
ALTER TABLE li_goods_sku ADD `alert_quantity` int DEFAULT NULL COMMENT '预警库存';
/*
sku增加预警库存
*/
@ -75,4 +77,45 @@ ALTER TABLE li_goods_sku ADD `alert_quantity` int DEFAULT NULL COMMENT '预警
/*
*/
INSERT INTO `lilishop`.`li_store_menu`(`id`, `create_by`, `create_time`, `delete_flag`, `update_by`, `update_time`, `description`, `front_route`, `icon`, `level`, `name`, `parent_id`, `path`, `sort_order`, `title`, `permission`) VALUES (1349237928434098177, NULL, '2022-01-11 22:35:45.000000', b'0', NULL, '2022-01-11 22:37:05', NULL, 'goods/goods-seller/alertQuantity', 'ios-american-football', 2, 'alert-goods-quantity', '1348810864748945408', 'alert-goods-quantity', '1.14', '库存预警', NULL);
INSERT INTO `lilishop`.`li_store_menu`(`id`, `create_by`, `create_time`, `delete_flag`, `update_by`, `update_time`, `description`, `front_route`, `icon`, `level`, `name`, `parent_id`, `path`, `sort_order`, `title`, `permission`) VALUES (1349237928434098177, NULL, '2022-01-11 22:35:45.000000', b'0', NULL, '2022-01-11 22:37:05', NULL, 'goods/goods-seller/alertQuantity', 'ios-american-football', 2, 'alert-goods-quantity', '1348810864748945408', 'alert-goods-quantity', '1.14', '库存预警', NULL);
/**
*/
ALTER TABLE li_order_item ADD `is_refund` varchar(255) DEFAULT NULL COMMENT '是否退款';
/**
*/
ALTER TABLE li_order_item ADD `refund_price` decimal(10,2) DEFAULT NULL COMMENT '退款金额';
/**
/退
*/
ALTER TABLE li_bill ADD `point_refund_settlement_price` decimal(10,2) DEFAULT NULL COMMENT '退货积分补贴返还';
ALTER TABLE li_bill ADD `kanjia_refund_settlement_price` decimal(10,2) DEFAULT NULL COMMENT '退货砍价补贴返还';
UPDATE li_bill b
SET b.point_refund_settlement_price =IFNULL((
SELECT
SUM( point_settlement_price )
FROM
li_store_flow sf
WHERE
sf.flow_type = 'REFUND'
AND sf.store_id=b.store_id
AND sf.create_time BETWEEN b.start_time
AND b.end_time),0)
UPDATE li_bill b
SET b.kanjia_refund_settlement_price =IFNULL((
SELECT
SUM( kanjia_settlement_price )
FROM
li_store_flow sf
WHERE
sf.flow_type = 'REFUND'
AND sf.store_id=b.store_id
AND sf.create_time BETWEEN b.start_time
AND b.end_time),0);

View File

@ -28,6 +28,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
@ -189,28 +190,33 @@ public class StockUpdateExecute implements OrderStatusChangeEvent {
//如果促销类型需要库存判定则做对应处理
orderItems.forEach(orderItem -> {
if (orderItem.getPromotionType() != null) {
//如果此促销有库存概念则计入
if (PromotionTypeEnum.haveStock(orderItem.getPromotionType())) {
String[] skuPromotions = orderItem.getPromotionType().split(",");
for (int i = 0; i < skuPromotions.length; i++) {
int currentIndex = i;
//如果此促销有库存概念则计入
Arrays.stream(PromotionTypeEnum.haveStockPromotion).filter(promotionTypeEnum -> promotionTypeEnum.name().equals(skuPromotions[currentIndex]))
.findFirst()
.ifPresent(promotionTypeEnum -> {
String promotionId = orderItem.getPromotionId().split(",")[currentIndex];
String cacheKey = PromotionGoodsService.getPromotionGoodsStockCacheKey(promotionTypeEnum, promotionId, orderItem.getSkuId());
PromotionTypeEnum promotionTypeEnum = PromotionTypeEnum.valueOf(orderItem.getPromotionType());
String cacheKey = PromotionGoodsService.getPromotionGoodsStockCacheKey(promotionTypeEnum, orderItem.getPromotionId(), orderItem.getSkuId());
switch (promotionTypeEnum) {
case KANJIA:
cache.put(cacheKey, kanjiaActivityGoodsService.getKanjiaGoodsBySkuId(orderItem.getSkuId()).getStock());
return;
case POINTS_GOODS:
cache.put(cacheKey, pointsGoodsService.getPointsGoodsDetailBySkuId(orderItem.getSkuId()).getActiveStock());
return;
case SECKILL:
case PINTUAN:
cache.put(cacheKey, promotionGoodsService.getPromotionGoodsStock(promotionTypeEnum, orderItem.getPromotionId(), orderItem.getSkuId()));
return;
default:
break;
}
switch (promotionTypeEnum) {
case KANJIA:
cache.put(cacheKey, kanjiaActivityGoodsService.getKanjiaGoodsBySkuId(orderItem.getSkuId()).getStock());
return;
case POINTS_GOODS:
cache.put(cacheKey, pointsGoodsService.getPointsGoodsDetailBySkuId(orderItem.getSkuId()).getActiveStock());
return;
case SECKILL:
case PINTUAN:
cache.put(cacheKey, promotionGoodsService.getPromotionGoodsStock(promotionTypeEnum, promotionId, orderItem.getSkuId()));
return;
default:
break;
}
});
}
}
});
}
@ -222,7 +228,7 @@ public class StockUpdateExecute implements OrderStatusChangeEvent {
* @param orderSn 失败入库订单信息
*/
private void errorOrder(String orderSn) {
orderService.systemCancel(orderSn, outOfStockMessage,true);
orderService.systemCancel(orderSn, outOfStockMessage, true);
}
@ -236,13 +242,17 @@ public class StockUpdateExecute implements OrderStatusChangeEvent {
private void setPromotionStock(List<String> keys, List<String> values, OrderItem sku) {
if (sku.getPromotionType() != null) {
//如果此促销有库存概念则计入
if (!PromotionTypeEnum.haveStock(sku.getPromotionType())) {
return;
String[] skuPromotions = sku.getPromotionType().split(",");
for (int i = 0; i < skuPromotions.length; i++) {
int currentIndex = i;
Arrays.stream(PromotionTypeEnum.haveStockPromotion).filter(promotionTypeEnum -> promotionTypeEnum.name().equals(skuPromotions[currentIndex]))
.findFirst()
.ifPresent(promotionTypeEnum -> {
keys.add(PromotionGoodsService.getPromotionGoodsStockCacheKey(promotionTypeEnum, sku.getPromotionId().split(",")[currentIndex], sku.getSkuId()));
int num = -sku.getNum();
values.add(Integer.toString(num));
});
}
PromotionTypeEnum promotionTypeEnum = PromotionTypeEnum.valueOf(sku.getPromotionType());
keys.add(PromotionGoodsService.getPromotionGoodsStockCacheKey(promotionTypeEnum, sku.getPromotionId(), sku.getSkuId()));
int i = -sku.getNum();
values.add(Integer.toString(i));
}
}
@ -277,41 +287,51 @@ public class StockUpdateExecute implements OrderStatusChangeEvent {
goodsSku.setId(orderItem.getSkuId());
goodsSku.setGoodsId(orderItem.getGoodsId());
//如果有促销信息
if (null != orderItem.getPromotionType() && null != orderItem.getPromotionId() && PromotionTypeEnum.haveStock(orderItem.getPromotionType())) {
if (null != orderItem.getPromotionType() && null != orderItem.getPromotionId()) {
//如果促销有库存信息
PromotionTypeEnum promotionTypeEnum = PromotionTypeEnum.valueOf(orderItem.getPromotionType());
String[] skuPromotions = orderItem.getPromotionType().split(",");
for (int i = 0; i < skuPromotions.length; i++) {
int currentIndex = i;
Arrays.stream(PromotionTypeEnum.haveStockPromotion).filter(promotionTypeEnum -> promotionTypeEnum.name().equals(skuPromotions[currentIndex]))
.findFirst()
.ifPresent(promotionTypeEnum -> {
//修改砍价商品库存
String promotionId = orderItem.getPromotionId().split(",")[currentIndex];
//修改砍价商品库存
if (promotionTypeEnum.equals(PromotionTypeEnum.KANJIA)) {
KanjiaActivity kanjiaActivity = kanjiaActivityService.getById(orderItem.getPromotionId());
KanjiaActivityGoodsDTO kanjiaActivityGoodsDTO = kanjiaActivityGoodsService.getKanjiaGoodsDetail(kanjiaActivity.getKanjiaActivityGoodsId());
//修改砍价商品库存
if (promotionTypeEnum.equals(PromotionTypeEnum.KANJIA)) {
KanjiaActivity kanjiaActivity = kanjiaActivityService.getById(promotionId);
KanjiaActivityGoodsDTO kanjiaActivityGoodsDTO = kanjiaActivityGoodsService.getKanjiaGoodsDetail(kanjiaActivity.getKanjiaActivityGoodsId());
Integer stock = Integer.parseInt(cache.get(PromotionGoodsService.getPromotionGoodsStockCacheKey(promotionTypeEnum, orderItem.getPromotionId(), orderItem.getSkuId())).toString());
kanjiaActivityGoodsDTO.setStock(stock);
Integer stock = Integer.parseInt(cache.get(PromotionGoodsService.getPromotionGoodsStockCacheKey(promotionTypeEnum, promotionId, orderItem.getSkuId())).toString());
kanjiaActivityGoodsDTO.setStock(stock);
kanjiaActivityGoodsService.updateById(kanjiaActivityGoodsDTO);
//修改积分商品库存
} else if (promotionTypeEnum.equals(PromotionTypeEnum.POINTS_GOODS)) {
PointsGoodsVO pointsGoodsVO = pointsGoodsService.getPointsGoodsDetail(orderItem.getPromotionId());
Integer stock = Integer.parseInt(cache.get(PromotionGoodsService.getPromotionGoodsStockCacheKey(promotionTypeEnum, orderItem.getPromotionId(), orderItem.getSkuId())).toString());
pointsGoodsVO.setActiveStock(stock);
pointsGoodsService.updateById(pointsGoodsVO);
} else {
PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams();
searchParams.setPromotionType(promotionTypeEnum.name());
searchParams.setPromotionId(orderItem.getPromotionId());
searchParams.setSkuId(orderItem.getSkuId());
PromotionGoods pGoods = promotionGoodsService.getPromotionsGoods(searchParams);
//记录需要更新的促销库存信息
promotionKey.add(
PromotionGoodsService.getPromotionGoodsStockCacheKey(
promotionTypeEnum,
orderItem.getPromotionId(), orderItem.getSkuId())
);
if (pGoods != null) {
promotionGoods.add(pGoods);
}
kanjiaActivityGoodsService.updateById(kanjiaActivityGoodsDTO);
//修改积分商品库存
} else if (promotionTypeEnum.equals(PromotionTypeEnum.POINTS_GOODS)) {
PointsGoodsVO pointsGoodsVO = pointsGoodsService.getPointsGoodsDetail(promotionId);
Integer stock = Integer.parseInt(cache.get(PromotionGoodsService.getPromotionGoodsStockCacheKey(promotionTypeEnum, promotionId, orderItem.getSkuId())).toString());
pointsGoodsVO.setActiveStock(stock);
pointsGoodsService.updateById(pointsGoodsVO);
} else {
PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams();
searchParams.setPromotionType(promotionTypeEnum.name());
searchParams.setPromotionId(promotionId);
searchParams.setSkuId(orderItem.getSkuId());
PromotionGoods pGoods = promotionGoodsService.getPromotionsGoods(searchParams);
//记录需要更新的促销库存信息
promotionKey.add(
PromotionGoodsService.getPromotionGoodsStockCacheKey(
promotionTypeEnum,
promotionId, orderItem.getSkuId())
);
if (pGoods != null) {
promotionGoods.add(pGoods);
}
}
});
}
}
goodsSkus.add(goodsSku);
}

View File

@ -23,7 +23,7 @@ public enum PromotionTypeEnum {
/**
* 有促销库存的活动类型
*/
static final PromotionTypeEnum[] haveStockPromotion = new PromotionTypeEnum[]{PINTUAN, SECKILL, KANJIA, POINTS_GOODS};
public static final PromotionTypeEnum[] haveStockPromotion = new PromotionTypeEnum[]{PINTUAN, SECKILL, KANJIA, POINTS_GOODS};
private final String description;

View File

@ -65,7 +65,7 @@ public class TencentFilePlugin implements FilePlugin {
* @return
*/
private String getUrlPrefix() {
return "https://" + ossSetting.getTencentCOSBucket() + ".cos" + ossSetting.getTencentCOSRegion() + ".myqcloud.com/";
return "https://" + ossSetting.getTencentCOSBucket() + ".cos." + ossSetting.getTencentCOSRegion() + ".myqcloud.com/";
}
@Override

View File

@ -7,7 +7,6 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
import java.util.Map;
/**
* 商品导入DTO
@ -36,7 +35,7 @@ public class GoodsImportDTO {
private Boolean release;
@ApiModelProperty(value = "商品图片")
private List<Map<String, String>> images;
private List<String> images;
private List<String> goodsGalleryList;
@ApiModelProperty(value = "成本价")

View File

@ -32,18 +32,5 @@ public class SpecValueVO implements Serializable {
* 规格图片
*/
@ApiModelProperty(value = "规格的图片")
private List<SpecImages> specImage;
@Data
public static class SpecImages implements Serializable {
private static final long serialVersionUID = 1816357809660916086L;
private String url;
private String name;
private String status;
}
private List<String> specImage;
}

View File

@ -33,7 +33,9 @@ import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.net.URLEncoder;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
@Slf4j
@Service
@ -203,15 +205,11 @@ public class GoodsImportServiceImpl implements GoodsImportService {
goodsImportDTO.setCategory(category);
goodsImportDTO.setTemplate(templateId);
goodsImportDTO.setGoodsUnit(objects.get(4).toString().substring(objects.get(4).toString().indexOf("-") + 1));
goodsImportDTO.setRelease(objects.get(5).toString().equals("上架") ? true : false);
goodsImportDTO.setRelease(objects.get(5).toString().equals("上架"));
List<Map<String, String>> images = new ArrayList<>();
List<String> goodsGalleryList = new ArrayList<>();
Map<String, String> map = new HashMap<>();
map.put("url", objects.get(6).toString());
images.add(map);
goodsGalleryList.add(objects.get(6).toString());
goodsImportDTO.setImages(images);
goodsImportDTO.setImages(goodsGalleryList);
goodsImportDTO.setGoodsGalleryList(goodsGalleryList);
goodsImportDTO.setCost(Convert.toDouble(objects.get(7)));
@ -241,7 +239,7 @@ public class GoodsImportServiceImpl implements GoodsImportService {
//获取父
Category parentCategory = categoryService.getCategoryById(goodsImportDTO.getCategory().getParentId());
goodsOperationDTO.setCategoryPath(parentCategory.getParentId() + "," + parentCategory.getId() + "," + goodsImportDTO.getCategory().getParentId());
goodsOperationDTO.setCategoryPath(parentCategory.getParentId() + "," + parentCategory.getId() + "," + goodsImportDTO.getCategory().getId());
//添加商品
goodsService.addGoods(goodsOperationDTO);
}

View File

@ -35,7 +35,6 @@ import cn.lili.modules.goods.service.WholesaleService;
import cn.lili.modules.goods.sku.GoodsSkuBuilder;
import cn.lili.modules.goods.sku.render.SalesModelRender;
import cn.lili.modules.member.entity.dos.FootPrint;
import cn.lili.modules.member.service.MemberEvaluationService;
import cn.lili.modules.promotion.entity.dos.Coupon;
import cn.lili.modules.promotion.entity.dos.PromotionGoods;
import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams;
@ -98,11 +97,6 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
*/
@Autowired
private RocketmqCustomProperties rocketmqCustomProperties;
/**
* 会员评价
*/
@Autowired
private MemberEvaluationService memberEvaluationService;
/**
* 商品
*/
@ -334,6 +328,11 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
}
}
if (goodsSkuDetail.getGoodsGalleryList() == null || goodsSkuDetail.getGoodsGalleryList().isEmpty()) {
goodsSkuDetail.setGoodsGalleryList(goodsVO.getGoodsGalleryList());
} else {
goodsSkuDetail.getGoodsGalleryList().addAll(goodsVO.getGoodsGalleryList());
}
map.put("data", goodsSkuDetail);
//获取分类
@ -474,13 +473,10 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
SpecValueVO specValueVO = new SpecValueVO();
if ("images".equals(entry.getKey())) {
specValueVO.setSpecName(entry.getKey());
if (entry.getValue().toString().contains("url")) {
List<SpecValueVO.SpecImages> specImages = JSONUtil.toList(JSONUtil.parseArray(entry.getValue()),
SpecValueVO.SpecImages.class);
specValueVO.setSpecImage(specImages);
goodsGalleryList =
specImages.stream().map(SpecValueVO.SpecImages::getUrl).collect(Collectors.toList());
}
List<String> specImages = JSONUtil.toList(JSONUtil.parseArray(entry.getValue()),
String.class);
specValueVO.setSpecImage(specImages);
goodsGalleryList = new ArrayList<>(specImages);
} else {
specValueVO.setSpecName(entry.getKey());
specValueVO.setSpecValue(entry.getValue().toString());
@ -677,7 +673,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
salesModelRenders.stream().filter(i -> i.getSalesMode().equals(goodsOperationDTO.getSalesModel())).findFirst().ifPresent(i -> i.renderBatch(goodsSkuList, goodsOperationDTO));
for (GoodsSku goodsSku : goodsSkuList) {
extendOldSkuValue(goodsSku);
this.renderImages(goodsSku);
this.renderImages(goodsSku, goodsOperationDTO.getGoodsGalleryList());
}
}
@ -709,7 +705,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
extendOldSkuValue(goodsSku);
// 商品销售模式渲染器
salesModelRenders.stream().filter(i -> i.getSalesMode().equals(goodsOperationDTO.getSalesModel())).findFirst().ifPresent(i -> i.renderSingle(goodsSku, goodsOperationDTO));
this.renderImages(goodsSku);
this.renderImages(goodsSku, goodsOperationDTO.getGoodsGalleryList());
}
/**
@ -734,16 +730,20 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
*
* @param goodsSku sku
*/
void renderImages(GoodsSku goodsSku) {
void renderImages(GoodsSku goodsSku, List<String> goodsImages) {
JSONObject jsonObject = JSONUtil.parseObj(goodsSku.getSpecs());
List<Map<String, String>> images = jsonObject.get("images", List.class);
List<String> images = jsonObject.getBeanList("images", String.class);
GoodsGallery goodsGallery;
if (images != null && !images.isEmpty()) {
GoodsGallery goodsGallery = goodsGalleryService.getGoodsGallery(images.get(0).get("url"));
goodsSku.setBig(goodsGallery.getOriginal());
goodsSku.setOriginal(goodsGallery.getOriginal());
goodsSku.setThumbnail(goodsGallery.getThumbnail());
goodsSku.setSmall(goodsGallery.getSmall());
goodsGallery = goodsGalleryService.getGoodsGallery(images.get(0));
} else {
goodsGallery = goodsGalleryService.getGoodsGallery(goodsImages.get(0));
}
goodsSku.setBig(goodsGallery.getOriginal());
goodsSku.setOriginal(goodsGallery.getOriginal());
goodsSku.setThumbnail(goodsGallery.getThumbnail());
goodsSku.setSmall(goodsGallery.getSmall());
}
/**

View File

@ -399,6 +399,8 @@ public class SeckillApplyServiceImpl extends ServiceImpl<SeckillApplyMapper, Sec
Object quantity = cache.get(promotionGoodsStockCacheKey);
if (quantity != null) {
goodsVO.setQuantity((Integer) quantity);
} else {
cache.put(promotionGoodsStockCacheKey, seckillApply.getQuantity());
}
seckillGoodsVoS.add(goodsVO);
}

View File

@ -103,9 +103,16 @@ public class Bill extends BaseIdEntity {
@ApiModelProperty(value = "积分商品结算价格")
private Double pointSettlementPrice;
@ApiModelProperty(value = "退货积分补贴返还")
private Double pointRefundSettlementPrice;
@ApiModelProperty(value = "砍价商品结算价格")
private Double kanjiaSettlementPrice;
@ApiModelProperty(value = "退货砍价补贴返还")
private Double kanjiaRefundSettlementPrice;
/**
* 开始算钱啦

View File

@ -35,8 +35,10 @@ public interface BillMapper extends BaseMapper<Bill> {
* @param queryWrapper 查询条件
* @return 结算单
*/
@Select("SELECT IFNULL(SUM( final_price ),0) AS orderPrice,IFNULL(SUM( commission_price ),0) AS commissionPrice" +
",IFNULL(SUM( distribution_rebate ),0) AS distributionCommission,IFNULL(SUM( site_coupon_commission ),0) AS siteCouponCommission" +
@Select("SELECT IFNULL(SUM( final_price ),0) AS orderPrice" +
",IFNULL(SUM( commission_price ),0) AS commissionPrice" +
",IFNULL(SUM( distribution_rebate ),0) AS distributionCommission" +
",IFNULL(SUM( site_coupon_commission ),0) AS siteCouponCommission" +
",IFNULL(SUM( point_settlement_price ),0) AS pointSettlementPrice " +
",IFNULL(SUM( kanjia_settlement_price ),0) AS kanjiaSettlementPrice " +
",IFNULL(SUM( bill_price ),0) AS billPrice " +
@ -49,8 +51,12 @@ public interface BillMapper extends BaseMapper<Bill> {
* @param queryWrapper 查询条件
* @return 结算单
*/
@Select("SELECT IFNULL(SUM( final_price ),0) AS refundPrice,IFNULL(SUM( commission_price ),0) AS refundCommissionPrice" +
",IFNULL(SUM( distribution_rebate ),0) AS distributionRefundCommission,IFNULL(SUM( site_coupon_commission ),0) AS siteCouponRefundCommission" +
@Select("SELECT IFNULL(SUM( final_price ),0) AS refundPrice" +
",IFNULL(SUM( commission_price ),0) AS refundCommissionPrice" +
",IFNULL(SUM( distribution_rebate ),0) AS distributionRefundCommission" +
",IFNULL(SUM( site_coupon_commission ),0) AS siteCouponRefundCommission" +
",IFNULL(SUM( kanjia_settlement_price ),0) AS kanjiaRefundSettlementPrice" +
",IFNULL(SUM( point_settlement_price ),0) AS pointRefundSettlementPrice" +
",IFNULL(SUM( final_price ),0) AS billPrice FROM li_store_flow ${ew.customSqlSegment}")
Bill getRefundBill(@Param(Constants.WRAPPER) QueryWrapper<Bill> queryWrapper);
}

View File

@ -30,6 +30,10 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
@ -37,9 +41,9 @@ import org.springframework.transaction.annotation.Transactional;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.Date;
import java.util.List;
import java.util.*;
/**
* 结算单业务层实现
@ -95,12 +99,16 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements Bi
if (refundBill != null) {
//退单金额
bill.setRefundPrice(refundBill.getRefundPrice() != null ? refundBill.getRefundPrice() : 0D);
//退单产生退还佣金金额
//退单 平台服务费返还
bill.setRefundCommissionPrice(refundBill.getRefundCommissionPrice() != null ? refundBill.getRefundCommissionPrice() : 0D);
//分销订单退还返现佣金返还
//退单 分销佣金返还
bill.setDistributionRefundCommission(refundBill.getDistributionRefundCommission() != null ? refundBill.getDistributionRefundCommission() : 0D);
//退平台优惠券补贴返还
//退 平台优惠券补贴返还
bill.setSiteCouponRefundCommission(refundBill.getSiteCouponRefundCommission() != null ? refundBill.getSiteCouponRefundCommission() : 0D);
//退单 平台优惠券补贴返还
bill.setPointRefundSettlementPrice(refundBill.getPointRefundSettlementPrice() != null ? refundBill.getPointRefundSettlementPrice() : 0D);
//退单 砍价补贴返还
bill.setKanjiaRefundSettlementPrice(refundBill.getKanjiaRefundSettlementPrice() != null ? refundBill.getKanjiaRefundSettlementPrice() : 0D);
//退款金额=店铺最终退款结算金额
refundPrice = refundBill.getBillPrice() != null ? refundBill.getBillPrice() : 0D;
}
@ -213,8 +221,61 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements Bi
@Override
public void download(HttpServletResponse response, String id) {
Bill bill = this.getById(id);
ExcelWriter writer = ExcelUtil.getWriterWithSheet("入账订单");
//创建Excel工作薄对象
ExcelWriter writer = ExcelUtil.getWriterWithSheet("店铺结算单");
writer.setSheet("店铺结算单");
Map<String,Object> map=new LinkedHashMap<>();
map.put("创建时间",DateUtil.format(bill.getCreateTime(), "yyyy-MM-dd"));
writer.setColumnWidth(0, 15);
map.put("账单号",bill.getSn());
writer.setColumnWidth(1, 30);
map.put("结算开始时间",DateUtil.format(bill.getStartTime(), "yyyy-MM-dd"));
writer.setColumnWidth(2, 15);
map.put("结算结束时间",DateUtil.format(bill.getEndTime(), "yyyy-MM-dd"));
writer.setColumnWidth(3, 15);
map.put("账单状态",BillStatusEnum.valueOf(bill.getBillStatus()).description());
map.put("店铺名称",bill.getStoreName());
writer.setColumnWidth(5, 15);
map.put("平台付款时间",DateUtil.format(bill.getPayTime(), "yyyy-MM-dd"));
writer.setColumnWidth(6, 15);
map.put("银行开户名",bill.getBankAccountName());
writer.setColumnWidth(7, 15);
map.put("银行账号",bill.getBankAccountNumber());
writer.setColumnWidth(8, 15);
map.put("开户行",bill.getBankName());
writer.setColumnWidth(9, 15);
map.put("联行号",bill.getBankCode());
map.put("订单金额",bill.getOrderPrice());
map.put("退单金额",bill.getRefundPrice());
map.put("平台收取服务费",bill.getCommissionPrice());
writer.setColumnWidth(13, 15);
map.put("退单退回平台服务费",bill.getRefundCommissionPrice());
writer.setColumnWidth(14, 25);
map.put("分销佣金",bill.getDistributionCommission());
map.put("退单退还分销佣金",bill.getDistributionRefundCommission());
writer.setColumnWidth(16, 20);
map.put("平台优惠券补贴",bill.getSiteCouponCommission());
writer.setColumnWidth(17, 15);
map.put("退单退回平台优惠券补贴",bill.getSiteCouponRefundCommission());
writer.setColumnWidth(18, 25);
map.put("积分商品补贴",bill.getSiteCouponCommission());
writer.setColumnWidth(19, 15);
map.put("积分商品补贴",bill.getPointSettlementPrice());
writer.setColumnWidth(20, 15);
map.put("退单退回积分商品补贴",bill.getPointRefundSettlementPrice());
writer.setColumnWidth(21, 25);
map.put("砍价商品补贴",bill.getKanjiaSettlementPrice());
writer.setColumnWidth(22, 15);
map.put("退单退回砍价补贴",bill.getKanjiaRefundSettlementPrice());
writer.setColumnWidth(23, 25);
map.put("最终结算金额",bill.getBillPrice());
writer.setColumnWidth(24, 15);
writer.writeRow(map,true);
writer.setSheet("入账订单");
writer.addHeaderAlias("createTime", "入账时间");
writer.setColumnWidth(0, 20);
@ -237,7 +298,6 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements Bi
writer.addHeaderAlias("billPrice", "应结金额");
writer.setColumnWidth(11, 20);
List<StoreFlowPayDownloadVO> storeFlowList = storeFlowService.getStoreFlowPayDownloadVO(StoreFlowQueryDTO.builder().type(FlowTypeEnum.PAY.name()).bill(bill).build());
writer.write(storeFlowList, true);
@ -252,7 +312,7 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements Bi
writer.setColumnWidth(3, 20);
writer.addHeaderAlias("goodsName", "商品名称");
writer.setColumnWidth(4, 70);
writer.addHeaderAlias("num", "销售");
writer.addHeaderAlias("num", "退款");
writer.addHeaderAlias("finalPrice", "退款金额");
writer.addHeaderAlias("commissionPrice", "平台分佣");
writer.addHeaderAlias("siteCouponPrice", "平台优惠券");
@ -265,23 +325,26 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements Bi
writer.addHeaderAlias("billPrice", "结算金额");
writer.setColumnWidth(12, 20);
List<StoreFlowRefundDownloadVO> storeFlowRefundDownloadVOList = storeFlowService.getStoreFlowRefundDownloadVO(StoreFlowQueryDTO.builder().type(FlowTypeEnum.REFUND.name()).bill(bill).build());
writer.write(storeFlowRefundDownloadVOList, true);
ServletOutputStream out = null;
try {
writer.setOnlyAlias(true);
//设置公共属性列表名称
response.setContentType("application/vnd.ms-excel;charset=utf-8");
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(bill.getStoreName() + "-" + bill.getSn(), "UTF8") + ".xls");
response.setHeader("Content-Disposition", URLEncoder.encode("店铺结算单详情", "UTF8") + ".xls");
out = response.getOutputStream();
writer.flush(out, true);
} catch (Exception e) {
log.error("下载结算单错误", e);
log.error("下载列表错误", e);
} finally {
writer.close();
IoUtil.close(out);
}
}
}

View File

@ -28,6 +28,10 @@ public class InsertIgnoreBatchAllColumn extends AbstractMethod {
@Accessors(chain = true)
private Predicate<TableFieldInfo> predicate;
protected InsertIgnoreBatchAllColumn(String methodName) {
super(methodName);
}
@SuppressWarnings("Duplicates")
@Override
public MappedStatement injectMappedStatement(Class<?> mapperClass, Class<?> modelClass, TableInfo tableInfo) {
@ -36,7 +40,7 @@ public class InsertIgnoreBatchAllColumn extends AbstractMethod {
String sqlTemplate = "<script>\nINSERT IGNORE INTO %s %s VALUES %s\n</script>";
List<TableFieldInfo> fieldList = tableInfo.getFieldList();
String insertSqlColumn = tableInfo.getKeyInsertSqlColumn(true, false) +
String insertSqlColumn = tableInfo.getKeyInsertSqlColumn(true, "", false) +
this.filterTableFieldInfo(fieldList, predicate, TableFieldInfo::getInsertSqlColumn, EMPTY);
String columnScript = LEFT_BRACKET + insertSqlColumn.substring(0, insertSqlColumn.length() - 1) + RIGHT_BRACKET;
String insertSqlProperty = tableInfo.getKeyInsertSqlProperty(true, ENTITY_DOT, false) +

View File

@ -28,7 +28,7 @@ public class SpiceSqlInjector extends DefaultSqlInjector {
// methodList.add(new InsertBatchSomeColumn(t -> !t.isLogicDelete() && !"update_time".equals(t.getColumn())));
// 要逻辑删除 t.isLogicDelete() 默认不要
methodList.add(new InsertBatchSomeColumn(t -> !t.isLogicDelete()));
methodList.add(new InsertIgnoreBatchAllColumn());
methodList.add(new InsertIgnoreBatchAllColumn("insertIgnoreBatchAllColumn"));
return methodList;
}
}

View File

@ -1,6 +1,8 @@
package cn.lili.controller.store;
import cn.lili.common.context.ThreadContextHolder;
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.security.OperationalJudgment;
import cn.lili.common.vo.PageVO;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.order.order.entity.dos.StoreFlow;
@ -17,6 +19,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.constraints.NotNull;
/**
@ -66,4 +69,15 @@ public class BillManagerController {
return ResultUtil.success();
}
@ApiOperation(value = "下载结算单", produces = "application/octet-stream")
@ApiImplicitParam(name = "id", value = "结算单ID", required = true, paramType = "path", dataType = "String")
@GetMapping(value = "/downLoad/{id}")
public void downLoadDeliverExcel(@PathVariable String id) {
OperationalJudgment.judgment(billService.getById(id));
HttpServletResponse response = ThreadContextHolder.getHttpResponse();
billService.download(response, id);
}
}

View File

@ -25,12 +25,12 @@
<docker-registry>registry.cn-beijing.aliyuncs.com/lili-images</docker-registry>
<images-version>1</images-version>
<alipay-sdk-version>4.22.32.ALL</alipay-sdk-version>
<mybatis-plus-version>3.5.1</mybatis-plus-version>
<Hutool-version>5.8.14</Hutool-version>
<mybatis-plus-version>3.5.5</mybatis-plus-version>
<Hutool-version>5.8.24</Hutool-version>
<TinyPinyin-verions>2.0.3.RELEASE</TinyPinyin-verions>
<jasypt-version>3.0.4</jasypt-version>
<neetl-version>2.9.10</neetl-version>
<lombok-version>1.18.24</lombok-version>
<lombok-version>1.18.30</lombok-version>
<redisson>3.15.6</redisson>
<aliyun-version>4.5.18</aliyun-version>
<aliyun-sdk-oss-version>3.11.1</aliyun-sdk-oss-version>