Browse Source

//..hexiao

release_toaliyun_real
xhxu 2 years ago
parent
commit
dc0b3cd81e
7 changed files with 140 additions and 96 deletions
  1. +4
    -32
      mallinkBApi/src/main/java/com/iformall/controller/WxCouponOrderController.java
  2. +95
    -3
      mallinkBApi/src/main/java/com/iformall/controller/WxCouponOrderReservationController.java
  3. +0
    -24
      mallinkCApi/src/main/java/com/iformall/controller/WxCouponOrderController.java
  4. +3
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxCouponOrderReservation.java
  5. +1
    -0
      mallinkService/src/main/java/com/iformall/enums/EnumCouponVerifyType.java
  6. +29
    -35
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java
  7. +8
    -2
      mallinkService/src/main/resources/mapper/WxCouponOrderReservationMapper.xml

+ 4
- 32
mallinkBApi/src/main/java/com/iformall/controller/WxCouponOrderController.java View File

@@ -341,52 +341,24 @@ public class WxCouponOrderController extends BaseController {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}

WxCouponOrderCVo wxCouponOrderCVo = null;
String couponTenantId = paramMap.get("couponTenantId");
TenantEntity couponOrderTenantEntity = getCouponOrderTenantEntity(couponTenantId);
wxCouponOrderCVo = wxCouponOrderService.detailCUserVo(couponOrderIdStr,couponOrderTenantEntity);
if (wxCouponOrderCVo == null)
return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL);

WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoService.getById(wxCouponOrderCVo.getcUserId(),wxCouponOrderCVo.getFinalTenantId());
if (wxCUserBasicInfo != null && EnumCreditLockedStatus.CLOSE.getCode().equals(wxCUserBasicInfo.getStatus())) {
return new ResultData(ErrorCode.MEMBER_IS_LOCKED);
}

Date now = new Date();
if (wxCouponOrderCVo.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME.getCode())){
// && !wxCouponOrderCVo.getType().equals(EnumCouponType.COUPON_PREORDER.getCode())) {
if (wxCouponOrderCVo.getValidStartDate().after(now)) {
logger.error("此券有效期未开始:" + couponOrderIdStr);
return new ResultData(ErrorCode.COUPON_ORDER_IS_EARLIER_THAN_VALIDDATE);
}
if (wxCouponOrderCVo.getValidEndDate().before(now)) {
logger.error("此券有效期已结束:" + couponOrderIdStr);
return new ResultData(ErrorCode.COUPON_ORDER_IS_LATER_THAN_VALIDDATE);
}

} else if(wxCouponOrderCVo.getValidType().equals(EnumCouponValidType.DAYS_AFTER_RECEIVING.getCode())){
if (wxCouponOrderCVo.getExpiredTime().before(now)) {
logger.error("此券已过期:" + couponOrderIdStr);
return new ResultData(ErrorCode.COUPON_IS_EXPIRED);
}
}

WxCouponOrder wxCouponOrder = wxCouponOrderService.getById(couponOrderId,couponOrderTenantEntity.getTenantId());
if (wxCouponOrder == null) {
logger.error("券ID不存在:" + couponOrderId);
return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL);
}
WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoService.getById(wxCouponOrder.getcUserId(),wxCouponOrder.getFinalTenantId());
if (wxCUserBasicInfo != null && EnumCreditLockedStatus.CLOSE.getCode().equals(wxCUserBasicInfo.getStatus())) {
return new ResultData(ErrorCode.MEMBER_IS_LOCKED);
}

WxMerchantBUser wxMerchantBUser = getLoginBUser();
if (wxMerchantBUser == null) {
logger.error("核销员ID不存在:" + getLoginBUser().getId());
throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(), "核销员ID不存在或者无权限");
}
Long bUserId = getWxBuserId();
if (null != bUserId) {
wxMerchantBUser.setBuserId(bUserId);
}
WxCouponOrder couponOrder = null;
try {


+ 95
- 3
mallinkBApi/src/main/java/com/iformall/controller/WxCouponOrderReservationController.java View File

@@ -1,21 +1,31 @@
package com.iformall.controller;

import com.github.pagehelper.PageInfo;
import com.iformall.annotation.TenantIgnore;
import com.iformall.common.ErrorCode;
import com.iformall.common.ResultData;
import com.iformall.domain.po.WxCouponOrderReservation;
import com.iformall.domain.po.*;
import com.iformall.domain.po.base.BaseEntity;
import com.iformall.enums.EnumCouponOrderReservationStatus;
import com.iformall.service.WxCouponOrderReservationService;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.vo.WxCouponOrderCVo;
import com.iformall.enums.*;
import com.iformall.exception.MallinkException;
import com.iformall.service.*;
import com.iformall.utils.DateUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
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;
import java.util.Map;

@RestController
@RequestMapping("/api/wxCouponOrderReservation")
@Api(description = "查询预约接口")
@@ -25,6 +35,17 @@ public class WxCouponOrderReservationController extends BaseController {
@Autowired
private WxCouponOrderReservationService wxCouponOrderReservationService;

@Autowired
private WxMerchantService wxMerchantService;

@Autowired
private WxMerchantRelationService wxMerchantRelationService;

@Autowired
private WxCouponOrderService wxCouponOrderService;

private WxCUserBasicInfoService wxCUserBasicInfoService;

@ApiOperation("分页列表接口")
@GetMapping("list")
@ApiImplicitParams({
@@ -117,5 +138,76 @@ public class WxCouponOrderReservationController extends BaseController {
return new ResultData();
}

/**
* 预约单核销
* @param reservation
* @return
*/
@ApiOperation(value = "核销接口", notes = "{\"couponOrderId\":\"string\",\"couponTenantId\":\"string\"}")
@PostMapping("verify")
public ResultData verify(@RequestBody WxCouponOrderReservation reservation) {
logger.info("WxCouponOrderReservationController.verify:");
WxMerchantBUser loginBUser = getLoginBUser();
if(reservation.getId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"id is null");
}
WxCouponOrderReservation sortReservation = wxCouponOrderReservationService.getSortById(reservation.getId(), reservation.getTenantId());
if(sortReservation == null){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"id is error");
}
if(EnumCouponOrderReservationStatus.getReservationFinish().contains(sortReservation.getStatus())){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"预约单已完成");
}
if(!EnumCouponOrderReservationStatus.getReservationIng().contains(sortReservation.getStatus())){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"预约单状态不支持核销");
}
if(sortReservation.getReservationMerchantId() == null){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"预约门店未找到");
}
//登陆商户
Long merchantId = loginBUser.getMerchantId();
//核销商户
WxMerchant merchant = null;
if(!sortReservation.getReservationMerchantId().equals(merchantId)){
WxMerchant loginMerchant = wxMerchantService.selectById(merchantId);
if(!EnumMerchantAdmin.REGIONAL.getCode().equals(loginMerchant.getIsAdmin())){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"非区域商户,核销失败");
}
List<Long> subMerchantIds = wxMerchantRelationService.getRelationByRegionId(merchant.getId());
if(!subMerchantIds.contains(sortReservation.getReservationMerchantId())){
return new ResultData(ErrorCode.SYS_PARAMETER_ERROR.getCode(),"区域门店不匹配,核销失败");
}
merchant = wxMerchantService.selectById(sortReservation.getReservationMerchantId());
}
WxCouponOrder wxCouponOrder = wxCouponOrderService.getById(sortReservation.getCouponOrderId(),sortReservation.getTenantId());
if (wxCouponOrder == null) {
logger.error("券ID不存在:" + sortReservation.getCouponOrderId());
return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL);
}

WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoService.getById(wxCouponOrder.getcUserId(),wxCouponOrder.getFinalTenantId());
if (wxCUserBasicInfo != null && EnumCreditLockedStatus.CLOSE.getCode().equals(wxCUserBasicInfo.getStatus())) {
return new ResultData(ErrorCode.MEMBER_IS_LOCKED);
}

WxCouponOrder couponOrder = null;
try {
wxCouponOrder.setVerifyRemark(EnumCouponVerifyType.VERIFY_B_13.getMessage());
couponOrder = wxCouponOrderService.verify(wxCouponOrder, merchant, EnumCouponVerifyType.VERIFY_B,loginBUser);
} catch (MallinkException e) {
logger.error("核销异常: " + e.getMessage());
return new ResultData(e.getErrorCode(), e.getMessage());
} catch (Exception e) {
logger.error("核销异常: " + e.getMessage());
return new ResultData(ErrorCode.VERIFY_ERROR, e.getMessage());
}

if (couponOrder != null) {
wxCouponOrderService.sendInsideCouponVerifyMsg(couponOrder.getId(), couponOrder, couponOrder.getBMerchantId(), loginBUser);
}

return new ResultData(couponOrder);
}


}

+ 0
- 24
mallinkCApi/src/main/java/com/iformall/controller/WxCouponOrderController.java View File

@@ -515,11 +515,6 @@ public class WxCouponOrderController extends BaseController {
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}

WxCouponOrderCVo wxCouponOrderCVo = wxCouponOrderService.detailCUserVo(couponOrderIdStr,getTenantInfo());

if (wxCouponOrderCVo == null)
return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL);

WxCUserBasicInfo member;
try {
member = getCacheMember();
@@ -527,25 +522,6 @@ public class WxCouponOrderController extends BaseController {
return new ResultData(Result.ERROR,e.getMessage());
}

Date now = new Date();
if (wxCouponOrderCVo.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME.getCode())){
// && !wxCouponOrderCVo.getType().equals(EnumCouponType.COUPON_PREORDER.getCode())) {
if (wxCouponOrderCVo.getValidStartDate().after(now)) {
logger.error("此券有效期未开始:" + couponOrderIdStr);
return new ResultData(ErrorCode.COUPON_ORDER_IS_EARLIER_THAN_VALIDDATE);
}
if (wxCouponOrderCVo.getValidEndDate().before(now)) {
logger.error("此券有效期已结束:" + couponOrderIdStr);
return new ResultData(ErrorCode.COUPON_ORDER_IS_LATER_THAN_VALIDDATE);
}

} else if(wxCouponOrderCVo.getValidType().equals(EnumCouponValidType.DAYS_AFTER_RECEIVING.getCode())){
if (wxCouponOrderCVo.getExpiredTime().before(now)) {
logger.error("此券已过期:" + couponOrderIdStr);
return new ResultData(ErrorCode.COUPON_IS_EXPIRED);
}
}

WxCouponOrder wxCouponOrder = wxCouponOrderService.getById(couponOrderId,getTenantInfo().getTenantId());
if (wxCouponOrder == null) {
logger.error("券ID不存在:" + couponOrderId);


+ 3
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxCouponOrderReservation.java View File

@@ -80,6 +80,9 @@ public class WxCouponOrderReservation extends TenantEntity {
@TableField(exist = false)
private Date serchEndDate;

@TableField(exist = false)
private List<Integer> statusList;

@TableField(exist = false)
private List<Long> reservationMerchantIdList;



+ 1
- 0
mallinkService/src/main/java/com/iformall/enums/EnumCouponVerifyType.java View File

@@ -11,6 +11,7 @@ public enum EnumCouponVerifyType {
VERIFY_B_10(10,"B端收银核销"),
VERIFY_B_11(11,"B端券码核销"),
VERIFY_B_12(12,"B端扫码核销"),
VERIFY_B_13(13,"B端预约单核销"),

VERIFY_POS_INDEPENDENT(1, "POS独立核销"),
VERIFY_POS_PAY(2, "POS交易核销"),


+ 29
- 35
mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java View File

@@ -1402,7 +1402,24 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
logger.error("券: coupon-" + wxCoupon.getId() + "不存在" + "couponOrder-" + couponOrder.getId());
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL);
}

Date now = new Date();
if (wxCoupon.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME.getCode())){
// && !wxCouponOrderCVo.getType().equals(EnumCouponType.COUPON_PREORDER.getCode())) {
if (wxCoupon.getValidStartDate().after(now)) {
logger.error("此券有效期未开始:" + couponOrder.getId());
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_EARLIER_THAN_VALIDDATE);
}
if (wxCoupon.getValidEndDate().before(now)) {
logger.error("此券有效期已结束:" + couponOrder.getId());
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_LATER_THAN_VALIDDATE);
}
}

// 3. 券包状态检查
if(couponOrder.getExpiredTime() != null && couponOrder.getExpiredTime().before(now)){
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_LATER_THAN_VALIDDATE);
}
if (couponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_OVER_TIME.getCode()) {
logger.error("已过期: couponOrder-" + couponOrder.getId());
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_OVER_TIME);
@@ -1483,14 +1500,12 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
couponOrder.setBMerchantId(merchantId==null?0l:merchantId);
couponOrder.setBTenantId(mallTenantEntity.getTenantId());
couponOrder.setVerifyType(couponVerifyType.getCode());
if(EnumCouponVerifyType.VERIFY_B.equals(couponVerifyType)
&& StringUtils.isNotBlank(couponOrder.getVerifyRemark())){
if(couponOrder.getVerifyRemark().equals(EnumCouponVerifyType.VERIFY_B_11.getCode().toString())){
couponOrder.setVerifyRemark(EnumCouponVerifyType.VERIFY_B_11.getMessage());
}else if(couponOrder.getVerifyRemark().equals(EnumCouponVerifyType.VERIFY_B_12.getCode().toString())){
couponOrder.setVerifyRemark(EnumCouponVerifyType.VERIFY_B_12.getMessage());
}
}
if(EnumCouponVerifyType.VERIFY_B.equals(couponVerifyType) && StringUtils.isNotBlank(couponOrder.getVerifyRemark())){
try{
int subVerifyType = Integer.parseInt(couponOrder.getVerifyRemark());
couponOrder.setVerifyRemark(EnumCouponVerifyType.getEnum(subVerifyType).getMessage());
}catch(Exception e){}
}
if(EnumOrderShopingType.SELF_MENTION.getCode().equals(couponOrder.getShippingType())){
couponOrder.setShippingStatus(EnumOrderShopingStatus.ALREADY_SELF_MENTION.getCode());
}else if(EnumOrderShopingType.DISTRIBUTION.getCode().equals(couponOrder.getShippingType())){
@@ -1551,37 +1566,16 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
TenantEntity tenantEntity = new TenantEntity();
tenantEntity.setTenantId(tenantId);
tenantEntity.setParentTenantId(parentTenantId);

WxCouponOrder wxCouponOrder = this.getById(couponOrderId,tenantEntity.getTenantId());
if (wxCouponOrder == null) {
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL);
}
WxCouponOrderCVo wxCouponOrderCVo = this.detailCUserVo(String.valueOf(couponOrderId),tenantEntity);
if (wxCouponOrderCVo == null) {
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL);
}
WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoService.getById(wxCouponOrderCVo.getcUserId(),wxCouponOrderCVo.getFinalTenantId());
WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoService.getById(wxCouponOrder.getcUserId(),wxCouponOrder.getFinalTenantId());
if (wxCUserBasicInfo != null && EnumCreditLockedStatus.CLOSE.getCode().equals(wxCUserBasicInfo.getStatus())) {
throw new MallinkException(ErrorCode.MEMBER_IS_LOCKED);
}
Date now = new Date();
if (wxCouponOrderCVo.getValidType().equals(EnumCouponValidType.BETWEEN_TWO_TIME.getCode())){
// && !wxCouponOrderCVo.getType().equals(EnumCouponType.COUPON_PREORDER.getCode())) {
if (wxCouponOrderCVo.getValidStartDate().after(now)) {
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_EARLIER_THAN_VALIDDATE);
}
if (wxCouponOrderCVo.getValidEndDate().before(now)) {
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_LATER_THAN_VALIDDATE);
}

} else if(wxCouponOrderCVo.getValidType().equals(EnumCouponValidType.DAYS_AFTER_RECEIVING.getCode())){
if (wxCouponOrderCVo.getExpiredTime().before(now)) {
throw new MallinkException(ErrorCode.COUPON_IS_EXPIRED);
}
}

WxCouponOrder wxCouponOrder = this.getById(couponOrderId,tenantEntity.getTenantId());
if (wxCouponOrder == null) {
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL);
}

SysConfig sysConfig = sysConfigService.getByKey(SysConfigConstant.default_merchant_b_user, tenantEntity);
if (null == sysConfig) {


+ 8
- 2
mallinkService/src/main/resources/mapper/WxCouponOrderReservationMapper.xml View File

@@ -106,6 +106,12 @@
<if test=" null != status ">
and `status` = #{status}
</if>
<if test=" null != statusList and statusList.size > 0 ">
and `status` in
<foreach collection="statusList" index="index" item="idItem" open="(" separator="," close=")">
#{idItem}
</foreach>
</if>

<if test=" null != btenantId and '' != btenantId">
and `btenant_id` = #{btenantId}
@@ -164,13 +170,13 @@
</select>

<select id="getSortById" parameterType="java.util.HashMap" resultMap="BaseResultMap">
select `id`,`tenant_id`,`parent_tenant_id`,`reservation_merchant_id`,`status`
select `id`,`tenant_id`,`parent_tenant_id`,`coupon_order_id`,`reservation_merchant_id`,`status`
from wx_coupon_order_reservation
where `id` = #{id} and tenant_id=#{tenantId}
</select>

<select id="getSortByCouponOrder" parameterType="java.util.HashMap" resultMap="BaseResultMap">
select `id`,`tenant_id`,`parent_tenant_id`,`reservation_merchant_id`,`status`
select `id`,`tenant_id`,`parent_tenant_id`,`coupon_order_id`,`reservation_merchant_id`,`status`
from wx_coupon_order_reservation
where `coupon_order_id` = #{couponOrderId} and tenant_id=#{tenantId}
</select>


Loading…
Cancel
Save