| @@ -1,5 +1,6 @@ | |||
| package com.iformall.controller; | |||
| import com.alibaba.fastjson.JSONObject; | |||
| import com.github.pagehelper.PageInfo; | |||
| import com.iformall.annotation.RedisCache; | |||
| import com.iformall.common.ErrorCode; | |||
| @@ -7,10 +8,9 @@ import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.vo.WxCouponCVo; | |||
| import com.iformall.domain.vo.WxCouponOrderBVo; | |||
| import com.iformall.domain.vo.WxCouponOrderCVo; | |||
| import com.iformall.enums.EnumCouponType; | |||
| import com.iformall.enums.EnumCouponValidType; | |||
| import com.iformall.enums.EnumCreditLockedStatus; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.*; | |||
| import io.swagger.annotations.Api; | |||
| @@ -26,7 +26,10 @@ import org.springframework.data.redis.core.RedisTemplate; | |||
| import org.springframework.data.redis.core.ValueOperations; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import java.text.SimpleDateFormat; | |||
| import java.util.ArrayList; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import java.util.concurrent.TimeUnit; | |||
| @@ -70,6 +73,33 @@ public class WxCouponOrderController extends BaseController { | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("分页列表接口") | |||
| @GetMapping("goodsList") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true)}) | |||
| public ResultData goodsList(@ModelAttribute WxCouponOrderBVo wxCouponOrderBvo, Integer pageNum, Integer pageSize) { | |||
| if (null == wxCouponOrderBvo) wxCouponOrderBvo = new WxCouponOrderBVo(); | |||
| wxCouponOrderBvo.updateTenantInfo(getTenantInfo()); | |||
| wxCouponOrderBvo.setMerchantId(getLoginBUser().getMerchantId()); | |||
| wxCouponOrderBvo.setCouponType(EnumCouponType.COUPON_DISTRIBUTION.getCode()); | |||
| List<Integer> shippingStatuss = new ArrayList<>(); | |||
| if(EnumOrderShopingStatus.WAIT_SENG_GOODS.getCode().equals(wxCouponOrderBvo.getShippingStatus())){ | |||
| shippingStatuss.add(EnumOrderShopingStatus.READY_SELF_MENTION.getCode()); | |||
| shippingStatuss.add(EnumOrderShopingStatus.READY_DISTRIBUTION.getCode()); | |||
| }else if(EnumOrderShopingStatus.SENG_GOODS.getCode().equals(wxCouponOrderBvo.getShippingStatus())){ | |||
| shippingStatuss.add(EnumOrderShopingStatus.WAIT_SELF_MENTION.getCode()); | |||
| shippingStatuss.add(EnumOrderShopingStatus.WAIT_DISTRIBUTION.getCode()); | |||
| }else if(EnumOrderShopingStatus.FINISH_SENG_GOODS.getCode().equals(wxCouponOrderBvo.getShippingStatus())){ | |||
| wxCouponOrderBvo.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode()); | |||
| } | |||
| if(shippingStatuss.size() > 0){ | |||
| wxCouponOrderBvo.setShippingStatuss(shippingStatuss); | |||
| } | |||
| final PageInfo<WxCouponOrderBVo> page = wxCouponOrderService.goodsListAsPage(wxCouponOrderBvo, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| @ApiOperation("根据id更新接口") | |||
| @PostMapping("update") | |||
| public ResultData update(@RequestBody WxCouponOrder wxCouponOrder) { | |||
| @@ -318,7 +348,7 @@ public class WxCouponOrderController extends BaseController { | |||
| } | |||
| if (couponOrder != null) { | |||
| wxCouponOrderService.sendInsideCouponVerifyMsg(couponOrder, couponOrderId, wxMerchantBUser.getId()); | |||
| wxCouponOrderService.sendInsideCouponVerifyMsg(couponOrder, couponOrderId, wxMerchantBUser.getMerchantId()); | |||
| } | |||
| return new ResultData(couponOrder); | |||
| @@ -355,4 +385,52 @@ public class WxCouponOrderController extends BaseController { | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation(value = "商品发货", notes = "{\"id\":\"string\", \"deliveryInfo\":\"jsonString\"}") | |||
| @PostMapping("/sendGoods") | |||
| public ResultData sendGoods(@RequestBody WxCouponOrder wxCouponOrder) { | |||
| logger.debug("[" + getIpAddr() + "] WxCouponPasswordController::postpone"); | |||
| if (wxCouponOrder == null || wxCouponOrder.getId() == null) { | |||
| logger.error("id不能为空: "); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| try { | |||
| WxCouponOrder couponOrder = wxCouponOrderService.getById(wxCouponOrder.getId(), getTenantInfo().getTenantId()); | |||
| if(couponOrder==null){ | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| } | |||
| if(!EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode().equals(couponOrder.getCouponOrderStatus())){ | |||
| return new ResultData(ErrorCode.COUPON_GOODS_STATUS_NOT_SUPPORTED); | |||
| } | |||
| WxCouponOrder updateCouponOrder = new WxCouponOrder(); | |||
| updateCouponOrder.setId(couponOrder.getId()); | |||
| if(EnumOrderShopingType.SELF_MENTION.getCode().equals(couponOrder.getShippingType())){ | |||
| updateCouponOrder.setShippingStatus(EnumOrderShopingStatus.READY_SELF_MENTION.getCode()); | |||
| }else if(EnumOrderShopingType.DISTRIBUTION.getCode().equals(couponOrder.getShippingType())){ | |||
| if(StringUtils.isBlank(wxCouponOrder.getDeliveryInfo())){ | |||
| return new ResultData(ErrorCode.COUPON_GOODS_DELIVERY_NULL); | |||
| } | |||
| try{ | |||
| JSONObject jsonObject = JSONObject.parseObject(wxCouponOrder.getDeliveryInfo()); | |||
| jsonObject.put("date",new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); | |||
| updateCouponOrder.setDeliveryInfo(JSONObject.toJSONString(jsonObject)); | |||
| }catch(Exception e){ | |||
| return new ResultData(ErrorCode.COUPON_GOODS_ADDRESS_ERROR); | |||
| } | |||
| updateCouponOrder.setShippingStatus(EnumOrderShopingStatus.WAIT_DISTRIBUTION.getCode()); | |||
| }else{ | |||
| return new ResultData(ErrorCode.COUPON_GOODS_TYPE_NOT_SUPPORTED); | |||
| } | |||
| updateCouponOrder.setUpdateDate(new Date()); | |||
| wxCouponOrderService.saveOrUpdate(updateCouponOrder); | |||
| } catch (Exception e) { | |||
| logger.error(e.getMessage()); | |||
| return new ResultData(ErrorCode.SYS_SERVER_ERROR); | |||
| } | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| @@ -5,19 +5,14 @@ import com.iformall.annotation.RedisCache; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.common.Result; | |||
| import com.iformall.common.ResultData; | |||
| import com.iformall.domain.po.WxCUser; | |||
| import com.iformall.domain.po.WxCUserBasicInfo; | |||
| import com.iformall.domain.po.WxCoupon; | |||
| import com.iformall.domain.po.*; | |||
| import com.iformall.domain.po.base.BaseEntity; | |||
| import com.iformall.domain.po.WxCouponOrder; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.WxCardCVo; | |||
| import com.iformall.domain.vo.WxCouponCVo; | |||
| import com.iformall.domain.vo.WxCouponOrderCVo; | |||
| import com.iformall.enums.EnumCouponChannelActivityStatus; | |||
| import com.iformall.enums.EnumCouponOrderStatus; | |||
| import com.iformall.enums.EnumCouponOrderValidStatus; | |||
| import com.iformall.enums.EnumCouponType; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.MemCouponFromDspService; | |||
| import com.iformall.service.WxCouponOrderService; | |||
| import com.iformall.service.WxCouponService; | |||
| @@ -409,4 +404,87 @@ public class WxCouponOrderController extends BaseController { | |||
| return new ResultData(); | |||
| } | |||
| @ApiOperation(value = "核销接口", notes = "{\"couponOrderId\":\"string\"}") | |||
| @PostMapping("verify") | |||
| public ResultData verify(@RequestBody Map<String, String> paramMap) { | |||
| logger.info("couponOrderController.verify:" + paramMap.toString()); | |||
| String couponOrderIdStr = paramMap.get("couponOrderId"); | |||
| if (StringUtils.isBlank(couponOrderIdStr)) { | |||
| logger.error("couponOrderId不能为空: " + paramMap.toString()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL); | |||
| } | |||
| Long couponOrderId = 0L; | |||
| try { | |||
| couponOrderId = Long.valueOf(couponOrderIdStr); | |||
| } catch (NumberFormatException e) { | |||
| couponOrderId = 0L; | |||
| logger.error("couponOrderId参数不正确: " + paramMap.toString()); | |||
| 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(); | |||
| } catch (Exception e) { | |||
| 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.getType().equals(EnumCouponType.COUPON_PREORDER.getCode())){ | |||
| if (wxCouponOrderCVo.getPickStartDate().after(now)) { | |||
| logger.error("此券有效期未开始:" + couponOrderIdStr); | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_EARLIER_THAN_VALIDDATE); | |||
| } | |||
| if (wxCouponOrderCVo.getPickEndDate().before(now)) { | |||
| logger.error("此券有效期已结束:" + couponOrderIdStr); | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_LATER_THAN_VALIDDATE); | |||
| } | |||
| }else{ | |||
| 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.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); | |||
| return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| } | |||
| if(!member.getId().equals(wxCouponOrder.getCUserId())){ | |||
| logger.error("此券不属于此人:" + member.getId()); | |||
| return new ResultData(ErrorCode.SYS_PARAMETER_ERROR); | |||
| } | |||
| WxCouponOrder couponOrder = null; | |||
| try { | |||
| couponOrder = wxCouponOrderService.verify(wxCouponOrder); | |||
| } 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()); | |||
| } | |||
| return new ResultData(couponOrder); | |||
| } | |||
| } | |||
| @@ -435,4 +435,29 @@ public class WxOrderController extends BaseController { | |||
| } | |||
| @ApiOperation("分页订单列表接口") | |||
| @GetMapping("listGoods") | |||
| @ApiImplicitParams({ | |||
| @ApiImplicitParam(name = "pageNum", value = "页数", dataType = "int", paramType = "query", required = true), | |||
| @ApiImplicitParam(name = "pageSize", value = "每页条数", dataType = "int", paramType = "query", required = true), | |||
| }) | |||
| public ResultData listGoods(@ModelAttribute WxOrder wxOrder, Integer pageNum, Integer pageSize) { | |||
| // c端用户应该只能看到自己的订单 | |||
| if (wxOrder == null){ | |||
| wxOrder = new WxOrder(); | |||
| } | |||
| Long memberId; | |||
| try { | |||
| memberId = getMemberId(); | |||
| } catch (Exception e) { | |||
| return new ResultData(Result.ERROR,e.getMessage()); | |||
| } | |||
| wxOrder.setCUserId(memberId); | |||
| wxOrder.setSortColumns(BaseEntity.SortField.UpdateDate_DESC); | |||
| final PageInfo<WxOrderCouponVo> page = wxOrderService.listGoodsCAsPage(wxOrder, pageNum, pageSize); | |||
| return new ResultData(page); | |||
| } | |||
| } | |||
| @@ -2186,6 +2186,7 @@ public class PosServiceImpl implements PosService { | |||
| updateCO.setId(couponOrderId); | |||
| updateCO.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode()); | |||
| updateCO.setPayVendor(EnumPayWay.PAY_WAY_POS_NEU.getCode()); | |||
| couponOrderMapper.updateById(updateCO); | |||
| } | |||
| WxCouponOrderCVo couponOrderCVo = couponOrderService.detailCUserVo(posPayOrderNo,merchantBUser); | |||
| @@ -2214,7 +2215,7 @@ public class PosServiceImpl implements PosService { | |||
| logger.error("交易核销积分异常:" + e.getMessage()); | |||
| } | |||
| // 3. 核销后处理 | |||
| couponOrderService.sendInsideCouponVerifyMsg(merchantBUser, couponOrderId, merchantBUser.getId()); | |||
| couponOrderService.sendInsideCouponVerifyMsg(merchantBUser, couponOrderId, merchantBUser.getMerchantId()); | |||
| } | |||
| return payOrder; | |||
| } | |||
| @@ -224,6 +224,14 @@ public enum ErrorCode{ | |||
| COUPON_MANJIAN_USE_PRICE_NO_ALLOW_(4011, "满减券金额不符合条件"), | |||
| COUPON_ORDER_TYPE_NOT_SUPPORTED(4012, "券类型不支持"), | |||
| /** | |||
| * 商品 | |||
| */ | |||
| COUPON_GOODS_DELIVERY_NULL(5000,"物流信息为空"), | |||
| COUPON_GOODS_TYPE_NOT_SUPPORTED(5001,"该类型不支持发货"), | |||
| COUPON_GOODS_STATUS_NOT_SUPPORTED(5002,"该状态不支持发货"), | |||
| COUPON_GOODS_ADDRESS_ERROR(5003,"配送信息错误"), | |||
| /** | |||
| * 卡 | |||
| */ | |||
| @@ -12,6 +12,7 @@ import lombok.ToString; | |||
| import java.math.BigDecimal; | |||
| import java.text.DecimalFormat; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @TableName(value = "wx_coupon_order") | |||
| @Data | |||
| @@ -156,4 +157,7 @@ public class WxCouponOrder extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="配送信息",name="deliveryInfo") | |||
| private String deliveryInfo; | |||
| @TableField(exist = false) | |||
| private List<Integer> shippingStatuss; | |||
| } | |||
| @@ -16,6 +16,6 @@ public class FmInsideCouponVerifyMsg extends BaseMsg{ | |||
| private String parentTenantId; | |||
| @io.swagger.annotations.ApiModelProperty(value = "券包ID", name = "couponOrderId") | |||
| private Long couponOrderId; | |||
| @io.swagger.annotations.ApiModelProperty(value = "B端用户ID", name = "bUserId") | |||
| private Long bUserId; | |||
| @io.swagger.annotations.ApiModelProperty(value = "B端商户ID", name = "merchantId") | |||
| private Long merchantId; | |||
| } | |||
| @@ -22,6 +22,11 @@ public class WxOrderCouponVo extends TenantEntity { | |||
| @TableField(exist = false) | |||
| private Integer validStatus; | |||
| @TableField(exist = false) | |||
| private Integer level; | |||
| @TableField(exist = false) | |||
| private List<WxOrderCouponVo> orderCouponVoList; | |||
| /** 基础购买到的券信息 */ | |||
| @io.swagger.annotations.ApiModelProperty(value="订单码;正反向交易保持一致。",name="orderNumber") | |||
| private Long orderNumber; | |||
| @@ -111,6 +116,9 @@ public class WxOrderCouponVo extends TenantEntity { | |||
| @io.swagger.annotations.ApiModelProperty(value="组合订单编号",name="composeOrderId") | |||
| private Long composeOrderId; | |||
| @io.swagger.annotations.ApiModelProperty(value="商品数量",name="couponNumber") | |||
| private Integer couponNumber; | |||
| @io.swagger.annotations.ApiModelProperty(value="运费",name="freightPrice") | |||
| private Integer freightPrice; | |||
| @@ -10,7 +10,8 @@ public enum EnumComposeOrder { | |||
| SINGLE(0, "单个订单类型,如拼团,砍价"), | |||
| ONE_NUMBER_ORDER_BATCH(1, "购物车式组合下单,1个数量1个订单(针对同样产品)"), | |||
| MULITY_NUMBER_ORDER_BATCH(2,"购物车式组合下单,多个数量1个订单(针对同样产品)"), | |||
| PACKAGECOUPON(3,"券包订单类型") | |||
| PACKAGECOUPON(3,"券包订单类型"), | |||
| PACKAGECOUPON_SUB(4,"券包子订单类型") | |||
| ; | |||
| public static EnumComposeOrder getEnum(Integer code) { | |||
| @@ -14,6 +14,8 @@ public enum EnumCouponVerifyType { | |||
| VERIFY_POS_INDEPENDENT(1, "POS独立核销"), | |||
| VERIFY_POS_PAY(2, "POS交易核销"), | |||
| VERIFY_C(3,"用户自主核销"), | |||
| ; | |||
| public static EnumCouponVerifyType getEnum(Integer code) { | |||
| @@ -9,6 +9,11 @@ public enum EnumOrderShopingStatus { | |||
| ONLINE_PURCHASE(0,"线上购买"),//不需要发货 | |||
| WAIT_SENG_GOODS(1,"待发货(查询用)"), | |||
| SENG_GOODS(2,"已发货(查询用)"), | |||
| FINISH_SENG_GOODS(3,"已完成(查询用)"), | |||
| READY_SELF_MENTION(10,"自提商品准备中"), | |||
| WAIT_SELF_MENTION(14,"已备货,待自提"), | |||
| ALREADY_SELF_MENTION(15,"已自提"), | |||
| @@ -94,4 +94,6 @@ public interface WxCouponOrderMapper extends CommonMapper<WxCouponOrder, Long> { | |||
| List<Long> cardDeferCouponOrderId(@Param("couponId")Long couponId,@Param("tenantId")String tenantId); | |||
| Integer findWriteOffCount(WxCouponOrder wxCouponOrder); | |||
| List<WxCouponOrderBVo> findGoodsList(WxCouponOrderBVo record); | |||
| } | |||
| @@ -66,5 +66,6 @@ public interface WxOrderMapper extends CommonMapper<WxOrder, Long> { | |||
| void updateOrderStatusForGroup(@Param("tenantId")String tenantId); | |||
| void updateCUserId(WxOrder updateOrder); | |||
| List<WxOrderCouponVo> listGoodsCAsPage(WxOrder record); | |||
| } | |||
| @@ -57,25 +57,32 @@ public interface WxCouponOrderService { | |||
| */ | |||
| WxCouponOrder verify(WxCouponOrder couponOrder, WxMerchantBUser bUser); | |||
| /** | |||
| * 根据主键couponOrderId(券码)核销 | |||
| * C端自主核销 | |||
| * | |||
| * @param couponOrder | |||
| */ | |||
| WxCouponOrder verify(WxCouponOrder couponOrder); | |||
| /** | |||
| * 核销后发送消息 | |||
| */ | |||
| void sendInsideCouponVerifyMsg(TenantEntity tenantEntity, Long couponOrderId, Long buUserId); | |||
| void sendInsideCouponVerifyMsg(TenantEntity tenantEntity, Long couponOrderId, Long merchantId); | |||
| /** | |||
| * 核销后处理 | |||
| * | |||
| * @param couponOrder | |||
| * @param bUser 核销人(登录用户) | |||
| * @param | |||
| */ | |||
| void actionAfterVerify(WxCouponOrder couponOrder, WxMerchantBUser bUser); | |||
| void actionAfterVerify(WxCouponOrder couponOrder, WxMerchant merchant); | |||
| /** | |||
| * 核销发券 | |||
| * @param couponOrder | |||
| * @param bUser | |||
| */ | |||
| boolean sendCouponAfterVerify(WxCouponOrder couponOrder, WxMerchantBUser bUser); | |||
| boolean sendCouponAfterVerify(WxCouponOrder couponOrder); | |||
| /** | |||
| * B端刷卡支付发券 | |||
| @@ -99,9 +106,9 @@ public interface WxCouponOrderService { | |||
| /** | |||
| * 核销模板消息 | |||
| * @param couponOrder | |||
| * @param bUser | |||
| * @param merchant | |||
| */ | |||
| void sendVerifyMsg(WxCouponOrder couponOrder, WxMerchantBUser bUser, boolean hadSentCoupon); | |||
| void sendVerifyMsg(WxCouponOrder couponOrder, WxMerchant merchant, boolean hadSentCoupon); | |||
| /** | |||
| * 根据日期 b用户查券list | |||
| @@ -221,4 +228,6 @@ public interface WxCouponOrderService { | |||
| void statisticsWriteOff(WxCouponOrder wxCouponOrder, Map<String, Object> resultMap); | |||
| Integer findCount(WxCouponOrder wxCouponOrder); | |||
| PageInfo<WxCouponOrderBVo> goodsListAsPage(WxCouponOrderBVo couponOrderBvo, Integer pageNum, Integer pageSize); | |||
| } | |||
| @@ -244,4 +244,5 @@ public interface WxOrderService { | |||
| ResultData composeSaveOrder(boolean allowUnPayOrder,EnumComposeOrder composeOrderType,List<OrderComposeSaveDto> composeOrderSaveDto,Long cUserId,EnumPayWay payWay,TenantEntity tenantEntity); | |||
| PageInfo<WxOrderCouponVo> listGoodsCAsPage(WxOrder wxOrder, Integer pageNum, Integer pageSize); | |||
| } | |||
| @@ -462,6 +462,11 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| couponOrder.setVerifyRemark(EnumCouponVerifyType.VERIFY_B_12.getMessage()); | |||
| } | |||
| } | |||
| if(EnumOrderShopingType.SELF_MENTION.getCode().equals(couponOrder.getShippingType())){ | |||
| couponOrder.setShippingStatus(EnumOrderShopingStatus.ALREADY_SELF_MENTION.getCode()); | |||
| }else if(EnumOrderShopingType.DISTRIBUTION.getCode().equals(couponOrder.getShippingType())){ | |||
| couponOrder.setShippingStatus(EnumOrderShopingStatus.ALREADY_DISTRIBUTION.getCode()); | |||
| } | |||
| couponOrder.setUpdateDate(new Date()); | |||
| num = wxCouponOrderMapper.updateVerifyCouponOrder(couponOrder); | |||
| } catch (Exception e) { | |||
| @@ -475,12 +480,108 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| doAfterVerify(couponOrder, bUser, wxCoupon); | |||
| return couponOrder; | |||
| } | |||
| @Override | |||
| @Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) | |||
| public WxCouponOrder verify(WxCouponOrder couponOrder) { | |||
| // 1. 获取券信息 | |||
| WxCoupon wxCoupon = wxCouponMapper.selectById(couponOrder.getCouponId(),couponOrder.getTenantId()); | |||
| if (wxCoupon == null) { | |||
| logger.error("券: coupon-" + wxCoupon.getId() + "不存在" + "couponOrder-" + couponOrder.getId()); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL); | |||
| } | |||
| // 2. 检查适用门店(自主核销有且只有一个门店) | |||
| WxCouponMerchant wxCouponMerchant = new WxCouponMerchant(); | |||
| wxCouponMerchant.setProductId(wxCoupon.getId()); | |||
| wxCouponMerchant.setStatus(EnumCouponMerchantStatus.COUPON_MERCHANT_STATUS_VALID.getCode()); | |||
| WxCouponMerchant cm = null; | |||
| try{ | |||
| cm = wxCouponMerchantMapper.selectOne(new QueryWrapper<>(wxCouponMerchant)); | |||
| }catch (Exception e){ | |||
| throw new MallinkException(ErrorCode.VERIFY_COUPON_ORDER_MERCHANT_IS_NULL); | |||
| } | |||
| if(cm == null){ | |||
| throw new MallinkException(ErrorCode.VERIFY_COUPON_ORDER_MERCHANT_IS_NULL); | |||
| } | |||
| // 3. 券包状态检查 | |||
| if (couponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_OVER_TIME.getCode()) { | |||
| logger.error("已过期: couponOrder-" + couponOrder.getId()); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_OVER_TIME); | |||
| } | |||
| if (couponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_INVALID.getCode()) { | |||
| logger.error("已退款: couponOrder-" + couponOrder.getId()); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_INVALID); | |||
| } | |||
| if (couponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_USED.getCode()) { | |||
| logger.error("已经核销过的券: couponOrder-" + couponOrder.getId()); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_USED); | |||
| } | |||
| if (couponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.POS_PRE_VERIFY.getCode()) { | |||
| logger.error("券已被预核销: couponOrder-" + couponOrder.getId()); | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_PRE_VERIFY); | |||
| } | |||
| //如果开启了分账,就必须要配置分账账号 | |||
| WxAppinfo appInfo = getAppinfo(couponOrder,couponOrder.getPayVendor()); | |||
| WxPayAccount payAccount = wxPayAccountMapper.selectById(appInfo.getPayId()); | |||
| WxProfitSharingReceiver psReceiverQ = new WxProfitSharingReceiver(); | |||
| psReceiverQ.updateTenantInfo(payAccount); | |||
| psReceiverQ.setMerchantId(cm.getMerchantId()); | |||
| psReceiverQ.setSharingType(payServiceFactory.getPayShareAdapterService(couponOrder.getPayVendor()).getProfitSharingType()); | |||
| psReceiverQ.setStatus(EnumProfitSharingReceiverStatus.PROFIT_SHARING_RECEIVER_STATUS_VALID.getCode()); | |||
| List<WxProfitSharingReceiver> psReceiverList = wxProfitSharingReceiverMapper.findList(psReceiverQ); | |||
| if (null == payAccount.getShare()) { | |||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getCode(),"该租户payAccount未设置分账."); | |||
| } | |||
| if (EnumPayShare.YES.getCode().intValue() == payAccount.getShare().intValue()) { | |||
| if (null == psReceiverList || psReceiverList.size() == 0) { | |||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getCode(),"该商户未设置分账账号."); | |||
| }else { | |||
| for (WxProfitSharingReceiver receiver:psReceiverList) { | |||
| if (EnumProfitSharingReceiverType.PROFIT_SHARING_RECEIVER_PERSONAL_WECHATID.getCode().intValue() | |||
| == receiver.getReceiverType().intValue()) { | |||
| throw new MallinkException(ErrorCode.PROFIT_SHARING_RECEIVER_INVALID.getCode(),"该商户收款账号存在个人微信号方式,微信已停止支持,请重新设置."); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| int num = 0; | |||
| try { | |||
| couponOrder.setCouponOrderStatus(EnumCouponOrderStatus.COUPON_ORDER_USED.getCode()); //1核销 | |||
| couponOrder.setVerifyType(EnumCouponVerifyType.VERIFY_C.getCode()); | |||
| if(EnumOrderShopingType.SELF_MENTION.getCode().equals(couponOrder.getShippingType())){ | |||
| couponOrder.setShippingStatus(EnumOrderShopingStatus.ALREADY_SELF_MENTION.getCode()); | |||
| }else if(EnumOrderShopingType.DISTRIBUTION.getCode().equals(couponOrder.getShippingType())){ | |||
| couponOrder.setShippingStatus(EnumOrderShopingStatus.ALREADY_DISTRIBUTION.getCode()); | |||
| } | |||
| couponOrder.setUpdateDate(new Date()); | |||
| num = wxCouponOrderMapper.updateVerifyCouponOrder(couponOrder); | |||
| } catch (Exception e) { | |||
| logger.error("db failed: couponOrder-" + couponOrder.getId() + ", e:" + e.getMessage()); | |||
| throw new MallinkException(ErrorCode.DB_FAIL.getCode(), "DB FAILD " + e.getMessage()); | |||
| } | |||
| if (num != 1) { | |||
| logger.error("核销异常:updatete num " + num); | |||
| throw new MallinkException(ErrorCode.VERIFY_ERROR.getCode(), "updatete num " + num); | |||
| } | |||
| doAfterVerify(couponOrder, wxCoupon, cm.getMerchantId()); | |||
| this.sendInsideCouponVerifyMsg(couponOrder, couponOrder.getId(), cm.getMerchantId()); | |||
| return couponOrder; | |||
| } | |||
| /** | |||
| * B端核销卷增加成长值,积分 | |||
| * @param couponOrder | |||
| * @param bUser | |||
| * @param wxCoupon | |||
| */ | |||
| private void doAfterVerify(WxCouponOrder couponOrder, WxMerchantBUser bUser, WxCoupon wxCoupon) { | |||
| // 成长值 | |||
| try { | |||
| WxOrder order = wxOrderMapper.selectById(couponOrder.getOrderId(),couponOrder.getTenantId()); | |||
| wxScoreRulesService.addScore2(bUser,EnumScoreType.CONSUMPTION, order, wxCoupon.getBusiness()); | |||
| wxScoreRulesService.addScore2(couponOrder,EnumScoreType.CONSUMPTION, order, wxCoupon.getBusiness()); | |||
| } catch (Exception e) { | |||
| logger.error("成长值:" + e.getMessage()); | |||
| } | |||
| @@ -511,6 +612,12 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| } | |||
| } | |||
| /** | |||
| * 核销停车劵增加成长值,积分 | |||
| * @param couponOrder | |||
| * @param wxCoupon | |||
| * @param cuUser | |||
| */ | |||
| private void doAfterVerify(WxCouponOrder couponOrder, WxCoupon wxCoupon, WxCUserBasicInfo cuUser) { | |||
| // 成长值 | |||
| try { | |||
| @@ -542,18 +649,56 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| } | |||
| } | |||
| /** | |||
| * 自主核销商品加成长值 积分 | |||
| * @param couponOrder | |||
| * @param wxCoupon | |||
| */ | |||
| private void doAfterVerify(WxCouponOrder couponOrder, WxCoupon wxCoupon,Long merchantId) { | |||
| // 成长值 | |||
| try { | |||
| WxOrder order = wxOrderMapper.selectById(couponOrder.getOrderId(),couponOrder.getTenantId()); | |||
| wxScoreRulesService.addScore2(couponOrder,EnumScoreType.CONSUMPTION, order, wxCoupon.getBusiness()); | |||
| } catch (Exception e) { | |||
| logger.error("成长值:" + e.getMessage()); | |||
| } | |||
| // 积分 | |||
| try { | |||
| //-------此处为【现金支付】记录增加积分操作------- | |||
| WxCreditHistory creditHistory = new WxCreditHistory(); | |||
| creditHistory.setOperatorType(EnumUserType.CUSERBASIC.getCode()); | |||
| creditHistory.setOperatorId(couponOrder.getCUserId()); | |||
| creditHistory.setCUserId(couponOrder.getCUserId()); | |||
| creditHistory.setCreateDate(new Date()); | |||
| // creditHistory.updateTenantInfo(couponOrder); | |||
| creditHistory.setTenantId(couponOrder.getFinalTenantId()); | |||
| creditHistory.setFinalTenantId(couponOrder.getFinalTenantId()); | |||
| creditHistory.setCreditType(EnumScoreType.CONSUMPTION.getCode()); | |||
| creditHistory.setCouponId(wxCoupon.getId()); | |||
| creditHistory.setBusinessId(wxCoupon.getBusiness()); | |||
| creditHistory.setSpend(couponOrder.getCouponPrice()); | |||
| //如果券与商户一对一 则直接将消费商户更新为此商户 若一对多 则消费商户显示多商户 | |||
| creditHistory.setMerchantId(merchantId); | |||
| creditHistory.setChangePurpose("用户自主核销增加积分:券名称["+wxCoupon.getTitle()+"("+creditHistory.getSpendStr()+"元)] "); | |||
| wxCreditHistoryService.saveOrUpdate(creditHistory,couponOrder.getTenantId()); | |||
| } catch (Exception e) { | |||
| logger.error("积分值:" + e.getMessage()); | |||
| } | |||
| } | |||
| @Override | |||
| public void sendInsideCouponVerifyMsg(TenantEntity tenantEntity, Long couponOrderId, Long buUserId) { | |||
| public void sendInsideCouponVerifyMsg(TenantEntity tenantEntity, Long couponOrderId, Long merchantId) { | |||
| FmInsideCouponVerifyMsg verifyMsg = new FmInsideCouponVerifyMsg(); | |||
| verifyMsg.setMsgType(EnumMsgRecordType.INSIDE_COUPON_VERIFY.getCode()); | |||
| verifyMsg.updateTenantInfo(tenantEntity); | |||
| verifyMsg.setCouponOrderId(couponOrderId); | |||
| verifyMsg.setBUserId(buUserId); | |||
| verifyMsg.setMerchantId(merchantId); | |||
| mqBaseProducer.sendMessage(verifyMsg, EnumMsgMqTopic.DEFAULT.getCode(), EnumMsgMqTag.DEFAULT.getCode(), EnumMsgMqKey.DEFAULT.getCode()); | |||
| } | |||
| @Override | |||
| public void actionAfterVerify(WxCouponOrder couponOrder, WxMerchantBUser bUser) { | |||
| public void actionAfterVerify(WxCouponOrder couponOrder, WxMerchant merchant) { | |||
| WxPayAccount wxPayAccountQuery = new WxPayAccount(); | |||
| wxPayAccountQuery.updateTenantInfo(couponOrder); | |||
| @@ -562,7 +707,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| try { | |||
| // 核销记账,并且往账户里面记帐 | |||
| if (couponOrder.getCouponPrice() > 0) { | |||
| recordAfterVerified(couponOrder, bUser.getMerchantId()); | |||
| recordAfterVerified(couponOrder, merchant.getId()); | |||
| } | |||
| } catch (Exception e) { | |||
| logger.error("核销记账失败"+e.getMessage(),e); | |||
| @@ -572,14 +717,14 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| if (EnumComposeOrder.isSingle(couponOrder.getComposeOrderType())) { | |||
| try { | |||
| // 核销分账 | |||
| shareAfterVerify(couponOrder, bUser.getMerchantId(),couponOrder.getPayVendor(),false); | |||
| shareAfterVerify(couponOrder, merchant.getId(),couponOrder.getPayVendor(),false); | |||
| } catch (Exception e) { | |||
| logger.error("核销记账失败"+e.getMessage(),e); | |||
| } | |||
| }else { | |||
| try { | |||
| // 核销分账 | |||
| shareAfterVerify(couponOrder, bUser.getMerchantId(),couponOrder.getPayVendor(),true); | |||
| shareAfterVerify(couponOrder, merchant.getId(),couponOrder.getPayVendor(),true); | |||
| } catch (Exception e) { | |||
| logger.error("核销记账失败"+e.getMessage(),e); | |||
| } | |||
| @@ -588,7 +733,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| try { | |||
| // 核销补贴 | |||
| subsidyAfterVerify(couponOrder, bUser.getMerchantId()); | |||
| subsidyAfterVerify(couponOrder, merchant.getId()); | |||
| } catch (Exception e) { | |||
| logger.error("核销记账失败"+e.getMessage(),e); | |||
| } | |||
| @@ -597,14 +742,14 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| // 核销发券 | |||
| try { | |||
| bSentCoupon = sendCouponAfterVerify(couponOrder, bUser); | |||
| bSentCoupon = sendCouponAfterVerify(couponOrder); | |||
| } catch (Exception e) { | |||
| logger.error("核销记账失败"+e.getMessage(),e); | |||
| } | |||
| // 核销发模板消息 | |||
| try { | |||
| sendVerifyMsg(couponOrder, bUser, bSentCoupon); | |||
| sendVerifyMsg(couponOrder, merchant, bSentCoupon); | |||
| } catch (Exception e) { | |||
| logger.error("核销发送消息发生错误:" + e.getMessage(),e); | |||
| } | |||
| @@ -800,7 +945,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| } | |||
| @Override | |||
| public boolean sendCouponAfterVerify(WxCouponOrder couponOrder, WxMerchantBUser bUser) { | |||
| public boolean sendCouponAfterVerify(WxCouponOrder couponOrder) { | |||
| // 核销发券 | |||
| WxOrder wxOrder = wxOrderMapper.selectById(couponOrder.getOrderId(),couponOrder.getTenantId()); | |||
| if (wxOrder != null) { | |||
| @@ -833,7 +978,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| * @param couponOrder, bUser | |||
| */ | |||
| @Override | |||
| public void sendVerifyMsg(WxCouponOrder couponOrder, WxMerchantBUser bUser, boolean hadSentCoupon) { | |||
| public void sendVerifyMsg(WxCouponOrder couponOrder, WxMerchant merchant, boolean hadSentCoupon) { | |||
| // 1. get order info | |||
| WxOrder order = wxOrderMapper.selectById(couponOrder.getOrderId(),couponOrder.getTenantId()); | |||
| if (order == null) { | |||
| @@ -846,18 +991,18 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| logger.error("找不到券信息"); | |||
| throw new MallinkException(ErrorCode.COUPON_IS_EMPTY); | |||
| } | |||
| // 3. merchant info | |||
| WxMerchant merchant = wxMerchantMapper.selectById(bUser.getMerchantId()); | |||
| if (merchant == null) { | |||
| logger.error("找不到商户信息"); | |||
| throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_FOUND); | |||
| } | |||
| // // 3. merchant info | |||
| // WxMerchant merchant = wxMerchantMapper.selectById(merchant.getId()); | |||
| // if (merchant == null) { | |||
| // logger.error("找不到商户信息"); | |||
| // throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_FOUND); | |||
| // } | |||
| // 4. get user info | |||
| WxCUser user = null; | |||
| WxCUser wcuQ = new WxCUser(); | |||
| wcuQ.updateTenantInfo(bUser); | |||
| wcuQ.updateTenantInfo(couponOrder); | |||
| wcuQ.setUserId(couponOrder.getCUserId()); | |||
| List<WxCUser> list = wxCUserMapper.findList(wcuQ); | |||
| if(list != null && list.size() > 0){ | |||
| @@ -1607,4 +1752,9 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService { | |||
| return wxCouponOrderMapper.findCount(wxCouponOrder); | |||
| } | |||
| @Override | |||
| public PageInfo<WxCouponOrderBVo> goodsListAsPage(WxCouponOrderBVo record, Integer pageIndex, Integer pageSize) { | |||
| return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findGoodsList(record)); | |||
| } | |||
| } | |||
| @@ -2519,7 +2519,22 @@ public class WxOrderServiceImpl implements WxOrderService { | |||
| } | |||
| @Override | |||
| public PageInfo<WxOrderCouponVo> listGoodsCAsPage(WxOrder record, Integer pageIndex, Integer pageSize) { | |||
| PageInfo<WxOrderCouponVo> page = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxOrderMapper.listGoodsCAsPage(record)); | |||
| page.getList().stream().forEach(oc->{ | |||
| if(oc.getLevel().equals(1)){ | |||
| record.setComposeOrderId(oc.getComposeOrderId()); | |||
| record.setOrderStatus(oc.getOrderStatus()); | |||
| List<WxOrderCouponVo> orderCouponVoList = wxOrderMapper.findListOfCUser(record); | |||
| oc.setOrderCouponVoList(orderCouponVoList); | |||
| } | |||
| }); | |||
| return page; | |||
| } | |||
| private WxCoupon singleOrderCheck(OrderSaveDto orderSaveDto,int productCount,WxCUserBasicInfo wxCUserBasicInfo,EnumPayWay payWay,TenantEntity tenantEntity,int curindex,boolean singleProduct) { | |||
| logger.info("OrderSave: " + orderSaveDto); | |||
| String premsg = ""; | |||
| @@ -981,7 +981,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| // 更新后处理 | |||
| wxCouponOrderService.sendInsideCouponVerifyMsg(unPayOrder, unPayOrder.getPosPayOrderId(), user.getId()); | |||
| wxCouponOrderService.sendInsideCouponVerifyMsg(unPayOrder, unPayOrder.getPosPayOrderId(), user.getMerchantId()); | |||
| } | |||
| } | |||
| } catch (Exception e) { | |||
| @@ -1105,7 +1105,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService { | |||
| logger.error(e.getMessage()); | |||
| } | |||
| // 更新后处理 | |||
| wxCouponOrderService.sendInsideCouponVerifyMsg(unPayOrder, unPayOrder.getPosPayOrderId(), user.getId()); | |||
| wxCouponOrderService.sendInsideCouponVerifyMsg(unPayOrder, unPayOrder.getPosPayOrderId(), user.getMerchantId()); | |||
| } | |||
| } | |||
| } catch (Exception e) { | |||
| @@ -28,6 +28,9 @@ public class FmInsideCouponVerifyMsgServiceImpl implements MsgSendService { | |||
| @Autowired | |||
| private WxMerchantBUserService merchantBUserService; | |||
| @Autowired | |||
| private WxMerchantService merchantService; | |||
| @Override | |||
| public void send(BaseMsg baseMsg) throws Exception{ | |||
| FmInsideCouponVerifyMsg msg = (FmInsideCouponVerifyMsg)baseMsg; | |||
| @@ -37,12 +40,12 @@ public class FmInsideCouponVerifyMsgServiceImpl implements MsgSendService { | |||
| throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL.getCode(), "券包ID未找到" + msg.getCouponOrderId()); | |||
| } | |||
| WxMerchantBUser user = merchantBUserService.getById(msg.getBUserId()); | |||
| if(user == null) { | |||
| logger.error("用户未找到: " + msg.getBUserId()); | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(), "用户未找到" + msg.getBUserId()); | |||
| WxMerchant merchant = merchantService.selectById(msg.getMerchantId()); | |||
| if(merchant == null) { | |||
| logger.error("门店未找到: " + msg.getMerchantId()); | |||
| throw new MallinkException(ErrorCode.USER_IS_EMPTY.getCode(), "门店未找到" + msg.getMerchantId()); | |||
| } | |||
| couponOrderService.actionAfterVerify(couponOrder, user); | |||
| couponOrderService.actionAfterVerify(couponOrder, merchant); | |||
| } | |||
| } | |||
| @@ -156,6 +156,9 @@ | |||
| <if test=" null != verifyRemark"> | |||
| ,`verify_remark` = #{verifyRemark} | |||
| </if> | |||
| <if test=" null != shippingStatus"> | |||
| ,`shipping_status` = #{shippingStatus} | |||
| </if> | |||
| where id=#{id} and `b_user_id` is null | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| @@ -174,6 +177,9 @@ | |||
| <if test=" null != verifyRemark"> | |||
| ,`verify_remark` = #{verifyRemark} | |||
| </if> | |||
| <if test=" null != shippingStatus"> | |||
| ,`shipping_status` = #{shippingStatus} | |||
| </if> | |||
| where id=#{id} | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| @@ -198,6 +204,9 @@ | |||
| <if test=" null != verifyRemark"> | |||
| ,`verify_remark` = #{verifyRemark} | |||
| </if> | |||
| <if test=" null != shippingStatus"> | |||
| ,`shipping_status` = #{shippingStatus} | |||
| </if> | |||
| where 1=1 | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| @@ -900,6 +909,10 @@ | |||
| and co.coupon_type = #{couponType} | |||
| </when> | |||
| <otherwise> | |||
| <!-- and co.coupon_type != 5 --> | |||
| and co.coupon_type != 11 | |||
| <!-- and co.coupon_type != 12 --> | |||
| <!-- and co.coupon_type != 51 --> | |||
| and co.coupon_type < 100 | |||
| </otherwise> | |||
| </choose> | |||
| @@ -993,6 +1006,92 @@ | |||
| </select> | |||
| <select id="findGoodsList" parameterType="com.iformall.domain.vo.WxCouponOrderBVo" resultMap="AdminBVoResultMap"> | |||
| select | |||
| co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.c_user_id,co.owner_id,co.b_user_id, | |||
| co.order_id,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,co.verify_remark, co.pay_vendor, | |||
| co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info`, | |||
| c.type,c.title,c.sale_price,c.use_price,c.price,c.unit,c.auto_refund,c.business,c.subsidy_type, | |||
| cu.phone | |||
| FROM wx_coupon_order co | |||
| left join wx_coupon_merchant wcm on co.coupon_id = wcm.product_id and wcm.merchant_id = #{merchantId} | |||
| LEFT JOIN wx_c_user_basic_info cu ON cu.id=co.c_user_id | |||
| LEFT JOIN wx_coupon c ON c.id = co.coupon_id | |||
| where wcm.merchant_id = #{merchantId} | |||
| <choose> | |||
| <when test=" null != couponType"> | |||
| and co.coupon_type = #{couponType} | |||
| </when> | |||
| <otherwise> | |||
| <!-- and co.coupon_type != 5 --> | |||
| and co.coupon_type != 11 | |||
| <!-- and co.coupon_type != 12 --> | |||
| <!-- and co.coupon_type != 51 --> | |||
| and co.coupon_type < 100 | |||
| </otherwise> | |||
| </choose> | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and co.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and co.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test=" null != cUserPhone and '' != cUserPhone"> | |||
| and cu.`phone` = #{cUserPhone} | |||
| </if> | |||
| <if test=" null != couponOrderStatus "> | |||
| and co.coupon_order_status = #{couponOrderStatus} | |||
| </if> | |||
| <if test=" null != shippingStatuss "> | |||
| and co.`shipping_status` in | |||
| <foreach collection="shippingStatuss" index="index" item="idItem" open="(" separator="," close=")"> | |||
| #{idItem} | |||
| </foreach> | |||
| </if> | |||
| <if test="startDate != null"> | |||
| AND co.create_date > #{startDate,jdbcType=TIMESTAMP} | |||
| </if> | |||
| <if test="endDate != null"> | |||
| AND co.create_date < #{endDate,jdbcType=TIMESTAMP} | |||
| </if> | |||
| <if test="verifyStartDate != null"> | |||
| AND co.update_date > #{verifyStartDate,jdbcType=TIMESTAMP} | |||
| </if> | |||
| <if test="verifyEndDate != null"> | |||
| AND co.update_date < #{verifyEndDate,jdbcType=TIMESTAMP} | |||
| </if> | |||
| <if test=" null != id "> | |||
| and co.id = #{id} | |||
| </if> | |||
| <if test=" null != orderId "> | |||
| and co.order_id = #{orderId} | |||
| </if> | |||
| <if test=" null != couponId "> | |||
| and c.id = #{couponId} | |||
| </if> | |||
| <if test=" null != title "> | |||
| and c.title like concat('%', #{title},'%') | |||
| </if> | |||
| <if test=" null != type "> | |||
| and c.`type` = #{type} | |||
| </if> | |||
| <if test=" null != business "> | |||
| and c.business = #{business} | |||
| </if> | |||
| <if test=" null != sourceType "> | |||
| and c.`source_type` = #{sourceType} | |||
| </if> | |||
| <if test=" null != sortColumns"> order by ${sortColumns} </if> | |||
| <if test=" null == sortColumns">order by co.create_date desc,co.id desc</if> | |||
| </select> | |||
| <select id="findDetailOfAdmin" parameterType="java.util.HashMap" resultMap="BVoResultMap"> | |||
| select <include refid="allAdminCouponOrderDetailColumns" /> | |||
| @@ -1179,7 +1278,7 @@ | |||
| select="com.iformall.mapper.WxCouponMerchantMapper.findMerchantVoList" > | |||
| </collection> | |||
| </resultMap> | |||
| <resultMap id="CVoResultMapOptimize" type="com.iformall.domain.vo.WxCouponOrderCVo"> | |||
| <id column="id" jdbcType="BIGINT" property="id" /> | |||
| <result column="tenant_id" jdbcType="BIGINT" property="tenantId" /> | |||
| @@ -258,9 +258,10 @@ | |||
| <sql id="allCUserOrderDetailColumns"> | |||
| o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.payment_type,o.payment,o.payment_time,o.`freight_price`,o.order_status,o.create_date,o.update_date, | |||
| o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.payment_type,o.payment,o.payment_time,o.order_status,o.create_date,o.update_date, | |||
| c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.tail_price,c.orig_price,c.unit,c.detail,c.remark,c.valid_start_date,c.valid_end_date,c.pick_start_date,c.pick_end_date, | |||
| co.id as coupon_order_id,co.coupon_order_status,c.support_transfer,c.subsidy_num,o.compose_order_type,o.compose_order_id,o.`shipping_type`,o.`shipping_address` | |||
| co.id as coupon_order_id,co.coupon_order_status,c.support_transfer,c.subsidy_num,o.compose_order_type,o.compose_order_id, | |||
| o.`coupon_number`,o.`freight_price`,o.`shipping_type`,o.`shipping_address`,co.`shipping_status`,co.`delivery_info` | |||
| </sql> | |||
| <update id="updateStatusByPressCouponId" parameterType="com.iformall.domain.po.WxOrder"> | |||
| @@ -298,9 +299,12 @@ | |||
| </update> | |||
| <resultMap id="CVoResultMap" type="com.iformall.domain.vo.WxOrderCouponVo"> | |||
| <resultMap id="CVoListMap" type="com.iformall.domain.vo.WxOrderCouponVo"> | |||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||
| <result column="level" jdbcType="INTEGER" property="level"/> | |||
| <result column="order_number" jdbcType="BIGINT" property="orderNumber"/> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | |||
| @@ -341,6 +345,59 @@ | |||
| <result column="compose_order_type" jdbcType="INTEGER" property="composeOrderType" /> | |||
| <result column="compose_order_id" jdbcType="BIGINT" property="composeOrderId" /> | |||
| <result column="coupon_number" jdbcType="INTEGER" property="couponNumber"/> | |||
| <result column="shipping_type" jdbcType="INTEGER" property="shippingType"/> | |||
| <result column="shipping_address" jdbcType="VARCHAR" property="shippingAddress"/> | |||
| <result column="shipping_status" jdbcType="INTEGER" property="shippingStatus"/> | |||
| <result column="delivery_info" jdbcType="VARCHAR" property="deliveryInfo"/> | |||
| </resultMap> | |||
| <resultMap id="CVoResultMap" type="com.iformall.domain.vo.WxOrderCouponVo"> | |||
| <id column="id" jdbcType="BIGINT" property="id"/> | |||
| <result column="order_number" jdbcType="BIGINT" property="orderNumber"/> | |||
| <result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/> | |||
| <result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" /> | |||
| <result column="c_user_id" jdbcType="BIGINT" property="cUserId"/> | |||
| <result column="coupon_channel_id" jdbcType="BIGINT" property="couponChannelId"/> | |||
| <result column="product_id" jdbcType="BIGINT" property="productId"/> | |||
| <result column="payment_type" jdbcType="INTEGER" property="paymentType"/> | |||
| <result column="payment" jdbcType="INTEGER" property="payment"/> | |||
| <result column="payment_time" jdbcType="TIMESTAMP" property="paymentTime"/> | |||
| <result column="freight_price" jdbcType="INTEGER" property="freightPrice"/> | |||
| <result column="order_status" jdbcType="INTEGER" property="orderStatus"/> | |||
| <result column="create_date" jdbcType="TIMESTAMP" property="createDate"/> | |||
| <result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/> | |||
| <result column="type" jdbcType="INTEGER" property="type"/> | |||
| <result column="cover_img" jdbcType="VARCHAR" property="coverImg"/> | |||
| <result column="title" jdbcType="VARCHAR" property="title"/> | |||
| <result column="sub_title" jdbcType="VARCHAR" property="subTitle"/> | |||
| <result column="sale_price" jdbcType="INTEGER" property="salePrice"/> | |||
| <result column="use_price" jdbcType="INTEGER" property="usePrice"/> | |||
| <result column="detail" jdbcType="VARCHAR" property="detail"/> | |||
| <result column="price" jdbcType="INTEGER" property="price"/> | |||
| <result column="tail_price" jdbcType="INTEGER" property="tailPrice"/> | |||
| <result column="orig_price" jdbcType="INTEGER" property="origPrice"/> | |||
| <result column="unit" jdbcType="INTEGER" property="unit"/> | |||
| <result column="remark" jdbcType="VARCHAR" property="remark"/> | |||
| <result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/> | |||
| <result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/> | |||
| <result column="subsidy_num" jdbcType="INTEGER" property="subsidyNum"></result> | |||
| <result column="pick_start_date" jdbcType="TIMESTAMP" property="pickStartDate"/> | |||
| <result column="pick_end_date" jdbcType="TIMESTAMP" property="pickEndDate"/> | |||
| <result column="coupon_order_id" jdbcType="BIGINT" property="couponOrderId"/> | |||
| <result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus"/> | |||
| <result column="send_channel_type" jdbcType="INTEGER" property="sendChannelType" /> | |||
| <result column="support_transfer" jdbcType="INTEGER" property="supportTransfer"/> | |||
| <result column="compose_order_type" jdbcType="INTEGER" property="composeOrderType" /> | |||
| <result column="compose_order_id" jdbcType="BIGINT" property="composeOrderId" /> | |||
| <result column="coupon_number" jdbcType="INTEGER" property="couponNumber"/> | |||
| <result column="shipping_type" jdbcType="INTEGER" property="shippingType"/> | |||
| <result column="shipping_address" jdbcType="VARCHAR" property="shippingAddress"/> | |||
| @@ -365,7 +422,7 @@ | |||
| o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.payment_type,o.payment,o.payment_time,o.order_status,o.create_date,o.update_date, | |||
| c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.tail_price,c.orig_price,c.unit,c.valid_start_date,c.valid_end_date,c.pick_start_date,c.pick_end_date, | |||
| o.compose_order_type,o.compose_order_id, | |||
| co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info` | |||
| o.`coupon_number`,o.`freight_price`,o.`shipping_type`,o.`shipping_address` | |||
| </sql> | |||
| <select id="findListOfCUser" parameterType="com.iformall.domain.po.WxOrder" resultMap="CVoResultMap"> | |||
| @@ -393,6 +450,80 @@ | |||
| <if test=" null != sortColumns">order by ${sortColumns}</if> | |||
| </select> | |||
| <select id="listGoodsCAsPage" parameterType="com.iformall.domain.po.WxOrder" resultMap="CVoListMap"> | |||
| select * from( | |||
| select 0 level,o.compose_order_type,o.compose_order_id,o.payment,o.order_status,o.create_date, | |||
| o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.payment_type,o.payment_time,o.update_date, | |||
| c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.tail_price,c.orig_price,c.unit,c.valid_start_date,c.valid_end_date,c.pick_start_date,c.pick_end_date, | |||
| o.`coupon_number`,o.`freight_price`,o.`shipping_type`,o.`shipping_address` | |||
| from wx_coupon c,wx_order o | |||
| where o.product_id = c.id and o.order_status in (0,2) | |||
| and o.compose_order_type in (0,3) | |||
| and o.compose_order_id = 0 | |||
| <if test="cUserId != null"> | |||
| and o.c_user_id = #{cUserId} | |||
| </if> | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and o.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and o.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test="orderStatus != null"> | |||
| AND o.order_status = #{orderStatus} | |||
| </if> | |||
| union all | |||
| select 0 level, o.compose_order_type,o.compose_order_id,o.payment,o.order_status,o.create_date, | |||
| o.id,o.order_number,o.tenant_id,o.parent_tenant_id,o.c_user_id,o.coupon_channel_id,o.product_id,o.payment_type,o.payment_time,o.update_date, | |||
| c.type,c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.tail_price,c.orig_price,c.unit,c.valid_start_date,c.valid_end_date,c.pick_start_date,c.pick_end_date, | |||
| o.`coupon_number`,o.`freight_price`,o.`shipping_type`,o.`shipping_address` | |||
| from wx_coupon c,wx_order o | |||
| where o.product_id = c.id and o.order_status in (1,3,4,5) | |||
| and o.compose_order_type in (0,1,2,3) | |||
| <if test="cUserId != null"> | |||
| and o.c_user_id = #{cUserId} | |||
| </if> | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and o.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and o.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test="orderStatus != null"> | |||
| AND o.order_status = #{orderStatus} | |||
| </if> | |||
| union all | |||
| select 1 level,o.compose_order_type,o.compose_order_id,sum(o.payment) payment,o.order_status,min(create_date) create_date, | |||
| null ,null ,null ,null ,null ,null ,null ,null ,null ,null , | |||
| null ,null ,null ,null ,null ,null ,null ,null ,null ,null ,null ,null ,null ,null , | |||
| null ,null ,null ,null | |||
| from wx_order o | |||
| where o.order_status in (0,2) | |||
| and o.compose_order_type in (1,2) | |||
| and o.compose_order_id > 0 | |||
| <if test="cUserId != null"> | |||
| and o.c_user_id = #{cUserId} | |||
| </if> | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and o.`tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and o.`parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| <if test="orderStatus != null"> | |||
| AND o.order_status = #{orderStatus} | |||
| </if> | |||
| group by o.compose_order_type,o.compose_order_id | |||
| ) a | |||
| order by a.create_date desc | |||
| </select> | |||
| <select id="selectDetailOfCUser" parameterType="com.iformall.domain.po.WxOrder" resultMap="CVoResultMap"> | |||
| select | |||
| <include refid="allCUserOrderDetailColumns"/> | |||