| | |
| | | import cn.hutool.core.util.StrUtil; |
| | | import cn.hutool.json.JSONObject; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.enums.SqlLike; |
| | | import com.baomidou.mybatisplus.mapper.Condition; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | |
| | | import com.sinata.modular.system.service.IRoleService; |
| | | import java.util.Map; |
| | | import java.util.Set; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | * |
| | | * @author goku |
| | | */ |
| | | @Slf4j |
| | | @Controller |
| | | @RequestMapping("/mallOrder") |
| | | public class MallOrderController extends BaseController { |
| | |
| | | ); |
| | | order.setRefundPrice(refundPrice); |
| | | order.setRefundTime(new Date()); |
| | | } |
| | | |
| | | this.mallOrderService.updateById(order); |
| | | //退回库存 |
| | | List<MallOrderDetail> orderDetailList = this.mallOrderDetailService.selectList(new EntityWrapper<MallOrderDetail>().eq("order_no", orderNo)); |
| | | log.info("----------------------------处理退款回退库存--------------------------"); |
| | | log.info("orderDetailList:{}", JSON.toJSONString(orderDetailList)); |
| | | if (CollectionUtils.isNotEmpty(orderDetailList)) { |
| | | Map<Integer, MallOrderDetail> orderDetailMap = orderDetailList.stream() |
| | | .collect(Collectors.toMap(MallOrderDetail::getSkuId, e -> e)); |
| | |
| | | mallGoodsSku.setStock(mallGoodsSku.getStock() + mallOrderDetail.getGoodsNum()); |
| | | mallGoodsSkuService.updateById(mallGoodsSku); |
| | | } |
| | | //退销量 |
| | | Set<Integer> goodsIdList = orderDetailList.stream().map(MallOrderDetail::getGoodsId) |
| | | .collect(Collectors.toSet()); |
| | | Wrapper<MallGoods> wrapper = new EntityWrapper<MallGoods>().in("id", goodsIdList); |
| | | List<MallGoods> mallGoods = mallGoodsService.selectList(wrapper); |
| | | Map<Integer, MallOrderDetail> orderDetailMap2 = orderDetailList.stream() |
| | | .collect(Collectors.toMap(MallOrderDetail::getGoodsId, e -> e)); |
| | | if (CollectionUtils.isNotEmpty(mallGoods)) { |
| | | for (MallGoods mallGoods1 : mallGoods) { |
| | | MallOrderDetail mallOrderDetail1 = orderDetailMap2.get(mallGoods1.getId()); |
| | | if (Objects.nonNull(mallOrderDetail1)) { |
| | | log.info("----------------------------处理退款回退销量--------------------------"); |
| | | log.info("mallGoods1:{}", JSON.toJSONString(mallGoods1)); |
| | | mallGoods1.setBuyCount(mallGoods1.getBuyCount() - mallOrderDetail1.getGoodsNum()); |
| | | mallGoodsService.updateById(mallGoods1); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | this.mallOrderService.updateById(order); |
| | | |
| | | return SUCCESS_TIP; |
| | | } |
| | | } |