| @@ -397,5 +397,19 @@ public class WxCouponController extends BaseController { | |||||
| logger.debug("[" + getIpAddr() + "] WxCouponController::getHtmlById"); | logger.debug("[" + getIpAddr() + "] WxCouponController::getHtmlById"); | ||||
| return new ResultData(wxCouponService.getHtmlById(id)); | return new ResultData(wxCouponService.getHtmlById(id)); | ||||
| } | } | ||||
| @ApiOperation("卡延期") | |||||
| @PostMapping("/cardDefer") | |||||
| @SystemControllerLog(description = "卡延期") | |||||
| public ResultData cardDefer(@RequestBody WxCoupon wxCoupon) { | |||||
| if (wxCoupon.getId() == null) { | |||||
| return new ResultData(ResultData.ERROR, "缺少id"); | |||||
| } | |||||
| if (wxCoupon.getValidEndDate() == null) { | |||||
| return new ResultData(ResultData.ERROR, "缺少validEndDate"); | |||||
| } | |||||
| return new ResultData(wxCouponService.cardDefer(wxCoupon.getId(),wxCoupon.getValidEndDate())); | |||||
| } | |||||
| } | } | ||||
| @@ -82,4 +82,6 @@ public interface WxCouponMapper extends CommonMapper<WxCoupon, Long> { | |||||
| WxCoupon findCouponModel(WxCoupon wxCoupon); | WxCoupon findCouponModel(WxCoupon wxCoupon); | ||||
| Integer findCouponListCount(WxCoupon wxCoupon); | Integer findCouponListCount(WxCoupon wxCoupon); | ||||
| void updateValidEndDate(WxCoupon wxCoupon); | |||||
| } | } | ||||
| @@ -81,4 +81,7 @@ public interface WxCouponOrderMapper extends CommonMapper<WxCouponOrder, Long> { | |||||
| /// POS接口 | /// POS接口 | ||||
| List<WxCouponOrderCVo> findAvailCouponOrder(Map<String,Object> params); | List<WxCouponOrderCVo> findAvailCouponOrder(Map<String,Object> params); | ||||
| //卡延期,将过期的状态变为使用中 | |||||
| void cardDefer(@Param("couponId")Long couponId); | |||||
| } | } | ||||
| @@ -4,8 +4,11 @@ import com.iformall.common.CommonMapper; | |||||
| import com.iformall.domain.po.WxCouponPassword; | import com.iformall.domain.po.WxCouponPassword; | ||||
| import com.iformall.domain.vo.WxCouponPasswordCountInfoVO; | import com.iformall.domain.vo.WxCouponPasswordCountInfoVO; | ||||
| import java.util.Date; | |||||
| import java.util.List; | import java.util.List; | ||||
| import org.apache.ibatis.annotations.Param; | |||||
| public interface WxCouponPasswordMapper extends CommonMapper<WxCouponPassword, Long> { | public interface WxCouponPasswordMapper extends CommonMapper<WxCouponPassword, Long> { | ||||
| List<WxCouponPassword> findList(WxCouponPassword wxCouponPassword); | List<WxCouponPassword> findList(WxCouponPassword wxCouponPassword); | ||||
| @@ -22,5 +25,7 @@ public interface WxCouponPasswordMapper extends CommonMapper<WxCouponPassword, L | |||||
| void updateStatus(List<WxCouponPassword> tempList); | void updateStatus(List<WxCouponPassword> tempList); | ||||
| void updatePostpone(WxCouponPassword wxCouponPassword); | void updatePostpone(WxCouponPassword wxCouponPassword); | ||||
| void updateExpiredTime(@Param("couponId")Long couponId,@Param("expiredTime")Date expiredTime); | |||||
| } | } | ||||
| @@ -224,5 +224,11 @@ public interface WxCouponService { | |||||
| * @param remainInventory 当前库存 | * @param remainInventory 当前库存 | ||||
| */ | */ | ||||
| void backRemainInventory(Long id, Integer number, Integer remainInventory); | void backRemainInventory(Long id, Integer number, Integer remainInventory); | ||||
| /** | |||||
| * 卡延期 | |||||
| * @param wxCoupon | |||||
| * @return | |||||
| */ | |||||
| ResultData cardDefer(Long id,Date validEndDate); | |||||
| } | } | ||||
| @@ -8,6 +8,7 @@ import com.github.pagehelper.PageHelper; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.iformall.common.ErrorCode; | import com.iformall.common.ErrorCode; | ||||
| import com.iformall.common.IdWorker; | import com.iformall.common.IdWorker; | ||||
| import com.iformall.common.Result; | |||||
| import com.iformall.common.ResultData; | import com.iformall.common.ResultData; | ||||
| import com.iformall.domain.dto.WxCouponMerchantDto; | import com.iformall.domain.dto.WxCouponMerchantDto; | ||||
| import com.iformall.domain.po.*; | import com.iformall.domain.po.*; | ||||
| @@ -77,6 +78,9 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| @Autowired | @Autowired | ||||
| WxPayAccountMapper payAccountMapper; | WxPayAccountMapper payAccountMapper; | ||||
| @Autowired | |||||
| WxCouponOrderMapper wxCouponOrderMapper; | |||||
| @Autowired | @Autowired | ||||
| @Qualifier("couponChannelRedisTemplate") | @Qualifier("couponChannelRedisTemplate") | ||||
| @@ -742,4 +746,28 @@ public class WxCouponServiceImpl implements WxCouponService { | |||||
| } | } | ||||
| } | } | ||||
| @Override | |||||
| @Transactional(isolation= Isolation.SERIALIZABLE, propagation = Propagation.REQUIRED, rollbackFor = {Exception.class}) | |||||
| public ResultData cardDefer(Long id,Date validEndDate) { | |||||
| WxCoupon coupon = wxCouponMapper.selectById(id); | |||||
| if (null == coupon) { | |||||
| return new ResultData(Result.ERROR,id+"未查询到券信息."); | |||||
| } | |||||
| if (new Date().after(validEndDate)) { | |||||
| return new ResultData(Result.ERROR,"有效期不能小于当前时间."); | |||||
| } | |||||
| //更新coupon信息 | |||||
| coupon.setValidEndDate(validEndDate); | |||||
| coupon.setUpdateDate(new Date()); | |||||
| wxCouponMapper.updateValidEndDate(coupon); | |||||
| //更新coupon_order的状态,已过期的变为使用中 5-->4 | |||||
| wxCouponOrderMapper.cardDefer(id); | |||||
| //更新coupon_passwd | |||||
| couponPasswordMapper.updateExpiredTime(id, validEndDate); | |||||
| return new ResultData(); | |||||
| } | |||||
| } | } | ||||
| @@ -1041,4 +1041,8 @@ | |||||
| and `parent_tenant_id` = #{parentTenantId} | and `parent_tenant_id` = #{parentTenantId} | ||||
| </if> | </if> | ||||
| </select> | </select> | ||||
| <update id="updateValidEndDate" parameterType="com.iformall.domain.po.WxCoupon"> | |||||
| update wx_coupon set valid_end_date = #{validEndDate} , update_date = #{updateDate} where id = #{id} | |||||
| </update> | |||||
| </mapper> | </mapper> | ||||
| @@ -1393,5 +1393,9 @@ | |||||
| where co.coupon_id = c.id and co.id = a.id | where co.coupon_id = c.id and co.id = a.id | ||||
| and co.id = #{id} | and co.id = #{id} | ||||
| </select> | </select> | ||||
| <update id="cardDefer" parameterType="java.lang.Long"> | |||||
| update wx_coupon_order set coupon_order_status = 4,update_date = now() where coupon_id = #{couponId} and coupon_order_status = 5 | |||||
| </update> | |||||
| </mapper> | </mapper> | ||||
| @@ -195,5 +195,9 @@ | |||||
| and `parent_tenant_id` = #{parentTenantId} | and `parent_tenant_id` = #{parentTenantId} | ||||
| </if> | </if> | ||||
| </update> | </update> | ||||
| <update id="updateExpiredTime" parameterType="map"> | |||||
| update wx_coupon_password set expire_date = #{expiredTime} , update_date = now() where coupon_id = #{couponId} | |||||
| </update> | |||||
| </mapper> | </mapper> | ||||