|
|
@@ -94,8 +94,7 @@ import static com.fs.his.utils.PhoneUtil.decryptPhone;
|
|
|
*/
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
-public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
-{
|
|
|
+public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService {
|
|
|
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
|
|
|
@Autowired
|
|
|
private FsIntegralOrderMapper fsIntegralOrderMapper;
|
|
|
@@ -125,7 +124,7 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
@Autowired
|
|
|
private IFsStorePaymentService storePaymentService;
|
|
|
@Autowired
|
|
|
- private FsStorePaymentMapper storePaymentMapper;
|
|
|
+ private FsStorePaymentMapper storePaymentMapper;
|
|
|
@Autowired
|
|
|
private IFsIntegralCartService cartService;
|
|
|
@Autowired
|
|
|
@@ -182,6 +181,12 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
@Autowired
|
|
|
private FsCourseCheckinReceiveMapper fsCourseCheckinReceiveMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private FsUserCouponMapper fsUserCouponMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FsCouponMapper fsCouponMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
private RedisCacheUtil redisCacheUtil;
|
|
|
|
|
|
@@ -206,8 +211,7 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
* @return 积分商品订单
|
|
|
*/
|
|
|
@Override
|
|
|
- public FsIntegralOrder selectFsIntegralOrderByOrderId(Long orderId)
|
|
|
- {
|
|
|
+ public FsIntegralOrder selectFsIntegralOrderByOrderId(Long orderId) {
|
|
|
return fsIntegralOrderMapper.selectFsIntegralOrderByOrderId(orderId);
|
|
|
}
|
|
|
|
|
|
@@ -218,8 +222,7 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
* @return 积分商品订单
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<FsIntegralOrder> selectFsIntegralOrderList(FsIntegralOrder fsIntegralOrder)
|
|
|
- {
|
|
|
+ public List<FsIntegralOrder> selectFsIntegralOrderList(FsIntegralOrder fsIntegralOrder) {
|
|
|
return fsIntegralOrderMapper.selectFsIntegralOrderList(fsIntegralOrder);
|
|
|
}
|
|
|
|
|
|
@@ -230,8 +233,7 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int insertFsIntegralOrder(FsIntegralOrder fsIntegralOrder)
|
|
|
- {
|
|
|
+ public int insertFsIntegralOrder(FsIntegralOrder fsIntegralOrder) {
|
|
|
fsIntegralOrder.setCreateTime(DateUtils.getNowDate());
|
|
|
return fsIntegralOrderMapper.insertFsIntegralOrder(fsIntegralOrder);
|
|
|
}
|
|
|
@@ -243,8 +245,7 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int updateFsIntegralOrder(FsIntegralOrder fsIntegralOrder)
|
|
|
- {
|
|
|
+ public int updateFsIntegralOrder(FsIntegralOrder fsIntegralOrder) {
|
|
|
return fsIntegralOrderMapper.updateFsIntegralOrder(fsIntegralOrder);
|
|
|
}
|
|
|
|
|
|
@@ -255,8 +256,7 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int deleteFsIntegralOrderByOrderIds(Long[] orderIds)
|
|
|
- {
|
|
|
+ public int deleteFsIntegralOrderByOrderIds(Long[] orderIds) {
|
|
|
return fsIntegralOrderMapper.deleteFsIntegralOrderByOrderIds(orderIds);
|
|
|
}
|
|
|
|
|
|
@@ -267,8 +267,7 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int deleteFsIntegralOrderByOrderId(Long orderId)
|
|
|
- {
|
|
|
+ public int deleteFsIntegralOrderByOrderId(Long orderId) {
|
|
|
return fsIntegralOrderMapper.deleteFsIntegralOrderByOrderId(orderId);
|
|
|
}
|
|
|
|
|
|
@@ -282,10 +281,10 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
|
|
|
FsIntegralOrder order = fsIntegralOrderMapper.selectFsIntegralOrderByOrderId(fsIntegralOrder.getOrderId());
|
|
|
|
|
|
- if (order==null){
|
|
|
+ if (order == null) {
|
|
|
throw new CustomException("订单不存在");
|
|
|
}
|
|
|
- if (order.getStatus()!=1L){
|
|
|
+ if (order.getStatus() != 1L) {
|
|
|
throw new CustomException("非法更改");
|
|
|
}
|
|
|
FsIntegralOrder o1 = new FsIntegralOrder();
|
|
|
@@ -310,9 +309,9 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
@Transactional
|
|
|
public R createOrder(FsIntegralOrderCreateParam param) {
|
|
|
|
|
|
- FsUser user=fsUserMapper.selectFsUserByUserId(param.getUserId());
|
|
|
- FsUserAddress address=fsUserAddressMapper.selectFsUserAddressByAddressId(param.getAddressId());
|
|
|
- FsIntegralGoods integralGoods=fsIntegralGoodsMapper.selectFsIntegralGoodsByGoodsId(param.getGoodsId());
|
|
|
+ FsUser user = fsUserMapper.selectFsUserByUserId(param.getUserId());
|
|
|
+ FsUserAddress address = fsUserAddressMapper.selectFsUserAddressByAddressId(param.getAddressId());
|
|
|
+ FsIntegralGoods integralGoods = fsIntegralGoodsMapper.selectFsIntegralGoodsByGoodsId(param.getGoodsId());
|
|
|
if (Objects.isNull(user)) {
|
|
|
return R.error("用户不存在");
|
|
|
}
|
|
|
@@ -322,7 +321,7 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
if (Objects.isNull(integralGoods)) {
|
|
|
return R.error("商品不存在");
|
|
|
}
|
|
|
- if(integralGoods.getStock()<=0L){
|
|
|
+ if (integralGoods.getStock() <= 0L) {
|
|
|
return R.error("库存不足");
|
|
|
}
|
|
|
|
|
|
@@ -330,19 +329,19 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
BigDecimal totalCash = integralGoods.getCash();
|
|
|
Long activityId = param.getActivityId();
|
|
|
|
|
|
- if(param.getIsAPP() != null && param.getIsAPP() == 1){
|
|
|
+ if (param.getIsAPP() != null && param.getIsAPP() == 1) {
|
|
|
FsCourseCheckinPrize prizeQuery = new FsCourseCheckinPrize();
|
|
|
prizeQuery.setGoodsId(param.getGoodsId());
|
|
|
prizeQuery.setPrizeType(2);
|
|
|
List<FsCourseCheckinPrize> prizeList = fsCourseCheckinPrizeMapper.selectFsCourseCheckinPrizeList(prizeQuery);
|
|
|
- if(ObjectUtil.isNotEmpty(prizeList)){
|
|
|
+ if (ObjectUtil.isNotEmpty(prizeList)) {
|
|
|
FsCourseCheckinReceive receiveQuery = new FsCourseCheckinReceive();
|
|
|
receiveQuery.setUserId(param.getUserId());
|
|
|
receiveQuery.setActivityId(param.getActivityId());
|
|
|
receiveQuery.setGoodsId(param.getGoodsId());
|
|
|
receiveQuery.setReceiveStatus(0);
|
|
|
List<FsCourseCheckinReceive> receiveList = fsCourseCheckinReceiveMapper.selectFsCourseCheckinReceiveList(receiveQuery);
|
|
|
- if(ObjectUtil.isNotEmpty(receiveList)){
|
|
|
+ if (ObjectUtil.isNotEmpty(receiveList)) {
|
|
|
totalIntegral = 0L;
|
|
|
totalCash = BigDecimal.ZERO;
|
|
|
activityId = param.getActivityId();
|
|
|
@@ -350,7 +349,7 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(totalIntegral > 0 && user.getIntegral() < totalIntegral){
|
|
|
+ if (totalIntegral > 0 && user.getIntegral() < totalIntegral) {
|
|
|
return R.error("积分不足");
|
|
|
}
|
|
|
|
|
|
@@ -372,15 +371,15 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
/**
|
|
|
* 创建订单
|
|
|
*/
|
|
|
- private R createOrder(FsUser user, FsUserAddress address, Long totalIntegral, BigDecimal totalCash, List<FsIntegralGoods> goodsItem, Long companyUserId,Long goodsId,Long activityId) {
|
|
|
+ private R createOrder(FsUser user, FsUserAddress address, Long totalIntegral, BigDecimal totalCash, List<FsIntegralGoods> goodsItem, Long companyUserId, Long goodsId, Long activityId) {
|
|
|
FsIntegralOrder order = new FsIntegralOrder();
|
|
|
String orderSn = null;
|
|
|
- try{
|
|
|
+ try {
|
|
|
orderSn = OrderCodeUtils.getOrderSn();
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
orderSn = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
|
}
|
|
|
- if(StringUtils.isEmpty(orderSn)){
|
|
|
+ if (StringUtils.isEmpty(orderSn)) {
|
|
|
throw new CustomException("订单生成失败,请重试");
|
|
|
}
|
|
|
|
|
|
@@ -406,31 +405,31 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
order.setIntegral(totalIntegral.toString());
|
|
|
order.setItemJson(JSONUtil.toJsonStr(goodsItem));
|
|
|
order.setUserName(address.getRealName());
|
|
|
- order.setUserAddress(address.getProvince()+address.getCity()+address.getDistrict()+address.getDetail());
|
|
|
+ order.setUserAddress(address.getProvince() + address.getCity() + address.getDistrict() + address.getDetail());
|
|
|
order.setUserPhone(address.getPhone());
|
|
|
order.setCreateTime(new Date());
|
|
|
order.setCompanyUserId(companyUserId);
|
|
|
CompanyUser companyUser = companyUserMapper.selectCompanyUserByCompanyUserId(companyUserId);
|
|
|
- if (ObjectUtil.isNotEmpty(companyUser)){
|
|
|
+ if (ObjectUtil.isNotEmpty(companyUser)) {
|
|
|
order.setCompanyId(companyUser.getCompanyId());
|
|
|
}
|
|
|
|
|
|
//判断当前用户是否有关联企微ID
|
|
|
- if(ObjectUtil.isNotNull(user.getQwUserId())){
|
|
|
+ if (ObjectUtil.isNotNull(user.getQwUserId())) {
|
|
|
//获取企微信息
|
|
|
- QwUser qwUser=qwUserMapper.selectOne(new LambdaQueryWrapper<QwUser>().select(QwUser::getId,QwUser::getCompanyId,QwUser::getCompanyUserId).eq(QwUser::getId,user.getQwUserId()));
|
|
|
- if(ObjectUtil.isNotNull(qwUser)){
|
|
|
+ QwUser qwUser = qwUserMapper.selectOne(new LambdaQueryWrapper<QwUser>().select(QwUser::getId, QwUser::getCompanyId, QwUser::getCompanyUserId).eq(QwUser::getId, user.getQwUserId()));
|
|
|
+ if (ObjectUtil.isNotNull(qwUser)) {
|
|
|
//写入企业微信ID、销售ID、公司id
|
|
|
order.setQwUserId(qwUser.getId());
|
|
|
- order.setCompanyId(ObjectUtil.isNotNull(qwUser.getCompanyId())?qwUser.getCompanyId():null);
|
|
|
- order.setCompanyUserId(ObjectUtil.isNotNull(qwUser.getCompanyUserId())?qwUser.getCompanyUserId():null);
|
|
|
+ order.setCompanyId(ObjectUtil.isNotNull(qwUser.getCompanyId()) ? qwUser.getCompanyId() : null);
|
|
|
+ order.setCompanyUserId(ObjectUtil.isNotNull(qwUser.getCompanyUserId()) ? qwUser.getCompanyUserId() : null);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if(fsIntegralOrderMapper.insertFsIntegralOrder(order)>0){
|
|
|
+ if (fsIntegralOrderMapper.insertFsIntegralOrder(order) > 0) {
|
|
|
if (order.getPayType() != 2) {
|
|
|
//写入日志
|
|
|
- FsUser userMap=new FsUser();
|
|
|
+ FsUser userMap = new FsUser();
|
|
|
userMap.setUserId(user.getUserId());
|
|
|
|
|
|
// 可消费积分
|
|
|
@@ -439,7 +438,7 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
// 扣除完可消费积分后,剩余的积分
|
|
|
long extra = totalIntegral - consumer;
|
|
|
// 可提现积分扣除 剩余积分
|
|
|
- Long withdrawIntegral = user.getWithdrawIntegral()- extra;
|
|
|
+ Long withdrawIntegral = user.getWithdrawIntegral() - extra;
|
|
|
userMap.setIntegral(withdrawIntegral);
|
|
|
userMap.setWithdrawIntegral(withdrawIntegral);
|
|
|
} else {
|
|
|
@@ -456,20 +455,20 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
fsUserIntegralLogsMapper.insertFsUserIntegralLogs(logs);
|
|
|
}
|
|
|
//如何是打卡活动的积分商品则修改领取状态
|
|
|
- if(activityId!=null&&goodsId!=null){
|
|
|
+ if (activityId != null && goodsId != null) {
|
|
|
FsCourseCheckinReceive receiveQuery = new FsCourseCheckinReceive();
|
|
|
receiveQuery.setUserId(order.getUserId());
|
|
|
receiveQuery.setActivityId(activityId);
|
|
|
receiveQuery.setGoodsId(goodsId);
|
|
|
receiveQuery.setReceiveStatus(0);
|
|
|
List<FsCourseCheckinReceive> receiveList = fsCourseCheckinReceiveMapper.selectFsCourseCheckinReceiveList(receiveQuery);
|
|
|
- if(ObjectUtil.isNotEmpty(receiveList)){
|
|
|
+ if (ObjectUtil.isNotEmpty(receiveList)) {
|
|
|
FsCourseCheckinReceive receive = receiveList.get(0);
|
|
|
receive.setReceiveStatus(1);
|
|
|
receive.setReceiveTime(new Date());
|
|
|
receive.setUpdateTime(new Date());
|
|
|
fsCourseCheckinReceiveMapper.updateFsCourseCheckinReceive(receive);
|
|
|
- if(receive.getGoodsId() != null){
|
|
|
+ if (receive.getGoodsId() != null) {
|
|
|
redisCacheUtil.delRedisKey("getIntegralGoodsById::" + receive.getGoodsId());
|
|
|
}
|
|
|
}
|
|
|
@@ -483,30 +482,30 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
integralParam.setBusinessId(order.getOrderId().toString());
|
|
|
userIntegralLogsService.addIntegralTemplate(integralParam);
|
|
|
|
|
|
- return R.ok("兑换成功").put("order",order).put("isPay", 1);
|
|
|
+ return R.ok("兑换成功").put("order", order).put("isPay", 1);
|
|
|
}
|
|
|
// 现金 或 积分+现金
|
|
|
else {
|
|
|
String redisKey = String.valueOf(StrUtil.format("{}{}", FsConstants.REDIS_INTEGRAL_ORDER_UNPAY, order.getOrderId()));
|
|
|
- redisCache.setCacheObject(redisKey,order.getOrderId(),30, TimeUnit.MINUTES);
|
|
|
- return R.ok().put("order",order).put("isPay", 0);
|
|
|
+ redisCache.setCacheObject(redisKey, order.getOrderId(), 30, TimeUnit.MINUTES);
|
|
|
+ return R.ok().put("order", order).put("isPay", 0);
|
|
|
}
|
|
|
- }
|
|
|
- else{
|
|
|
+ } else {
|
|
|
throw new CustomException("订单创建失败");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 创建购物车订单
|
|
|
+ *
|
|
|
* @param param 参数
|
|
|
- * @return R
|
|
|
+ * @return R
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public R createCartOrder(FsIntegralCartOrderCreateParam param) {
|
|
|
- FsUser user=fsUserMapper.selectFsUserByUserId(param.getUserId());
|
|
|
- FsUserAddress address=fsUserAddressMapper.selectFsUserAddressByAddressId(param.getAddressId());
|
|
|
+ FsUser user = fsUserMapper.selectFsUserByUserId(param.getUserId());
|
|
|
+ FsUserAddress address = fsUserAddressMapper.selectFsUserAddressByAddressId(param.getAddressId());
|
|
|
|
|
|
if (Objects.isNull(user)) {
|
|
|
throw new CustomException("用户不存在");
|
|
|
@@ -531,7 +530,7 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
if (Objects.isNull(integralGoods)) {
|
|
|
throw new CustomException("商品不存在");
|
|
|
}
|
|
|
- if(integralGoods.getStock() < cart.getCartNum()){
|
|
|
+ if (integralGoods.getStock() < cart.getCartNum()) {
|
|
|
throw new CustomException("库存不足");
|
|
|
}
|
|
|
|
|
|
@@ -547,32 +546,29 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
goodsItem.add(integralGoods);
|
|
|
}
|
|
|
|
|
|
- if(user.getIntegral() < totalIntegral){
|
|
|
+ if (user.getIntegral() < totalIntegral) {
|
|
|
return R.error("积分不足");
|
|
|
}
|
|
|
|
|
|
- return createOrder(user, address, totalIntegral, totalCash, goodsItem, null, null,null);
|
|
|
+ return createOrder(user, address, totalIntegral, totalCash, goodsItem, null, null, null);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public String importProductDeliver(List<FsStoreProductDeliverExcelVO> list) {
|
|
|
- if (StringUtils.isNull(list) || list.size() == 0)
|
|
|
- {
|
|
|
+ if (StringUtils.isNull(list) || list.size() == 0) {
|
|
|
throw new ServiceException("导入商品数据不能为空!");
|
|
|
}
|
|
|
int successNum = 0;
|
|
|
int failureNum = 0;
|
|
|
StringBuilder successMsg = new StringBuilder();
|
|
|
StringBuilder failureMsg = new StringBuilder();
|
|
|
- for (FsStoreProductDeliverExcelVO vo : list)
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
+ for (FsStoreProductDeliverExcelVO vo : list) {
|
|
|
+ try {
|
|
|
FsIntegralOrder o = fsIntegralOrderMapper.selectFsIntegralOrderByOrderCode(vo.getOrderCode());
|
|
|
- if (o==null){
|
|
|
- throw new CustomException("没有此订单");
|
|
|
+ if (o == null) {
|
|
|
+ throw new CustomException("没有此订单");
|
|
|
}
|
|
|
- if (o.getStatus()!=1){
|
|
|
+ if (o.getStatus() != 1) {
|
|
|
throw new CustomException("订单状态不为待发货");
|
|
|
}
|
|
|
// 判断每个字段是否为null或为空字符串
|
|
|
@@ -601,22 +597,17 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
successNum++;
|
|
|
successMsg.append("<br/>" + successNum + "、订单编号 " + vo.getOrderCode() + " 导入成功");
|
|
|
|
|
|
- }
|
|
|
- catch (Exception e)
|
|
|
- {
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
|
failureNum++;
|
|
|
- String msg = "<br/>" + failureNum + "、订单编号 " + vo.getOrderCode() + " 导入失败:";
|
|
|
+ String msg = "<br/>" + failureNum + "、订单编号 " + vo.getOrderCode() + " 导入失败:";
|
|
|
failureMsg.append(msg + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
- if (failureNum > 0)
|
|
|
- {
|
|
|
+ if (failureNum > 0) {
|
|
|
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确,错误如下:");
|
|
|
throw new ServiceException(failureMsg.toString());
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条,数据如下:");
|
|
|
}
|
|
|
return successMsg.toString();
|
|
|
@@ -635,7 +626,7 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
public R cannelOrder(Long orderId) {
|
|
|
// 取消订单
|
|
|
FsIntegralOrder order = fsIntegralOrderMapper.selectFsIntegralOrderByOrderId(orderId);
|
|
|
- if (!order.getStatus().equals(4)){
|
|
|
+ if (!order.getStatus().equals(4)) {
|
|
|
return R.error("非法操作");
|
|
|
}
|
|
|
|
|
|
@@ -643,8 +634,9 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
fsIntegralOrderMapper.updateFsIntegralOrder(order);
|
|
|
|
|
|
// 还原库存
|
|
|
- if (order.getItemJson().startsWith("[") && order.getItemJson().endsWith("]")){
|
|
|
- List<FsIntegralGoods> goodsItem = JSONUtil.toBean(order.getItemJson(), new TypeReference<List<FsIntegralGoods>>(){}, true);
|
|
|
+ if (order.getItemJson().startsWith("[") && order.getItemJson().endsWith("]")) {
|
|
|
+ List<FsIntegralGoods> goodsItem = JSONUtil.toBean(order.getItemJson(), new TypeReference<List<FsIntegralGoods>>() {
|
|
|
+ }, true);
|
|
|
goodsItem.forEach(goods -> fsIntegralGoodsMapper.addStock(goods.getGoodsId(), Objects.isNull(goods.getNum()) ? 1 : goods.getNum()));
|
|
|
} else {
|
|
|
FsIntegralGoods integralGoods = JSONUtil.toBean(order.getItemJson(), FsIntegralGoods.class);
|
|
|
@@ -652,8 +644,8 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
}
|
|
|
|
|
|
// 还原积分
|
|
|
- FsUser user=fsUserMapper.selectFsUserByUserId(order.getUserId());
|
|
|
- FsUser userMap=new FsUser();
|
|
|
+ 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);
|
|
|
@@ -676,7 +668,7 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
public R payment(FsIntegralOrderDoPayParam param, PaymentMethodEnum paymentMethod) {
|
|
|
FsIntegralOrder order = fsIntegralOrderMapper.selectFsIntegralOrderByOrderId(param.getOrderId());
|
|
|
if (Objects.isNull(order) || !order.getStatus().equals(4)
|
|
|
- || order.getPayMoney().compareTo(BigDecimal.ZERO) <= 0){
|
|
|
+ || order.getPayMoney().compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
return R.error("非法操作");
|
|
|
}
|
|
|
|
|
|
@@ -706,7 +698,7 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public R payConfirm(String orderSn, String payCode, String tradeNo, String payType, int type,String bankTransactionId,String bankSerialNo){
|
|
|
+ public R payConfirm(String orderSn, String payCode, String tradeNo, String payType, int type, String bankTransactionId, String bankSerialNo) {
|
|
|
log.info("进入积分商城订单支付回调 orderSn: {}, payCode: {}, tradeNo: {}, payType: {}, type: {}",
|
|
|
orderSn, payCode, tradeNo, payType, type);
|
|
|
FsIntegralOrder order = null;
|
|
|
@@ -717,7 +709,7 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
return R.error("支付单号不存在");
|
|
|
}
|
|
|
|
|
|
- if(storePayment.getStatus() == 0){
|
|
|
+ if (storePayment.getStatus() == 0) {
|
|
|
FsStorePayment paymentMap = new FsStorePayment();
|
|
|
paymentMap.setPaymentId(storePayment.getPaymentId());
|
|
|
paymentMap.setStatus(1);
|
|
|
@@ -725,13 +717,12 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
paymentMap.setTradeNo(tradeNo);
|
|
|
paymentMap.setBankSerialNo(bankSerialNo);
|
|
|
paymentMap.setBankTransactionId(bankTransactionId);
|
|
|
- if(payType.equals(PayType.WECHAT_MINI_PROGRAM_PAYMENT.getCode())){
|
|
|
+ if (payType.equals(PayType.WECHAT_MINI_PROGRAM_PAYMENT.getCode())) {
|
|
|
paymentMap.setPayTypeCode(PayType.WECHAT_MINI_PROGRAM_PAYMENT.name());
|
|
|
- }
|
|
|
- else if(payType.equals(PayType.ALIPAY_BARCODE_PAYMENT.getCode())){
|
|
|
+ } else if (payType.equals(PayType.ALIPAY_BARCODE_PAYMENT.getCode())) {
|
|
|
paymentMap.setPayTypeCode(PayType.ALIPAY_BARCODE_PAYMENT.name());
|
|
|
}
|
|
|
- if (storePayment.getPayMode().equals("yb")){
|
|
|
+ if (storePayment.getPayMode().equals("yb")) {
|
|
|
OrderQueryDTO orderQueryDTO = new OrderQueryDTO();
|
|
|
orderQueryDTO.setUpOrderId(tradeNo);
|
|
|
OrderResult orderResult = ybPayService.getOrder(orderQueryDTO);
|
|
|
@@ -742,8 +733,7 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
storePaymentService.updateFsStorePayment(paymentMap);
|
|
|
order = fsIntegralOrderMapper.selectFsIntegralOrderByOrderId(Long.parseLong(storePayment.getBusinessId()));
|
|
|
}
|
|
|
- }
|
|
|
- else if (type == 2) {
|
|
|
+ } else if (type == 2) {
|
|
|
order = fsIntegralOrderMapper.selectFsIntegralOrderByOrderCode(orderSn);
|
|
|
}
|
|
|
|
|
|
@@ -770,9 +760,9 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
String mpOpenId = companyUserService.selectMpOpenIdByCompanyUserId(companyUserId);
|
|
|
if (StringUtils.isNotEmpty(mpOpenId)) {
|
|
|
FsUser user = userService.selectFsUserByUserId(order.getUserId());
|
|
|
- String userName = user.getUsername() != null?user.getUsername():user.getNickName();
|
|
|
+ String userName = user.getUsername() != null ? user.getUsername() : user.getNickName();
|
|
|
Date payTime = Date.from(order.getPayTime().atZone(ZoneId.systemDefault()).toInstant());
|
|
|
- wechatApi.sendTemplateMessage(wechatApi.getAccessToken(), mpOpenId,payTime,userName,order.getPayMoney(),order.getOrderCode());
|
|
|
+ wechatApi.sendTemplateMessage(wechatApi.getAccessToken(), mpOpenId, payTime, userName, order.getPayMoney(), order.getOrderCode());
|
|
|
log.info("支付成功模板消息已发送给销售: {}", companyUserId);
|
|
|
} else {
|
|
|
log.warn("未找到 companyUserId={} 的 openId,跳过模板消息发送", companyUserId);
|
|
|
@@ -808,19 +798,19 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
public int cancelOrder(String orderCode) {
|
|
|
//查询订单是否存在且是否未发货
|
|
|
FsIntegralOrder fsIntegralOrder = fsIntegralOrderMapper.selectFsIntegralOrderByOrderCode(orderCode);
|
|
|
- if (null==fsIntegralOrder){
|
|
|
+ if (null == fsIntegralOrder) {
|
|
|
throw new ServiceException("订单不存在");
|
|
|
}
|
|
|
- if (fsIntegralOrder.getStatus()!=1){
|
|
|
+ if (fsIntegralOrder.getStatus() != 1) {
|
|
|
throw new ServiceException("订单已发货或已完成");
|
|
|
}
|
|
|
int i = 0;
|
|
|
//修改订单状态
|
|
|
i = fsIntegralOrderMapper.cancelOrder(fsIntegralOrder.getOrderId());
|
|
|
- if (i>0){
|
|
|
+ if (i > 0) {
|
|
|
//原路退回积分
|
|
|
FsUser fsUser = fsUserMapper.selectFsUserByUserId(fsIntegralOrder.getUserId());
|
|
|
- fsUser.setIntegral(fsUser.getIntegral()+Long.parseLong(fsIntegralOrder.getIntegral()));
|
|
|
+ fsUser.setIntegral(fsUser.getIntegral() + Long.parseLong(fsIntegralOrder.getIntegral()));
|
|
|
i = fsUserMapper.updateFsUser(fsUser);
|
|
|
//新增积分记录
|
|
|
FsUserIntegralLogs fsUserIntegralLogs = new FsUserIntegralLogs();
|
|
|
@@ -833,28 +823,29 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
fsUserIntegralLogs.setStatus(0);
|
|
|
i = fsUserIntegralLogsMapper.insertFsUserIntegralLogs(fsUserIntegralLogs);
|
|
|
//还原库存
|
|
|
- if (fsIntegralOrder.getItemJson().startsWith("[") && fsIntegralOrder.getItemJson().endsWith("]")){
|
|
|
- List<FsIntegralGoods> goodsItem = JSONUtil.toBean(fsIntegralOrder.getItemJson(), new TypeReference<List<FsIntegralGoods>>(){}, true);
|
|
|
+ if (fsIntegralOrder.getItemJson().startsWith("[") && fsIntegralOrder.getItemJson().endsWith("]")) {
|
|
|
+ List<FsIntegralGoods> goodsItem = JSONUtil.toBean(fsIntegralOrder.getItemJson(), new TypeReference<List<FsIntegralGoods>>() {
|
|
|
+ }, true);
|
|
|
goodsItem.forEach(goods -> fsIntegralGoodsMapper.addStock(goods.getGoodsId(), Objects.isNull(goods.getNum()) ? 1 : goods.getNum()));
|
|
|
} else {
|
|
|
FsIntegralGoods integralGoods = JSONUtil.toBean(fsIntegralOrder.getItemJson(), FsIntegralGoods.class);
|
|
|
fsIntegralGoodsMapper.addStock(integralGoods.getGoodsId(), Objects.isNull(integralGoods.getNum()) ? 1 : integralGoods.getNum());
|
|
|
}
|
|
|
//还原金额
|
|
|
- List<FsStorePayment> payments = storePaymentMapper.selectFsStorePaymentByPay(6,fsIntegralOrder.getOrderId());
|
|
|
- if(payments!=null&&payments.size()==1){
|
|
|
- FsStorePayment payment=payments.get(0);
|
|
|
+ List<FsStorePayment> payments = storePaymentMapper.selectFsStorePaymentByPay(6, fsIntegralOrder.getOrderId());
|
|
|
+ if (payments != null && payments.size() == 1) {
|
|
|
+ FsStorePayment payment = payments.get(0);
|
|
|
V2TradePaymentScanpayRefundRequest request = new V2TradePaymentScanpayRefundRequest();
|
|
|
request.setOrdAmt(payment.getPayMoney().toString());
|
|
|
request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
|
|
|
- request.setReqSeqId("refund-"+payment.getPayCode());
|
|
|
+ request.setReqSeqId("refund-" + payment.getPayCode());
|
|
|
Map<String, Object> extendInfoMap = new HashMap<>();
|
|
|
- extendInfoMap.put("org_req_seq_id", "integral-"+payment.getPayCode());
|
|
|
+ extendInfoMap.put("org_req_seq_id", "integral-" + payment.getPayCode());
|
|
|
request.setExtendInfo(extendInfoMap);
|
|
|
HuiFuRefundResult refund = huiFuService.refund(request);
|
|
|
- logger.info("积分退款返回结果:积分订单id:"+fsIntegralOrder.getOrderId()+refund);
|
|
|
- if((refund.getResp_code().equals("00000000")||refund.getResp_code().equals("00000100"))&&(refund.getTrans_stat().equals("S")||refund.getTrans_stat().equals("P"))){
|
|
|
- FsStorePayment paymentMap=new FsStorePayment();
|
|
|
+ logger.info("积分退款返回结果:积分订单id:" + fsIntegralOrder.getOrderId() + refund);
|
|
|
+ if ((refund.getResp_code().equals("00000000") || refund.getResp_code().equals("00000100")) && (refund.getTrans_stat().equals("S") || refund.getTrans_stat().equals("P"))) {
|
|
|
+ FsStorePayment paymentMap = new FsStorePayment();
|
|
|
paymentMap.setPaymentId(payment.getPaymentId());
|
|
|
paymentMap.setStatus(-1);
|
|
|
paymentMap.setRefundTime(DateUtils.getNowDate());
|
|
|
@@ -880,7 +871,7 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
public int mandatoryRefunds(String orderCode) {
|
|
|
//查询订单是否存在且是否未发货
|
|
|
FsIntegralOrder fsIntegralOrder = fsIntegralOrderMapper.selectFsIntegralOrderByOrderCode(orderCode);
|
|
|
- if (null==fsIntegralOrder){
|
|
|
+ if (null == fsIntegralOrder) {
|
|
|
throw new ServiceException("订单不存在");
|
|
|
}
|
|
|
//用户说自己去对接物流,不必校验是否发货。
|
|
|
@@ -890,10 +881,10 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
int i = 0;
|
|
|
//修改订单状态
|
|
|
i = fsIntegralOrderMapper.cancelOrder(fsIntegralOrder.getOrderId());
|
|
|
- if (i>0){
|
|
|
+ if (i > 0) {
|
|
|
//原路退回积分
|
|
|
FsUser fsUser = fsUserMapper.selectFsUserByUserId(fsIntegralOrder.getUserId());
|
|
|
- fsUser.setIntegral(fsUser.getIntegral()+Long.parseLong(fsIntegralOrder.getIntegral()));
|
|
|
+ fsUser.setIntegral(fsUser.getIntegral() + Long.parseLong(fsIntegralOrder.getIntegral()));
|
|
|
i = fsUserMapper.updateFsUser(fsUser);
|
|
|
//新增积分记录
|
|
|
FsUserIntegralLogs fsUserIntegralLogs = new FsUserIntegralLogs();
|
|
|
@@ -906,28 +897,29 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
fsUserIntegralLogs.setStatus(0);
|
|
|
i = fsUserIntegralLogsMapper.insertFsUserIntegralLogs(fsUserIntegralLogs);
|
|
|
//还原库存
|
|
|
- if (fsIntegralOrder.getItemJson().startsWith("[") && fsIntegralOrder.getItemJson().endsWith("]")){
|
|
|
- List<FsIntegralGoods> goodsItem = JSONUtil.toBean(fsIntegralOrder.getItemJson(), new TypeReference<List<FsIntegralGoods>>(){}, true);
|
|
|
+ if (fsIntegralOrder.getItemJson().startsWith("[") && fsIntegralOrder.getItemJson().endsWith("]")) {
|
|
|
+ List<FsIntegralGoods> goodsItem = JSONUtil.toBean(fsIntegralOrder.getItemJson(), new TypeReference<List<FsIntegralGoods>>() {
|
|
|
+ }, true);
|
|
|
goodsItem.forEach(goods -> fsIntegralGoodsMapper.addStock(goods.getGoodsId(), Objects.isNull(goods.getNum()) ? 1 : goods.getNum()));
|
|
|
} else {
|
|
|
FsIntegralGoods integralGoods = JSONUtil.toBean(fsIntegralOrder.getItemJson(), FsIntegralGoods.class);
|
|
|
fsIntegralGoodsMapper.addStock(integralGoods.getGoodsId(), Objects.isNull(integralGoods.getNum()) ? 1 : integralGoods.getNum());
|
|
|
}
|
|
|
//还原金额
|
|
|
- List<FsStorePayment> payments = storePaymentMapper.selectFsStorePaymentByPay(6,fsIntegralOrder.getOrderId());
|
|
|
- if(payments!=null&&payments.size()==1){
|
|
|
- FsStorePayment payment=payments.get(0);
|
|
|
+ List<FsStorePayment> payments = storePaymentMapper.selectFsStorePaymentByPay(6, fsIntegralOrder.getOrderId());
|
|
|
+ if (payments != null && payments.size() == 1) {
|
|
|
+ FsStorePayment payment = payments.get(0);
|
|
|
V2TradePaymentScanpayRefundRequest request = new V2TradePaymentScanpayRefundRequest();
|
|
|
request.setOrdAmt(payment.getPayMoney().toString());
|
|
|
request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
|
|
|
- request.setReqSeqId("refund-"+payment.getPayCode());
|
|
|
+ request.setReqSeqId("refund-" + payment.getPayCode());
|
|
|
Map<String, Object> extendInfoMap = new HashMap<>();
|
|
|
- extendInfoMap.put("org_req_seq_id", "integral-"+payment.getPayCode());
|
|
|
+ extendInfoMap.put("org_req_seq_id", "integral-" + payment.getPayCode());
|
|
|
request.setExtendInfo(extendInfoMap);
|
|
|
HuiFuRefundResult refund = huiFuService.refund(request);
|
|
|
- logger.info("积分退款返回结果:积分订单id:"+fsIntegralOrder.getOrderId()+refund);
|
|
|
- if((refund.getResp_code().equals("00000000")||refund.getResp_code().equals("00000100"))&&(refund.getTrans_stat().equals("S")||refund.getTrans_stat().equals("P"))){
|
|
|
- FsStorePayment paymentMap=new FsStorePayment();
|
|
|
+ logger.info("积分退款返回结果:积分订单id:" + fsIntegralOrder.getOrderId() + refund);
|
|
|
+ if ((refund.getResp_code().equals("00000000") || refund.getResp_code().equals("00000100")) && (refund.getTrans_stat().equals("S") || refund.getTrans_stat().equals("P"))) {
|
|
|
+ FsStorePayment paymentMap = new FsStorePayment();
|
|
|
paymentMap.setPaymentId(payment.getPaymentId());
|
|
|
paymentMap.setStatus(-1);
|
|
|
paymentMap.setRefundTime(DateUtils.getNowDate());
|
|
|
@@ -952,10 +944,10 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
public int finishOrder(String orderCode) {
|
|
|
//查询订单是否存在且是否未发货
|
|
|
FsIntegralOrder fsIntegralOrder = fsIntegralOrderMapper.selectFsIntegralOrderByOrderCode(orderCode);
|
|
|
- if (null==fsIntegralOrder){
|
|
|
+ if (null == fsIntegralOrder) {
|
|
|
throw new ServiceException("订单不存在");
|
|
|
}
|
|
|
- if (fsIntegralOrder.getStatus()!=2){
|
|
|
+ if (fsIntegralOrder.getStatus() != 2) {
|
|
|
throw new ServiceException("订单未发货或者未支付,无法完成订单");
|
|
|
}
|
|
|
return fsIntegralOrderMapper.finishOrder(fsIntegralOrder.getOrderId(), fsIntegralOrder.getStatus());
|
|
|
@@ -1012,7 +1004,7 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
payments.add(payment);
|
|
|
|
|
|
FsExpress express = expressService.selectFsExpressByOmsCode("YUNDA");
|
|
|
- if(express!=null){
|
|
|
+ if (express != null) {
|
|
|
erpOrder.setExpress_code(express.getOmsCode());
|
|
|
fsIntegralOrder.setDeliveryName(express.getName());
|
|
|
fsIntegralOrder.setDeliveryCode(express.getCode());
|
|
|
@@ -1045,7 +1037,7 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
} else {
|
|
|
erpOrder.setReceiver_mobile(fsIntegralOrder.getUserPhone());
|
|
|
}
|
|
|
- if (StringUtils.isNotEmpty(fsIntegralOrder.getUserAddress())){
|
|
|
+ if (StringUtils.isNotEmpty(fsIntegralOrder.getUserAddress())) {
|
|
|
erpOrder.setReceiver_address(fsIntegralOrder.getUserAddress());
|
|
|
}
|
|
|
// String[] address = fsIntegralOrder.getUserAddress().split(" ");
|
|
|
@@ -1179,7 +1171,8 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
if (itemJson.startsWith("[") && itemJson.endsWith("]")) {
|
|
|
// 数组格式 - 多个商品
|
|
|
List<FsIntegralGoods> goodsList = JSONUtil.toBean(itemJson,
|
|
|
- new TypeReference<List<FsIntegralGoods>>(){}, true);
|
|
|
+ new TypeReference<List<FsIntegralGoods>>() {
|
|
|
+ }, true);
|
|
|
|
|
|
for (FsIntegralGoods goods : goodsList) {
|
|
|
if (ObjectUtil.isNotEmpty(goods)) {
|
|
|
@@ -1258,13 +1251,37 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (param.getPayMoney() != null) {
|
|
|
- totalCash = param.getPayMoney();
|
|
|
+ FsUserCoupon userCoupon = null;
|
|
|
+ FsCoupon coupon = null;
|
|
|
+ BigDecimal discountPrice = BigDecimal.ZERO;
|
|
|
+ BigDecimal totalPrice = totalCash;
|
|
|
+ if (param.getCouponId() != null) {
|
|
|
+ coupon = fsCouponMapper.selectFsCouponByCouponId(param.getCouponId());
|
|
|
+ if (coupon == null) {
|
|
|
+ return R.error("优惠券配置不存在");
|
|
|
+ }
|
|
|
+ if (coupon.getLimitTime() != null && coupon.getLimitTime().before(new Date())) {
|
|
|
+ return R.error("优惠券已过期");
|
|
|
+ }
|
|
|
+ userCoupon = fsUserCouponMapper.selectByCouponIdAndUserId(param.getCouponId(), param.getUserId());
|
|
|
+ if (userCoupon == null) {
|
|
|
+ return R.error("该用户的优惠券不存在");
|
|
|
+ }
|
|
|
+ if (userCoupon.getStatus() != 0) {
|
|
|
+ return R.error("优惠券已使用或已过期");
|
|
|
+ }
|
|
|
+ BigDecimal couponPrice = coupon.getPrice();
|
|
|
+ if (couponPrice == null || couponPrice.compareTo(BigDecimal.ZERO) == 0) {
|
|
|
+ discountPrice = totalPrice;
|
|
|
+ } else {
|
|
|
+ discountPrice = couponPrice;
|
|
|
+ }
|
|
|
+ totalCash = totalPrice.subtract(discountPrice);
|
|
|
+ if (totalCash.compareTo(BigDecimal.ZERO) < 0) {
|
|
|
+ totalCash = BigDecimal.ZERO;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- Long activityId = param.getActivityId();
|
|
|
-
|
|
|
-
|
|
|
for (FsIntegralGoods goods : goodsList) {
|
|
|
if (fsIntegralGoodsMapper.subStock(goods.getGoodsId(), 1) <= 0) {
|
|
|
throw new CustomException("商品库存不足: " + goods.getGoodsName());
|
|
|
@@ -1282,18 +1299,11 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
throw new CustomException("订单生成失败,请重试");
|
|
|
}
|
|
|
|
|
|
- if (totalCash.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- order.setPayType(totalIntegral > 0 ? 3 : 2);
|
|
|
- order.setStatus(4);
|
|
|
- order.setIsPay(0);
|
|
|
- order.setPayMoney(totalCash);
|
|
|
- } else {
|
|
|
- order.setPayType(1);
|
|
|
- order.setStatus(1);
|
|
|
- order.setIsPay(1);
|
|
|
- order.setPayTime(LocalDateTime.now());
|
|
|
- }
|
|
|
|
|
|
+ order.setPayType(totalIntegral > 0 ? 3 : 2);
|
|
|
+ order.setStatus(1);
|
|
|
+ order.setIsPay(1);
|
|
|
+ order.setPayMoney(totalCash);
|
|
|
order.setOrderCode(orderSn);
|
|
|
order.setUserId(user.getUserId());
|
|
|
if (!goodsList.isEmpty()) {
|
|
|
@@ -1309,6 +1319,11 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
order.setCreateTime(new Date());
|
|
|
order.setCompanyUserId(param.getCompanyUserId());
|
|
|
order.setCompanyId(param.getCompanyId());
|
|
|
+ order.setTotalPrice(totalPrice);
|
|
|
+ order.setDiscountPrice(discountPrice);
|
|
|
+ if (coupon != null) {
|
|
|
+ order.setCouponId(coupon.getCouponId());
|
|
|
+ }
|
|
|
|
|
|
if (fsIntegralOrderMapper.insertFsIntegralOrder(order) > 0) {
|
|
|
if (order.getPayType() != 2 && totalIntegral > 0) {
|
|
|
@@ -1317,7 +1332,7 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
userMap.setIntegral(user.getIntegral() - totalIntegral);
|
|
|
fsUserMapper.updateFsUser(userMap);
|
|
|
FsUserIntegralLogs logs = new FsUserIntegralLogs();
|
|
|
- logs.setIntegral(-totalIntegral);
|
|
|
+ logs.setIntegral(user.getIntegral()-totalIntegral);
|
|
|
logs.setUserId(order.getUserId());
|
|
|
logs.setBalance(userMap.getIntegral());
|
|
|
logs.setLogType(5);
|
|
|
@@ -1325,6 +1340,15 @@ public class FsIntegralOrderServiceImpl implements IFsIntegralOrderService
|
|
|
logs.setCreateTime(new Date());
|
|
|
fsUserIntegralLogsMapper.insertFsUserIntegralLogs(logs);
|
|
|
}
|
|
|
+ if (userCoupon != null) {
|
|
|
+ FsUserCoupon updateUserCoupon = new FsUserCoupon();
|
|
|
+ updateUserCoupon.setId(userCoupon.getId());
|
|
|
+ updateUserCoupon.setStatus(1);
|
|
|
+ updateUserCoupon.setUseTime(new Date());
|
|
|
+ updateUserCoupon.setBusinessId(order.getOrderId());
|
|
|
+ updateUserCoupon.setBusinessType(4);
|
|
|
+ fsUserCouponMapper.updateFsUserCoupon(updateUserCoupon);
|
|
|
+ }
|
|
|
return R.ok("订单创建成功").put("order", order);
|
|
|
} else {
|
|
|
throw new CustomException("订单创建失败");
|