|
@@ -3,9 +3,14 @@ package com.fs.hisStore.service.impl;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.exception.CustomException;
|
|
import com.fs.common.exception.CustomException;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
import com.fs.common.utils.DateUtils;
|
|
|
|
|
+import com.fs.his.domain.FsIntegralOrder;
|
|
|
|
|
+import com.fs.his.enums.FsUserIntegralLogTypeEnum;
|
|
|
|
|
+import com.fs.his.mapper.FsIntegralGoodsMapper;
|
|
|
|
|
+import com.fs.his.utils.RedisCacheUtil;
|
|
|
import com.fs.hisStore.domain.*;
|
|
import com.fs.hisStore.domain.*;
|
|
|
import com.fs.hisStore.mapper.*;
|
|
import com.fs.hisStore.mapper.*;
|
|
|
import com.fs.hisStore.param.FsIntegralOrderCreateParam;
|
|
import com.fs.hisStore.param.FsIntegralOrderCreateParam;
|
|
@@ -46,6 +51,10 @@ public class FsIntegralOrderScrmServiceImpl implements IFsIntegralOrderScrmServi
|
|
|
private FsIntegralGoodsScrmMapper fsIntegralGoodsMapper;
|
|
private FsIntegralGoodsScrmMapper fsIntegralGoodsMapper;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private FsUserIntegralLogsScrmMapper fsUserIntegralLogsMapper;
|
|
private FsUserIntegralLogsScrmMapper fsUserIntegralLogsMapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private FsIntegralGoodsMapper goodsMapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private RedisCacheUtil redisCacheUtil;
|
|
|
/**
|
|
/**
|
|
|
* 查询积分商品订单
|
|
* 查询积分商品订单
|
|
|
*
|
|
*
|
|
@@ -271,4 +280,41 @@ public class FsIntegralOrderScrmServiceImpl implements IFsIntegralOrderScrmServi
|
|
|
public FsIntegralOrderPVO selectFsIntegralOrderPVO(Long orderId) {
|
|
public FsIntegralOrderPVO selectFsIntegralOrderPVO(Long orderId) {
|
|
|
return fsIntegralOrderMapper.selectFsIntegralOrderPVO(orderId);
|
|
return fsIntegralOrderMapper.selectFsIntegralOrderPVO(orderId);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional
|
|
|
|
|
+ public R cancel(FsIntegralOrder params) {
|
|
|
|
|
+ FsUserScrm user = fsUserMapper.selectFsUserByUserId(params.getUserId());
|
|
|
|
|
+ FsIntegralOrderScrm order = fsIntegralOrderMapper.selectFsIntegralOrderByOrderId(params.getOrderId());
|
|
|
|
|
+ if (order.getStatus() != 1) {
|
|
|
|
|
+ return R.error("订单已发货,不能取消");
|
|
|
|
|
+ }
|
|
|
|
|
+ Long goodsId = JSON.parseArray(order.getItemJson()).getJSONObject(0).getLong("goodsId");
|
|
|
|
|
+ FsIntegralOrderScrm integralOrderScrm = new FsIntegralOrderScrm();
|
|
|
|
|
+ integralOrderScrm.setOrderId(order.getOrderId());
|
|
|
|
|
+ integralOrderScrm.setStatus(-1);
|
|
|
|
|
+ if (fsIntegralOrderMapper.updateFsIntegralOrder(integralOrderScrm) > 0){
|
|
|
|
|
+ // 写入日志
|
|
|
|
|
+ FsUserScrm fsUserScrm = new FsUserScrm();
|
|
|
|
|
+ fsUserScrm.setUserId(params.getUserId());
|
|
|
|
|
+ fsUserScrm.setIntegral(user.getIntegral() + Long.valueOf(order.getIntegral()));
|
|
|
|
|
+ fsUserMapper.updateFsUser(fsUserScrm);
|
|
|
|
|
+ FsUserIntegralLogsScrm logs = new FsUserIntegralLogsScrm();
|
|
|
|
|
+ logs.setIntegral(BigDecimal.valueOf(Long.valueOf(order.getIntegral())));
|
|
|
|
|
+ logs.setUserId(params.getUserId());
|
|
|
|
|
+ logs.setBalance(BigDecimal.valueOf(fsUserScrm.getIntegral()));
|
|
|
|
|
+ logs.setLogType(FsUserIntegralLogTypeEnum.TYPE_25.getValue());
|
|
|
|
|
+ logs.setBusinessId(order.getOrderId().toString());
|
|
|
|
|
+ logs.setCreateTime(new Date());
|
|
|
|
|
+ fsUserIntegralLogsMapper.insertFsUserIntegralLogs(logs);
|
|
|
|
|
+ // 加库存
|
|
|
|
|
+ goodsMapper.addStock(goodsId, 1);
|
|
|
|
|
+ // 清除商品缓存
|
|
|
|
|
+ redisCacheUtil.delSpringCacheKey("getIntegralGoodsById", goodsId);
|
|
|
|
|
+ redisCacheUtil.delRedisKey("getIntegralGoodsList");
|
|
|
|
|
+ return R.ok("取消成功");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ return R.error("取消失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|