|
@@ -19,6 +19,7 @@ import com.yonge.cooleshow.biz.dal.service.CouponInfoService;
|
|
|
import com.yonge.cooleshow.biz.dal.vo.coupon.CouponInfoWrapper;
|
|
|
import com.yonge.cooleshow.biz.dal.wrapper.StatGroupWrapper;
|
|
|
import com.yonge.cooleshow.biz.dal.wrapper.coupon.CouponInventoryWrapper;
|
|
|
+import com.yonge.cooleshow.common.enums.EStatus;
|
|
|
import com.yonge.toolset.base.exception.BizException;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
@@ -125,6 +126,7 @@ public class CouponInfoServiceImp extends ServiceImpl<CouponInfoMapper, CouponIn
|
|
|
* @param couponInfo CouponInfo
|
|
|
* @return CouponInfo
|
|
|
*/
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
public CouponInfo saveOrUpdateCouponInfo(CouponInfo couponInfo) {
|
|
|
|
|
@@ -132,6 +134,21 @@ public class CouponInfoServiceImp extends ServiceImpl<CouponInfoMapper, CouponIn
|
|
|
|
|
|
// 新增优惠券
|
|
|
save(couponInfo);
|
|
|
+
|
|
|
+ // 添加库存变更记录
|
|
|
+ if (couponInfo.getInventory() > 0) {
|
|
|
+
|
|
|
+ CouponInventoryWrapper wrapper = CouponInventoryWrapper.builder()
|
|
|
+ .userId(couponInfo.getCreatedBy())
|
|
|
+ .couponId(couponInfo.getId())
|
|
|
+ .dataType(CouponInventoryEnum.ADDITION)
|
|
|
+ .number(couponInfo.getInventory())
|
|
|
+ .remark("")
|
|
|
+ .status(EStatus.ENABLE.getValue())
|
|
|
+ .build();
|
|
|
+
|
|
|
+ couponInventoryMapper.insert(JSON.parseObject(wrapper.jsonString(), CouponInventory.class));
|
|
|
+ }
|
|
|
} else {
|
|
|
|
|
|
CouponInfo info = getById(couponInfo.getId());
|