|
|
@@ -43,6 +43,7 @@ import com.fs.his.param.*;
|
|
|
import com.fs.his.service.*;
|
|
|
import com.fs.his.utils.ConfigUtil;
|
|
|
import com.fs.his.utils.PhoneUtil;
|
|
|
+import com.fs.his.utils.RedisCacheUtil;
|
|
|
import com.fs.his.vo.*;
|
|
|
import com.fs.qw.domain.QwUser;
|
|
|
import com.fs.qw.mapper.QwUserMapper;
|
|
|
@@ -163,7 +164,7 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
private IFsUserAddressService fsUserAddressService;
|
|
|
|
|
|
@Autowired
|
|
|
- private com.fs.his.utils.RedisCacheUtil redisCacheUtil;
|
|
|
+ private RedisCacheUtil redisCacheUtil;
|
|
|
/**
|
|
|
* 查询积分商品订单
|
|
|
*
|
|
|
@@ -487,7 +488,14 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
// 清除商品列表缓存
|
|
|
redisCacheUtil.delRedisKey("getIntegralGoodsList");
|
|
|
|
|
|
- return createOrder(user, address, totalIntegral, totalCash, goodsItem, null);
|
|
|
+ // 创建订单
|
|
|
+ R result = createOrder(user, address, totalIntegral, totalCash, goodsItem, null);
|
|
|
+
|
|
|
+ // 订单创建成功后,删除购物车中已下单的商品
|
|
|
+ if (result.get("code").equals(200)) {
|
|
|
+ cartService.delCartByIds(user.getUserId(), param.getIds());
|
|
|
+ }
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -579,8 +587,9 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
public R cannelOrder(Long orderId) {
|
|
|
// 取消订单
|
|
|
FsIntegralOrder order = fsIntegralOrderMapper.selectFsIntegralOrderByOrderId(orderId);
|
|
|
- if (!order.getStatus().equals(4)){
|
|
|
- return R.error("非法操作");
|
|
|
+ // 允许取消待支付(4)和待发货(1)的订单
|
|
|
+ if (!order.getStatus().equals(4) && !order.getStatus().equals(1)){
|
|
|
+ return R.error("非法操作,只能取消待支付或待发货的订单");
|
|
|
}
|
|
|
|
|
|
order.setStatus(5);
|
|
|
@@ -593,32 +602,32 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
fsIntegralGoodsMapper.addStock(goods.getGoodsId(), Objects.isNull(goods.getNum()) ? 1 : goods.getNum());
|
|
|
// 清除商品缓存
|
|
|
redisCacheUtil.delSpringCacheKey("getIntegralGoodsById", goods.getGoodsId());
|
|
|
- log.info("取消订单还原库存,清除商品缓存, goodsId: {}", goods.getGoodsId());
|
|
|
});
|
|
|
} else {
|
|
|
FsIntegralGoods integralGoods = JSONUtil.toBean(order.getItemJson(), FsIntegralGoods.class);
|
|
|
fsIntegralGoodsMapper.addStock(integralGoods.getGoodsId(), Objects.isNull(integralGoods.getNum()) ? 1 : integralGoods.getNum());
|
|
|
// 清除商品缓存
|
|
|
redisCacheUtil.delSpringCacheKey("getIntegralGoodsById", integralGoods.getGoodsId());
|
|
|
- log.info("取消订单还原库存,清除商品缓存, goodsId: {}", integralGoods.getGoodsId());
|
|
|
}
|
|
|
// 清除商品列表缓存
|
|
|
redisCacheUtil.delRedisKey("getIntegralGoodsList");
|
|
|
|
|
|
- // 还原积分
|
|
|
- FsUser user=fsUserMapper.selectFsUserByUserId(order.getUserId());
|
|
|
- FsUser userMap=new FsUser();
|
|
|
- userMap.setUserId(user.getUserId());
|
|
|
- userMap.setIntegral(user.getIntegral() + Long.parseLong(order.getIntegral()));
|
|
|
- fsUserMapper.updateFsUser(userMap);
|
|
|
- FsUserIntegralLogs logs = new FsUserIntegralLogs();
|
|
|
- logs.setIntegral(Long.parseLong(order.getIntegral()));
|
|
|
- logs.setUserId(order.getUserId());
|
|
|
- logs.setBalance(userMap.getIntegral());
|
|
|
- logs.setLogType(5);
|
|
|
- logs.setBusinessId(order.getOrderId().toString());
|
|
|
- logs.setCreateTime(new Date());
|
|
|
- fsUserIntegralLogsMapper.insertFsUserIntegralLogs(logs);
|
|
|
+ // 还原积分(只有当订单消耗了积分时才退还)
|
|
|
+ if (StringUtils.isNotEmpty(order.getIntegral()) && Long.parseLong(order.getIntegral()) > 0) {
|
|
|
+ FsUser user=fsUserMapper.selectFsUserByUserId(order.getUserId());
|
|
|
+ FsUser userMap=new FsUser();
|
|
|
+ userMap.setUserId(user.getUserId());
|
|
|
+ userMap.setIntegral(user.getIntegral() + Long.parseLong(order.getIntegral()));
|
|
|
+ fsUserMapper.updateFsUser(userMap);
|
|
|
+ FsUserIntegralLogs logs = new FsUserIntegralLogs();
|
|
|
+ logs.setIntegral(Long.parseLong(order.getIntegral()));
|
|
|
+ logs.setUserId(order.getUserId());
|
|
|
+ logs.setBalance(userMap.getIntegral());
|
|
|
+ logs.setLogType(5);
|
|
|
+ logs.setBusinessId(order.getOrderId().toString());
|
|
|
+ logs.setCreateTime(new Date());
|
|
|
+ fsUserIntegralLogsMapper.insertFsUserIntegralLogs(logs);
|
|
|
+ }
|
|
|
|
|
|
return R.ok();
|
|
|
}
|