| | |
| | | import com.mzl.flower.config.security.SecurityUtils; |
| | | import com.mzl.flower.constant.Constants; |
| | | import com.mzl.flower.dto.PriceDTO; |
| | | import com.mzl.flower.dto.request.menber.MemberGrowthRecordDTO; |
| | | import com.mzl.flower.dto.request.payment.*; |
| | | import com.mzl.flower.dto.response.flower.FlowerCartListDTO; |
| | | import com.mzl.flower.dto.response.flower.FlowerCartListWrapDTO; |
| | |
| | | import com.mzl.flower.mapper.warehouse.WarehouseLocationMapper; |
| | | import com.mzl.flower.service.BaseService; |
| | | import com.mzl.flower.service.flower.FlowerService; |
| | | import com.mzl.flower.service.menber.MemberGrowthRecordService; |
| | | import com.mzl.flower.service.point.CustomerPointService; |
| | | import com.mzl.flower.service.system.CodeService; |
| | | import com.mzl.flower.service.system.WeChatService; |
| | | import com.mzl.flower.service.transport.TransportService; |
| | |
| | | import me.chanjar.weixin.common.error.WxErrorException; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.context.annotation.Lazy; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | private OrderItemCheckMapper orderItemCheckMapper; |
| | | |
| | | @Autowired |
| | | private OrderPointGoodsMapper pointGoodsMapper; |
| | | |
| | | @Autowired |
| | | @Lazy |
| | | private MemberGrowthRecordService memberGrowthRecordService; |
| | | |
| | | @Autowired |
| | | private CustomerPointService customerPointService; |
| | | |
| | | public void changeFlower2Cart(CartSaveDTO dto) { |
| | | String userId = SecurityUtils.getUserId(); |
| | |
| | | } |
| | | |
| | | Address address = addressMapper.selectById(dto.getAddressId()); |
| | | List<TransportOrderDTO> tLs = transportService.getPreOrderTransportList(address, p.getTotalWeight(), dto.getTransportId()); |
| | | List<TransportOrderDTO> tLs = transportService.getPreOrderTransportList(address |
| | | , p.getTotalWeight(), dto.getTransportId()); |
| | | BigDecimal transportFee = new BigDecimal(0); |
| | | String deliveryName = ""; |
| | | if (tLs != null && tLs.size() > 0) { |
| | |
| | | String userId = SecurityUtils.getUserId(); |
| | | Order order = new Order(); |
| | | order.setId(UUIDGenerator.getUUID()); |
| | | |
| | | final List<Long> goodsRecordIdList = dto.getGoodsRecordIdList(); |
| | | usePointGoods(order.getId(), goodsRecordIdList);//使用积分商品兑换券 |
| | | |
| | | order.create(userId); |
| | | order.setRemarks(dto.getRemarks()); |
| | | order.setSpecialNeeds(dto.getSpecialNeeds()); |
| | |
| | | //商品列表处理 |
| | | List<FlowerCartListDTO> flowers = p.getFlowers(); |
| | | Map<Long, List<ParamItemDTO>> paramMap = new HashMap<>(); |
| | | BigDecimal flowerAmount = order.getFlowerAmount();//订单商品总价 |
| | | final BigDecimal flowerAmount = order.getFlowerAmount();//订单商品总价 |
| | | final BigDecimal memberCouponAmount = order.getMemberCouponAmount();//使用优惠券面值 |
| | | for (FlowerCartListDTO f : flowers) { |
| | | OrderItem t = new OrderItem(); |
| | | t.setId(UUIDGenerator.getUUID()); |
| | |
| | | t.setTotal(f.getTotalMember());//使用会员总价 |
| | | |
| | | t.setOriginalPrice(pp.getPrice());//非会员售价 |
| | | BigDecimal couponAmount = calculateCoupon(order.getMemberCouponAmount() |
| | | , t.getTotal(), order.getFlowerAmount(), t.getNum()); |
| | | BigDecimal couponAmount = calculateCoupon(memberCouponAmount, t.getTotal(), flowerAmount, t.getNum()); |
| | | t.setCouponAmount(couponAmount);//每扎平摊的优惠券面值 |
| | | t.setRealPrice(t.getPrice().subtract(couponAmount));//退款时使用的真实成交价 |
| | | |
| | |
| | | order.setPayOpenid(openId); |
| | | orderMapper.insert(order); |
| | | |
| | | //TODO 处理积分商品兑换券 |
| | | //处理积分商品兑换券 |
| | | if(goodsRecordIdList != null && goodsRecordIdList.size() > 0){ |
| | | for(Long goodsRecordId : goodsRecordIdList){ |
| | | OrderPointGoods g = new OrderPointGoods(); |
| | | g.setId(UUIDGenerator.getUUID()); |
| | | g.setOrderId(order.getId()); |
| | | g.setGoodsRecordId(goodsRecordId); |
| | | g.create(userId); |
| | | pointGoodsMapper.insert(g); |
| | | } |
| | | } |
| | | |
| | | Map map = paymentV3Service.wxPrepay(order); |
| | | map.put("_testV2OrderId", order.getId()); |
| | | return map; |
| | | } |
| | | |
| | | private void usePointGoods(String orderId, List<Long> goodsRecordIdList){ |
| | | //TODO 使用积分商品兑换券 |
| | | } |
| | | |
| | | /** |
| | |
| | | boolean couldCheckRefund = StringUtils.isEmpty(transferId) && count == 0 && cc == 0; |
| | | dto.setCouldCheckRefund(couldCheckRefund); |
| | | |
| | | List<OrderPointGoodsListDTO> pointGoodsList = orderMapper.getPointGoodsList(id); |
| | | dto.setPointGoodsList(pointGoodsList); |
| | | |
| | | return dto; |
| | | } |
| | | |
| | |
| | | return result; |
| | | } |
| | | |
| | | public void autoReceive() { |
| | | public List<Order> autoReceive() { |
| | | int days = -5; //5天前的订单自动收货 |
| | | LocalDateTime endTime = LocalDateTime.now().plusDays(days); |
| | | List<Order> ls = orderMapper.getOrderForAutoReceive(endTime); |
| | | if (ls == null || ls.size() == 0) { |
| | | return; |
| | | return ls; |
| | | } |
| | | |
| | | for (Order o : ls) { |
| | |
| | | o.setReceiveTime(LocalDateTime.now()); |
| | | o.update("sys"); |
| | | orderMapper.updateById(o); |
| | | |
| | | } |
| | | |
| | | return ls; |
| | | } |
| | | |
| | | public void processAfterReceive(Order o){ |
| | | String status = o.getStatus(); |
| | | if(!Constants.ORDER_STATUS.EVALUATE.name().equals(status)){ |
| | | log.warn("订单未确认收货,无法处理积分和成长值"); |
| | | return; |
| | | } |
| | | |
| | | BigDecimal totalAmount = o.getTotalAmount(); |
| | | List<OrderItemCheck> checkList = orderItemCheckMapper.selectList(new QueryWrapper<OrderItemCheck>() |
| | | .eq("order_id", o.getId()) |
| | | .eq("audit_status", Constants.CHECK_AUDIT_STATUS.AGREED.name()) |
| | | ); |
| | | |
| | | if(checkList != null && checkList.size() > 0){ |
| | | for(OrderItemCheck c : checkList){ |
| | | totalAmount = totalAmount.subtract(getAmount(c.getDeductAmount())); |
| | | } |
| | | } |
| | | |
| | | //成长值计算 |
| | | MemberGrowthRecordDTO mDto = new MemberGrowthRecordDTO(); |
| | | mDto.setTotalAmount(totalAmount); |
| | | mDto.setUserId(o.getCreateBy()); |
| | | mDto.setSource(Constants.GROWTH_SOURCE.consume.name()); |
| | | mDto.setType(Constants.GROWTH_TYPE.add.name()); |
| | | mDto.setRemarks("订单: " + o.getOrderNo()); |
| | | memberGrowthRecordService.saveMemberGrowthRecord(mDto); |
| | | |
| | | //积分计算 |
| | | customerPointService.consumptionPoint(totalAmount, o.getOrderNo(), o.getCreateBy()); |
| | | } |
| | | |
| | | public JSONObject sendWxDeliveryGood(Order o) { |
| | |
| | | } |
| | | } |
| | | |
| | | public void confirmOrderReceive(String id) { |
| | | public Order confirmOrderReceive(String id) { |
| | | Order o = orderMapper.selectById(id); |
| | | String userId = SecurityUtils.getUserId(); |
| | | if (!userId.equals(o.getCreateBy())) { |
| | |
| | | o.setReceiveTime(LocalDateTime.now()); |
| | | o.update(userId); |
| | | orderMapper.updateById(o); |
| | | |
| | | return o; |
| | | } |
| | | |
| | | public Integer getMyOrderStatusCount(String status) { |