同步master

This commit is contained in:
lifenlong 2021-06-17 11:15:56 +08:00
commit 67e31bff07
5 changed files with 44 additions and 27 deletions

View File

@ -165,6 +165,7 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
Category parentCategory = this.getById(category.getParentId());
category.setDeleteFlag(parentCategory.getDeleteFlag());
}
this.save(category);
removeCache();
return true;
}

View File

@ -13,8 +13,17 @@ public enum OrderTypeEnum {
*/
NORMAL,
/**
* 赠品订单
*/
GIFT,
/**
* 虚拟订单
*/
VIRTUAL;
VIRTUAL,
/**
* 拼团订单
*/
PINTUAN
}

View File

@ -129,38 +129,43 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
public void intoDB(TradeDTO tradeDTO) {
//检查TradeDTO信息
checkTradeDTO(tradeDTO);
//订单列表
//存放购物车即业务中的订单
List<Order> orders = new ArrayList<>(tradeDTO.getCartList().size());
//订单日志
List<OrderLog> orderLogs = new ArrayList<>(tradeDTO.getCartList().size());
//订单VO列表
List<OrderVO> OrderVOList = new ArrayList<>(tradeDTO.getCartList().size());
//订单货物列表
//存放自订单/订单日志
List<OrderItem> orderItems = new ArrayList<>();
//循环交易货物列表新增订单
List<OrderLog> orderLogs = new ArrayList<>();
//拼团判定不能参与自己创建的拼团
if (tradeDTO.getParentOrderSn() != null) {
Order parentOrder = this.getBySn(tradeDTO.getParentOrderSn());
if (parentOrder.getMemberId().equals(UserContext.getCurrentUser().getId())) {
throw new ServiceException("不能参与自己发起的拼团活动!");
}
}
//订单集合
List<OrderVO> orderVOS = new ArrayList<>();
//循环购物车商品集合
tradeDTO.getCartList().forEach(item -> {
//构建订单
Order order = new Order(item, tradeDTO);
//检查订单信息
checkOrder(order);
//新建订单
if (OrderTypeEnum.PINTUAN.name().equals(order.getOrderType())) {
Pintuan pintuan = pintuanService.getPintuanById(order.getPromotionId());
Integer limitNum = pintuan.getLimitNum();
if (limitNum != 0 && order.getGoodsNum() > limitNum) {
throw new ServiceException("购买数量超过拼团活动限制数量");
}
}
//构建orderVO对象
OrderVO orderVO = new OrderVO();
BeanUtil.copyProperties(order, orderVO);
orders.add(order);
//记录订单日志
orderLogs.add(new OrderLog(item.getSn(),
UserContext.getCurrentUser().getId(),
UserContext.getCurrentUser().getRole().getRole(),
UserContext.getCurrentUser().getUsername(), "订单[" + item.getSn() + "]创建"));
//添加订单货物
String message = "订单[" + item.getSn() + "]创建";
orderLogs.add(new OrderLog(item.getSn(), UserContext.getCurrentUser().getId(), UserContext.getCurrentUser().getRole().getRole(), UserContext.getCurrentUser().getUsername(), message));
item.getSkuList().forEach(
sku -> orderItems.add(new OrderItem(sku, item, tradeDTO))
);
//构建orderVO对象
OrderVO orderVO = new OrderVO(order, orderItems);
OrderVOList.add(orderVO);
orderVO.setOrderItems(orderItems);
orderVOS.add(orderVO);
});
tradeDTO.setOrderVO(OrderVOList);
tradeDTO.setOrderVO(orderVOS);
//批量保存订单
this.saveBatch(orders);
//批量保存 子订单
@ -168,7 +173,6 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
// 批量记录订单操作日志
orderLogService.saveBatch(orderLogs);
// 赠品根据店铺单独生成订单
//todo 优化赠品订单代码逻辑
this.generatorGiftOrder(tradeDTO);
}

View File

@ -13,6 +13,7 @@ import com.alipay.api.request.AlipayTradePrecreateRequest;
import com.alipay.api.request.AlipayTradeWapPayRequest;
import com.alipay.api.response.AlipayTradeAppPayResponse;
import com.alipay.api.response.AlipayTradePrecreateResponse;
import lombok.extern.slf4j.Slf4j;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@ -24,7 +25,7 @@ import java.io.PrintWriter;
* @author Chopper
* @date 2020/12/15 19:26
*/
@Slf4j
public class AliPayRequest {
/**
@ -40,7 +41,7 @@ public class AliPayRequest {
public static void wapPay(HttpServletResponse response, AlipayTradeWapPayModel model, String returnUrl, String notifyUrl) throws AlipayApiException, IOException {
String form = wapPayStr(model, returnUrl, notifyUrl);
response.setContentType("text/html;charset=UTF-8");
log.info("支付表单{}", form);
PrintWriter out = response.getWriter();
out.write(form);
out.flush();

View File

@ -2,6 +2,7 @@ package cn.lili.controller.setting;
import cn.lili.common.enums.ResultUtil;
import cn.lili.common.vo.ResultMessage;
import cn.lili.modules.base.aspect.DemoSite;
import cn.lili.modules.base.service.RegionService;
import cn.lili.modules.system.entity.dos.Region;
import io.swagger.annotations.Api;
@ -29,6 +30,7 @@ public class RegionManagerController {
@Autowired
private RegionService regionService;
@DemoSite
@PostMapping(value = "/sync")
@ApiOperation(value = "同步高德行政地区数据")
public void synchronizationData(String url) {