Skip to content

Commit

Permalink
增加店铺企业信息接口
Browse files Browse the repository at this point in the history
增加删除商品
修复:修改订单金额售后金额不正确
  • Loading branch information
lifenlong committed Aug 11, 2021
1 parent dd7af21 commit 64e45c1
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 65 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,13 @@ public ResultMessage<StoreBasicInfoVO> detail(@NotNull @PathVariable String id)
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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public ResultMessage<Object> upload(MultipartFile file,
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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public class PriceDetailDTO implements Serializable {


public Double getOriginalPrice() {
if (originalPrice == null) {
if (originalPrice == 0D) {
return flowPrice;
}
return originalPrice;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public AfterSale review(String afterSaleSn, String serviceStatus, String remark,
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public Order updatePrice(String orderSn, Double orderPrice) {
Order order = updateOrderPrice(orderSn, orderPrice);

//修改订单货物金额
updateOrderItemPrice(order);
//updateOrderItemPrice(order);

//修改交易金额
tradeMapper.updateTradePrice(order.getTradeSn());
Expand Down Expand Up @@ -112,12 +112,16 @@ private Order updateOrderPrice(String orderSn, Double orderPrice) {
//获取订单价格信息
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);

//这里如果直接赋予订单金额,则累加可能会出现小数点,最后无法累加回去,所以用一个零时变量累加后,将平台佣金赋予对象
Expand Down Expand Up @@ -150,6 +154,9 @@ private List<OrderItem> updateOrderItemPrice(Order order) {
//获取订单货物价格信息
PriceDetailDTO priceDetailDTO = orderItem.getPriceDetailDTO();

if (priceDetailDTO.getOriginalPrice() == 0D) {
priceDetailDTO.setOriginalPrice(priceDetailDTO.getFlowPrice());
}
//SKU占总订单 金额的百分比
Double priceFluctuationRatio = CurrencyUtil.div(priceDetailDTO.getOriginalPrice(), order.getPriceDetailDTO().getOriginalPrice());

Expand All @@ -161,13 +168,14 @@ private List<OrderItem> updateOrderItemPrice(Order order) {

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()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
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;
Expand Down Expand Up @@ -74,6 +75,11 @@ public class SeckillApplyServiceImpl extends ServiceImpl<SeckillApplyMapper, Sec
*/
@Autowired
private SeckillService seckillService;
/**
* 商品索引
*/
@Autowired
private EsGoodsIndexService goodsIndexService;

@Override
public List<SeckillTimelineVO> getSeckillTimeline() {
Expand Down Expand Up @@ -201,20 +207,31 @@ public void addSeckillApply(String seckillId, String storeId, List<SeckillApplyV
* 批量删除秒杀活动申请
*
* @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()));
}

/**
Expand Down Expand Up @@ -247,48 +264,6 @@ private void checkSeckillApplyList(String hours, List<SeckillApplyVO> seckillApp
}
}

/**
* 组装促销商品信息
*
* @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);
}
}

/**
* 从缓存中获取秒杀活动信息
*
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
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;
Expand Down Expand Up @@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,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.StoreOtherVO;
import com.baomidou.mybatisplus.extension.service.IService;

import java.util.List;
Expand Down Expand Up @@ -95,4 +96,12 @@ public interface StoreDetailService extends IService<StoreDetail> {
* @return 店铺经营范围
*/
List goodsManagementCategory(String storeId);

/**
* 获取店铺其他信息
*
* @param storeId 店铺ID
* @return 店铺其他信息
*/
StoreOtherVO getStoreOtherVO(String storeId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
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;
Expand Down Expand Up @@ -134,4 +135,11 @@ public List goodsManagementCategory(String storeId) {
return list;
}

@Override
public StoreOtherVO getStoreOtherVO(String storeId) {

StoreOtherVO storeOtherVO=this.baseMapper.getLicencePhoto(storeId);
return storeOtherVO;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -96,4 +96,12 @@ public ResultMessage<IPage<SeckillApply>> getSeckillApply(SeckillSearchParams pa
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();
}


}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -18,7 +17,6 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;

/**
Expand Down Expand Up @@ -72,11 +70,10 @@ public ResultMessage<String> addSeckillApply(@PathVariable String seckillId, @Re
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();
}

Expand Down

0 comments on commit 64e45c1

Please sign in to comment.