增加店铺企业信息接口

增加删除商品
修复:修改订单金额售后金额不正确
This commit is contained in:
lifenlong 2021-08-11 20:14:56 +08:00
parent dd7af218a4
commit 64e45c10b1
13 changed files with 118 additions and 65 deletions

View File

@ -63,6 +63,13 @@ public class StoreBuyerController {
return ResultUtil.data(storeDetailService.getStoreBasicInfoDTO(id));
}
@ApiOperation(value = "通过id获取店铺详细信息-营业执照")
@ApiImplicitParam(name = "id", value = "店铺ID", required = true, paramType = "path")
@GetMapping(value = "/get/licencePhoto/{id}")
public ResultMessage<StoreOtherVO> licencePhoto(@NotNull @PathVariable String id) {
return ResultUtil.data(storeDetailService.getStoreOtherVO(id));
}
@ApiOperation(value = "通过id获取店铺商品分类")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "店铺ID", required = true, paramType = "path")

View File

@ -68,7 +68,7 @@ public class UploadController {
throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR);
}
Setting setting = settingService.get(SettingEnum.OSS_SETTING.name());
if (setting == null || StrUtil.isBlank(setting.getSettingValue())) {
if (StrUtil.isEmpty(setting.getSettingValue())) {
throw new ServiceException(ResultCode.OSS_NOT_EXIST);
}

View File

@ -96,7 +96,7 @@ public class PriceDetailDTO implements Serializable {
public Double getOriginalPrice() {
if (originalPrice == null) {
if (originalPrice == 0D) {
return flowPrice;
}
return originalPrice;

View File

@ -189,7 +189,7 @@ public class AfterSaleServiceImpl extends ServiceImpl<AfterSaleMapper, AfterSale
if (!afterSale.getServiceStatus().equals(AfterSaleStatusEnum.APPLY.name())) {
throw new ServiceException(ResultCode.AFTER_SALES_DOUBLE_ERROR);
}
//判断退款金额与付款金额是否正确,退款金额不能于付款金额
//判断退款金额与付款金额是否正确,退款金额不能于付款金额
if (NumberUtil.compare(afterSale.getFlowPrice(), actualRefundPrice) == -1) {
throw new ServiceException(ResultCode.AFTER_SALES_PRICE_ERROR);
}

View File

@ -71,7 +71,7 @@ public class OrderPriceServiceImpl implements OrderPriceService {
Order order = updateOrderPrice(orderSn, orderPrice);
//修改订单货物金额
updateOrderItemPrice(order);
//updateOrderItemPrice(order);
//修改交易金额
tradeMapper.updateTradePrice(order.getTradeSn());
@ -112,12 +112,16 @@ public class OrderPriceServiceImpl implements OrderPriceService {
//获取订单价格信息
PriceDetailDTO orderPriceDetailDTO = order.getPriceDetailDTO();
if (orderPriceDetailDTO.getOriginalPrice() == 0D) {
orderPriceDetailDTO.setOriginalPrice(orderPriceDetailDTO.getFlowPrice());
}
//修改订单价格
order.setFlowPrice(orderPrice);
//订单修改金额=使用订单原始金额-修改后金额
orderPriceDetailDTO.setUpdatePrice(CurrencyUtil.sub(orderPriceDetailDTO.getOriginalPrice(), orderPrice));
orderPriceDetailDTO.setFlowPrice(orderPrice);
order.setPriceDetail(JSONUtil.toJsonStr(orderPriceDetailDTO));
List<OrderItem> orderItems = updateOrderItemPrice(order);
//这里如果直接赋予订单金额则累加可能会出现小数点最后无法累加回去所以用一个零时变量累加后将平台佣金赋予对象
@ -150,6 +154,9 @@ public class OrderPriceServiceImpl implements OrderPriceService {
//获取订单货物价格信息
PriceDetailDTO priceDetailDTO = orderItem.getPriceDetailDTO();
if (priceDetailDTO.getOriginalPrice() == 0D) {
priceDetailDTO.setOriginalPrice(priceDetailDTO.getFlowPrice());
}
//SKU占总订单 金额的百分比
Double priceFluctuationRatio = CurrencyUtil.div(priceDetailDTO.getOriginalPrice(), order.getPriceDetailDTO().getOriginalPrice());
@ -161,13 +168,14 @@ public class OrderPriceServiceImpl implements OrderPriceService {
priceDetailDTO.setFlowPrice(flowPrice);
//计算平台佣金=交易金额*分类佣金比例/100
Double platFormCommission = CurrencyUtil.div(CurrencyUtil.mul(flowPrice, categoryService.getById(orderItem.getCategoryId()).getCommissionRate()), 100);
priceDetailDTO.setPlatFormCommission(platFormCommission);
//修改订单货物金额
orderItem.setFlowPrice(flowPrice);
orderItem.setUnitPrice(CurrencyUtil.div(flowPrice,orderItem.getNum()));
priceDetailDTO.countBill();
orderItem.setPriceDetail(JSONUtil.toJsonStr(priceDetailDTO));
orderItemService.update(orderItem, new LambdaUpdateWrapper<OrderItem>().eq(OrderItem::getId, orderItem.getId()));

View File

@ -57,10 +57,10 @@ public interface SeckillApplyService extends IService<SeckillApply> {
void addSeckillApply(String seckillId, String storeId, List<SeckillApplyVO> seckillApplyList);
/**
* 批量删除秒杀活动申请
* 批量删除秒杀活动商品
*
* @param seckillId 秒杀活动活动id
* @param ids 秒杀活动申请id集合
* @param id 秒杀活动商品
*/
void removeSeckillApplyByIds(String seckillId, List<String> ids);
void removeSeckillApply(String seckillId, String id );
}

View File

@ -25,6 +25,7 @@ import cn.lili.modules.promotion.service.SeckillApplyService;
import cn.lili.modules.promotion.service.SeckillService;
import cn.lili.modules.promotion.tools.PromotionCacheKeys;
import cn.lili.modules.promotion.tools.PromotionTools;
import cn.lili.modules.search.service.EsGoodsIndexService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -74,6 +75,11 @@ public class SeckillApplyServiceImpl extends ServiceImpl<SeckillApplyMapper, Sec
*/
@Autowired
private SeckillService seckillService;
/**
* 商品索引
*/
@Autowired
private EsGoodsIndexService goodsIndexService;
@Override
public List<SeckillTimelineVO> getSeckillTimeline() {
@ -201,20 +207,31 @@ public class SeckillApplyServiceImpl extends ServiceImpl<SeckillApplyMapper, Sec
* 批量删除秒杀活动申请
*
* @param seckillId 秒杀活动活动id
* @param ids 秒杀活动申请id集合
* @param id 秒杀活动申请id
*/
@Override
public void removeSeckillApplyByIds(String seckillId, List<String> ids) {
public void removeSeckillApply(String seckillId, String id) {
SeckillVO seckillVO = this.mongoTemplate.findById(seckillId, SeckillVO.class);
if (seckillVO == null) {
throw new ServiceException(ResultCode.SECKILL_NOT_EXIST_ERROR);
}
if (seckillVO.getPromotionStatus().equals(PromotionStatusEnum.START.name())) {
throw new ServiceException(ResultCode.SECKILL_UPDATE_ERROR);
}
seckillVO.getSeckillApplyList().removeIf(seckillApply -> ids.contains(seckillApply.getId()));
SeckillApply seckillApply = this.getById(id);
//获取商品SKUID
String skuId = seckillApply.getSkuId();
//清除秒杀活动中的商品
seckillVO.getSeckillApplyList().removeIf(seckillApply1 -> id.contains(seckillApply1.getId()));
this.mongoTemplate.save(seckillVO);
this.removeByIds(ids);
//删除促销商品
this.removeById(id);
//清除索引
this.goodsIndexService.deleteEsGoodsPromotionByPromotionId(skuId, seckillId);
//删除促销商品
promotionGoodsService.remove(new LambdaQueryWrapper<PromotionGoods>()
.eq(PromotionGoods::getSkuId, skuId)
.eq(PromotionGoods::getPromotionType, PromotionTypeEnum.SECKILL.name()));
}
/**
@ -247,48 +264,6 @@ public class SeckillApplyServiceImpl extends ServiceImpl<SeckillApplyMapper, Sec
}
}
/**
* 组装促销商品信息
*
* @param seckillApply 秒杀活动申请信息
* @param seckillStartTime 当前秒杀活动申请的开始时间
* @return 促销商品信息
*/
private PromotionGoods setPromotionGoods(SeckillApply seckillApply, Date seckillStartTime) {
PromotionGoods promotionGoods = new PromotionGoods();
promotionGoods.setTitle("秒杀活动");
promotionGoods.setSkuId(seckillApply.getSkuId());
promotionGoods.setPromotionType(PromotionTypeEnum.SECKILL.name());
promotionGoods.setPromotionId(seckillApply.getSeckillId());
promotionGoods.setPrice(seckillApply.getPrice());
promotionGoods.setNum(seckillApply.getQuantity());
promotionGoods.setStoreId(seckillApply.getStoreId());
promotionGoods.setPromotionStatus(PromotionStatusEnum.NEW.name());
//商品活动的开始时间为当前商品的参加时间段
int timeLine = seckillApply.getTimeLine();
String date = cn.lili.common.utils.DateUtil.toString(seckillStartTime, cn.lili.common.utils.DateUtil.STANDARD_DATE_FORMAT);
long startTime = cn.lili.common.utils.DateUtil.getDateline(date + " " + timeLine + ":00:00", cn.lili.common.utils.DateUtil.STANDARD_FORMAT);
long endTime = cn.lili.common.utils.DateUtil.getDateline(date + " 23:59:59", cn.lili.common.utils.DateUtil.STANDARD_FORMAT);
promotionGoods.setStartTime(new Date(startTime));
promotionGoods.setEndTime(new Date(endTime));
return promotionGoods;
}
/**
* 检查缓存中是否存在相同商品参与的秒杀活动活动
*
* @param startTime 秒杀活动开始时间
*/
private void checkCache(Long startTime) {
String seckillCacheKey = PromotionCacheKeys.getSeckillTimelineKey(cn.lili.common.utils.DateUtil.toString(startTime, cn.lili.common.utils.DateUtil.STANDARD_DATE_NO_UNDERLINE_FORMAT));
Map<Object, Object> hash = cache.getHash(seckillCacheKey);
//如果缓存中存在当前审核商品参与的秒杀活动活动商品信息清除
if (hash != null && !hash.isEmpty()) {
cache.remove(seckillCacheKey);
}
}
/**
* 从缓存中获取秒杀活动信息
*

View File

@ -0,0 +1,32 @@
package cn.lili.modules.store.entity.vos;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* 店铺其他信息
* @author Bulbasaur
* @date: 2021/8/11 3:42 下午
*
*/
@Data
public class StoreOtherVO {
@ApiModelProperty(value = "公司名称")
private String companyName;
@ApiModelProperty(value = "公司地址")
private String companyAddress;
@ApiModelProperty(value = "公司地址地区")
private String companyAddressPath;
@ApiModelProperty(value = "营业执照电子版")
private String licencePhoto;
@ApiModelProperty(value = "法定经营范围")
private String scope;
@ApiModelProperty(value = "员工总数")
private Integer employeeNum;
}

View File

@ -6,6 +6,7 @@ import cn.lili.modules.store.entity.dto.StoreAfterSaleAddressDTO;
import cn.lili.modules.store.entity.dto.StoreSettlementDay;
import cn.lili.modules.store.entity.vos.StoreBasicInfoVO;
import cn.lili.modules.store.entity.vos.StoreDetailVO;
import cn.lili.modules.store.entity.vos.StoreOtherVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
@ -79,4 +80,12 @@ public interface StoreDetailMapper extends BaseMapper<StoreDetail> {
*/
@Update("UPDATE li_store_detail SET settlement_day=#{dateTime} WHERE store_id=#{storeId}")
void updateSettlementDay(String storeId, DateTime dateTime);
/**
* 查看店铺营业执照信息
* @param storeId 店铺ID
* @return 店铺营业执照
*/
@Select("SELECT * FROM li_store_detail WHERE store_id=#{storeId}")
StoreOtherVO getLicencePhoto(String storeId);
}

View File

@ -5,6 +5,7 @@ import cn.lili.modules.store.entity.dto.StoreAfterSaleAddressDTO;
import cn.lili.modules.store.entity.dto.StoreSettingDTO;
import cn.lili.modules.store.entity.vos.StoreBasicInfoVO;
import cn.lili.modules.store.entity.vos.StoreDetailVO;
import cn.lili.modules.store.entity.vos.StoreOtherVO;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
@ -95,4 +96,12 @@ public interface StoreDetailService extends IService<StoreDetail> {
* @return 店铺经营范围
*/
List goodsManagementCategory(String storeId);
/**
* 获取店铺其他信息
*
* @param storeId 店铺ID
* @return 店铺其他信息
*/
StoreOtherVO getStoreOtherVO(String storeId);
}

View File

@ -12,6 +12,7 @@ import cn.lili.modules.store.entity.dto.StoreSettingDTO;
import cn.lili.modules.store.entity.vos.StoreBasicInfoVO;
import cn.lili.modules.store.entity.vos.StoreDetailVO;
import cn.lili.modules.store.entity.vos.StoreManagementCategoryVO;
import cn.lili.modules.store.entity.vos.StoreOtherVO;
import cn.lili.modules.store.mapper.StoreDetailMapper;
import cn.lili.modules.store.service.StoreDetailService;
import cn.lili.modules.store.service.StoreService;
@ -134,4 +135,11 @@ public class StoreDetailServiceImpl extends ServiceImpl<StoreDetailMapper, Store
return list;
}
@Override
public StoreOtherVO getStoreOtherVO(String storeId) {
StoreOtherVO storeOtherVO=this.baseMapper.getLicencePhoto(storeId);
return storeOtherVO;
}
}

View File

@ -96,4 +96,12 @@ public class SeckillManagerController {
return ResultUtil.data(seckillApply);
}
@DeleteMapping("/apply/{seckillId}/{id}")
@ApiOperation(value = "删除秒杀活动申请")
public ResultMessage<String> deleteSeckillApply(@PathVariable String seckillId, @PathVariable String id) {
seckillApplyService.removeSeckillApply(seckillId, id);
return ResultUtil.success();
}
}

View File

@ -1,8 +1,7 @@
package cn.lili.controller.promotion;
import cn.lili.common.enums.ResultCode;
import cn.lili.common.security.context.UserContext;
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.security.context.UserContext;
import cn.lili.common.vo.PageVO;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.promotion.entity.dos.Seckill;
@ -18,7 +17,6 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.Arrays;
import java.util.List;
/**
@ -72,11 +70,10 @@ public class SeckillStoreController {
return ResultUtil.success();
}
@DeleteMapping("/apply/{seckillId}/{ids}")
@ApiOperation(value = "删除秒杀活动申请")
public ResultMessage<String> deleteSeckillApply(@PathVariable("seckillId") String seckillId, @PathVariable("ids") String ids) {
String[] idsSplit = ids.split(",");
seckillApplyService.removeSeckillApplyByIds(seckillId, Arrays.asList(idsSplit));
@DeleteMapping("/apply/{seckillId}/{id}")
@ApiOperation(value = "删除秒杀活动商品")
public ResultMessage<String> deleteSeckillApply(@PathVariable String seckillId,@PathVariable String id) {
seckillApplyService.removeSeckillApply(seckillId, id);
return ResultUtil.success();
}