| @@ -6,6 +6,7 @@ import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.po.WxCouponSend; | |||
| import com.iformall.enums.EnumCouponSendStatus; | |||
| import com.iformall.enums.EnumCouponSendType; | |||
| import com.iformall.enums.EnumCouponStatus; | |||
| import com.iformall.service.WxCouponSendService; | |||
| @@ -18,6 +19,7 @@ import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @RestController | |||
| @@ -38,6 +40,7 @@ public class WxCouponSendController extends BaseController { | |||
| public ResultData list(@ModelAttribute WxCouponSend wxCouponSend, Integer pageNum, Integer pageSize) { | |||
| if (null == wxCouponSend) wxCouponSend = new WxCouponSend(); | |||
| wxCouponSend.setTenantId(getTenantId()); | |||
| wxCouponSend.setStatus(EnumCouponSendStatus.VALID.getCode()); | |||
| final PageInfo<WxCouponSend> page = wxCouponSendService.listAsPage(wxCouponSend, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @@ -49,7 +52,7 @@ public class WxCouponSendController extends BaseController { | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| } | |||
| wxCouponSend.setTenantId(getTenantId()); | |||
| wxCouponSend.setStatus(0); | |||
| wxCouponSend.setStatus(EnumCouponSendStatus.VALID.getCode()); | |||
| List<WxCouponSend> wxCouponSendList = wxCouponSendService.listAsPage(wxCouponSend, 1, 1).getList(); | |||
| if (wxCouponSendList != null && wxCouponSendList.size() > 0) { | |||
| return new ResultData(ErrorCode.COUPON_SEND_IS_EXISTED); | |||
| @@ -68,9 +71,9 @@ public class WxCouponSendController extends BaseController { | |||
| wxCouponSend.setType(wxCoupon.getType()); | |||
| wxCouponSend.setTenantId(wxCoupon.getTenantId()); | |||
| wxCouponSend.setTitle(wxCoupon.getTitle()); | |||
| wxCouponSend.setCreateDate(new Date()); | |||
| wxCouponSend.setUpdateDate(new Date()); | |||
| //Assert.notNull(wxCouponSend.getName(), "角色名不能为空"); | |||
| //Assert.isTrue(!checkUnique(sysRole.getName(), null), "重复的角色名"); | |||
| wxCouponSendService.saveOrUpdate(wxCouponSend); | |||
| return new ResultData(); | |||
| } | |||
| @@ -87,8 +90,15 @@ public class WxCouponSendController extends BaseController { | |||
| @GetMapping("/del") | |||
| @ApiImplicitParam(name = "id", value = "id", dataType = "Long", paramType = "query", required = true) | |||
| public ResultData delete(Long id) { | |||
| wxCouponSendService.deleteById(id); | |||
| return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| //wxCouponSendService.deleteById(id); | |||
| //return new ResultData(Result.SUCCESS, "删除成功", null); | |||
| WxCouponSend wxCouponSend = wxCouponSendService.getById(id); | |||
| if (wxCouponSend == null) | |||
| return new ResultData(ErrorCode.COUPON_SEND_IS_INVALID); | |||
| wxCouponSend.setStatus(EnumCouponSendStatus.INVALID.getCode()); | |||
| wxCouponSend.setUpdateDate(new Date()); | |||
| wxCouponSendService.saveOrUpdate(wxCouponSend); | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation("根据id查询接口") | |||
| @@ -91,6 +91,7 @@ public enum ErrorCode{ | |||
| COUPON_SEND_IS_EXISTED(2028, "此券已经添加到该渠道"), | |||
| COUPON_SEND_IS_INVALID(2029, "此发券渠道不存在"), | |||
| /** | |||
| * 车流 2040 | |||
| */ | |||
| @@ -1,40 +0,0 @@ | |||
| package com.iformall.enums; | |||
| /** | |||
| * Created by Stormeye on 2018/08/09. | |||
| */ | |||
| public enum EnumCouponActionChannelType { | |||
| // 0:精准 1:主动领取 2:用户购买 3:停车 4:核销 | |||
| PRECISE(0, "精准"), | |||
| RECEIVE(1, "主动领取"), | |||
| BUY(2, "用户购买"), | |||
| CAR(3, "停车"), | |||
| VERIFY(4, "核销") | |||
| ; | |||
| public static EnumCouponActionChannelType getEnum(Integer code) { | |||
| for (EnumCouponActionChannelType value : values()) { | |||
| if (value.getCode().equals(code)) { | |||
| return value; | |||
| } | |||
| } | |||
| return null; | |||
| } | |||
| private Integer code; | |||
| private String message; | |||
| EnumCouponActionChannelType(Integer code, String message) { | |||
| this.code = code; | |||
| this.message = message; | |||
| } | |||
| public Integer getCode() { | |||
| return code; | |||
| } | |||
| public String getMessage() { | |||
| return message; | |||
| } | |||
| } | |||
| @@ -6,8 +6,11 @@ package com.iformall.enums; | |||
| public enum EnumCouponSendSendType { | |||
| // 2:停车发券 3:核销发券 | |||
| UNKNOWN(0, "不详(保留)"), | |||
| ACTIVE(1, "主动(保留)"), | |||
| CAR_STOP(2, "停车发券"), | |||
| COUPON_VERIFY(3, "核销发券") | |||
| COUPON_VERIFY(3, "核销发券"), | |||
| COUPON_INJECT(4, "精准发券") | |||
| ; | |||
| public static EnumCouponSendSendType getEnum(Integer code) { | |||
| @@ -370,7 +370,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| wxPayOrder.setOrderId(couponOrder.getOrderId()); | |||
| wxPayOrder.setPayOrderStatus(EnumPayStatus.PAY_WAY_SUCCESS.getCode()); | |||
| wxPayOrder = wxPayOrderMapper.selectOne(wxPayOrder); | |||
| if (wxPayOrder != null && wxPayOrder.getShare() == EnumPayShare.YES.getCode()) | |||
| if (wxPayOrder != null && wxPayOrder.getShare().equals(EnumPayShare.YES.getCode())) | |||
| wxProfitSharingOrderService.createSharingOrder(wxPayOrder); | |||
| } catch (Exception e) { | |||
| logger.error("微信分账: " + e.getMessage()); | |||
| @@ -72,18 +72,18 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||
| //查询停车或者核销的券 stopCarCouponSwitch verifyConponSwitch | |||
| WxCouponSend wxCouponSendQuery = new WxCouponSend(); | |||
| wxCouponSendQuery.setTenantId(tenantId); | |||
| int actionLogType = 0; | |||
| int actionType = EnumCouponSendSendType.UNKNOWN.getCode(); | |||
| String configKey = ""; | |||
| if (type == EnumCouponSendSendType.CAR_STOP) { | |||
| //停车 | |||
| wxCouponSendQuery.setSendType(EnumCouponSendSendType.CAR_STOP.getCode()); | |||
| actionLogType = EnumCouponActionChannelType.CAR.getCode(); | |||
| actionType = EnumCouponSendSendType.CAR_STOP.getCode(); | |||
| wxCouponSendQuery.setSendType(actionType); | |||
| configKey = "stopCarCouponSwitch"; | |||
| } | |||
| if (type == EnumCouponSendSendType.COUPON_VERIFY) { | |||
| //核销 | |||
| wxCouponSendQuery.setSendType(EnumCouponSendSendType.COUPON_VERIFY.getCode()); | |||
| actionLogType = EnumCouponActionChannelType.VERIFY.getCode(); | |||
| actionType = EnumCouponSendSendType.COUPON_VERIFY.getCode(); | |||
| wxCouponSendQuery.setSendType(actionType); | |||
| configKey = "verifyConponSwitch"; | |||
| } else { | |||
| return; | |||
| @@ -104,7 +104,7 @@ public class WxCouponSendServiceImpl implements WxCouponSendService { | |||
| // 发放免费券 | |||
| WxCouponOrder couponOrder = wxOrderService.sendFreeCouponToUser(cUserId, send.getCouponId()); | |||
| if (couponOrder != null) { | |||
| wxCouponActionLogService.addOne(tenantId, send.getCouponId(), couponOrder.getId(), actionLogType, send.getId()); | |||
| wxCouponActionLogService.addOne(tenantId, send.getCouponId(), couponOrder.getId(), actionType, send.getId()); | |||
| } | |||
| wxCouponService.reduceInventory(send.getCouponId(), 1); | |||
| } | |||