Просмотр исходного кода

fix 券优化

release_toaliyun_real
winter 4 лет назад
Родитель
Сommit
a15217d8b4
10 измененных файлов: 311 добавлений и 343 удалений
  1. +5
    -92
      mallinkCApi/src/main/java/com/iformall/controller/WxCouponOrderController.java
  2. +2
    -2
      mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java
  3. +2
    -0
      mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java
  4. +2
    -0
      mallinkService/src/main/java/com/iformall/domain/vo/WxCouponOrderCVo.java
  5. +3
    -0
      mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java
  6. +3
    -6
      mallinkService/src/main/java/com/iformall/mapper/WxCouponOrderMapper.java
  7. +3
    -8
      mallinkService/src/main/java/com/iformall/service/WxCouponOrderService.java
  8. +239
    -34
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java
  9. +21
    -1
      mallinkService/src/main/resources/mapper/WxCouponMapper.xml
  10. +31
    -200
      mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml

+ 5
- 92
mallinkCApi/src/main/java/com/iformall/controller/WxCouponOrderController.java Просмотреть файл

@@ -80,13 +80,14 @@ public class WxCouponOrderController extends BaseController {
}
if (wxCouponOrder == null) wxCouponOrder = new WxCouponOrderCVo();
wxCouponOrder.setCUserId(memberId);
if (wxCouponOrder.getCouponOrderStatus() == null)
wxCouponOrder.updateTenantInfo(getTenantInfo());
if (wxCouponOrder.getCouponOrderStatus() == null) {
wxCouponOrder.setSortColumns(BaseEntity.SortField.CreateDate_DESC, BaseEntity.SortField.Id_DESC);
else if (wxCouponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode())
}else if (wxCouponOrder.getCouponOrderStatus() == EnumCouponOrderStatus.COUPON_ORDER_USE_WAIT.getCode()) {
wxCouponOrder.setSortColumns(BaseEntity.SortField.CreateDate_DESC, BaseEntity.SortField.Id_DESC);
else
}else {
wxCouponOrder.setSortColumns(BaseEntity.SortField.UpdateDate_DESC, BaseEntity.SortField.Id_DESC);
}
PageInfo<WxCouponOrderCVo> page = wxCouponOrderService.listCUserVoAsPageOptimize(wxCouponOrder, pageNum, pageSize);

Date now = new Date();
@@ -431,92 +432,4 @@ public class WxCouponOrderController extends BaseController {
memCouponFromDspService.couponOrderFromDsp(tenantEntity, member.getPhone());
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,null,EnumCouponVerifyType.VERIFY_C);
} 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 && couponOrder.getMerchantId() != null) {
wxCouponOrderService.sendInsideCouponVerifyMsg(couponOrder, couponOrderId, couponOrder.getMerchantId());
}

return new ResultData(couponOrder);
}

}

+ 2
- 2
mallinkPosApi/src/main/java/com/iformall/service/impl/PosServiceImpl.java Просмотреть файл

@@ -342,7 +342,7 @@ public class PosServiceImpl implements PosService {
}
coQ.put("cUserId", user.getId());
coQ.put("merchantId", merchantId);
List<WxCouponOrderCVo> avaCoList = couponOrderMapper.findAvailCouponOrder(coQ);
List<WxCouponOrderCVo> avaCoList = couponOrderService.findAvailCouponOrder(tenantEntity,user.getId(),merchantId,null);

JSONArray selCoArr = JSONObject.parseArray(coListStr);
if (config.getCoupon().equals(EnumPosCouponEnableType.SingleEnable.getCode())) {
@@ -947,7 +947,7 @@ public class PosServiceImpl implements PosService {
}
coQ.put("cUserId", user.getId());
coQ.put("merchantId", merchantId);
List<WxCouponOrderCVo> avaCoList = couponOrderMapper.findAvailCouponOrder(coQ);
List<WxCouponOrderCVo> avaCoList = couponOrderService.findAvailCouponOrder(tenantEntity,user.getId(),merchantId,null);
JSONArray selCoArr = JSONObject.parseArray(coListStr);
if (config.getCoupon().equals(EnumPosCouponEnableType.SingleEnable.getCode())) {
if (selCoArr.size() > 1) {


+ 2
- 0
mallinkService/src/main/java/com/iformall/domain/po/WxCoupon.java Просмотреть файл

@@ -142,6 +142,8 @@ public class WxCoupon extends TenantEntity {
private String remark;
@io.swagger.annotations.ApiModelProperty(value="状态(-1:全部,0:草稿/待生效,1:已生效,2:已失效,3:已作废)",name="status")
private Integer status;
@TableField(exist = false)
private List<Integer> statusList;
@io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate")
private Date createDate;
@io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate")


+ 2
- 0
mallinkService/src/main/java/com/iformall/domain/vo/WxCouponOrderCVo.java Просмотреть файл

@@ -38,6 +38,8 @@ public class WxCouponOrderCVo extends WxCouponOrder {
/** 基础购买到的券信息 */
@io.swagger.annotations.ApiModelProperty(value = "单张券ID", name = "couponId")
private Long couponId;
@TableField(exist = false)
private List<Long> couponIds;
@io.swagger.annotations.ApiModelProperty(value = "用户订单ID", name = "orderId")
private Long orderId;
@io.swagger.annotations.ApiModelProperty(value = "该订单对应券的实际过期时间 ", name = "expiredTime")


+ 3
- 0
mallinkService/src/main/java/com/iformall/mapper/WxCouponMapper.java Просмотреть файл

@@ -18,6 +18,9 @@ public interface WxCouponMapper extends CommonMapper<WxCoupon, Long> {
List<WxCoupon> findTenantSimpleList(WxCoupon wxCoupon);
WxCoupon findSimpleDetail(WxCoupon wxCoupon);
List<WxCoupon> findSimpleDetailList(WxCoupon wxCoupon);
List<Long> findIdList(WxCoupon wxCoupon);
List<WxCoupon> findCouponList(WxCoupon wxCoupon);



+ 3
- 6
mallinkService/src/main/java/com/iformall/mapper/WxCouponOrderMapper.java Просмотреть файл

@@ -46,12 +46,9 @@ public interface WxCouponOrderMapper extends CommonMapper<WxCouponOrder, Long> {
List<WxCouponOrder> findListOfOrderedByDateForBUser(Map dateMap);
List<WxCouponOrder> findListOfVerifiedByDateForBUser(Map dateMap);

//@Deprecated
//List<WxCouponOrderCVo> findListOfCUser(WxCouponOrder wxCouponOrder);
List<WxCouponOrderCVo> findListOfCUserOptimize(WxCouponOrder wxCouponOrder);
List<WxCouponOrder> findListOfCUserOptimize(WxCouponOrder wxCouponOrder);
WxCouponOrderCVo findDetailOfCUser(@Param("id")Long id,@Param("tenantId")String tenantId);
WxCouponOrderCVo findSimpleDetailOfCUser(@Param("id")Long id,@Param("tenantId")String tenantId);
WxCouponOrder findDetailOfCUser(@Param("id")Long id,@Param("tenantId")String tenantId);
List<WxCouponOrder> findListOfAdmin(WxCouponOrderBVo wxCouponOrder);
WxCouponOrder findDetailOfAdmin(@Param("id")Long id,@Param("tenantId")String tenantId,@Param("finalTenantId")String finalTenantId);

@@ -91,7 +88,7 @@ public interface WxCouponOrderMapper extends CommonMapper<WxCouponOrder, Long> {


/// POS接口
List<WxCouponOrderCVo> findAvailCouponOrder(Map<String,Object> params);
List<WxCouponOrder> findCouponOrderForPos(Map<String,Object> params);
//卡延期,将过期的状态变为使用中
void cardDefer(@Param("couponId")Long couponId,@Param("tenantId")String tenantId,@Param("expireTime")Date expireTime);


+ 3
- 8
mallinkService/src/main/java/com/iformall/service/WxCouponOrderService.java Просмотреть файл

@@ -148,14 +148,6 @@ public interface WxCouponOrderService {

List<WxCouponOrderCarCVo> carListCUserVo(WxCouponOrder record);


/**
* B用户查券详情
*
* @param bUserId B端用户
*/
ResultData detailBUserVo(Long bUserId, String couponOrderId);

/**
* A端查询分页列表
*
@@ -227,4 +219,7 @@ public interface WxCouponOrderService {
PageInfo<WxCouponOrderBVo> goodsListAsPage(WxCouponOrderBVo couponOrderBvo, Integer pageNum, Integer pageSize);
List<MarkingCouponDataReportVo> couponDataMap(TenantEntity tenantEntity,Date startTime,Date endTime);
/// POS接口
List<WxCouponOrderCVo> findAvailCouponOrder(TenantEntity tenantEntity,Long cUserId,Long merchantId,Long posOrderId);
}

+ 239
- 34
mallinkService/src/main/java/com/iformall/service/impl/WxCouponOrderServiceImpl.java Просмотреть файл

@@ -523,14 +523,134 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
@Override
public PageInfo<WxCouponOrderCVo> listCUserVoAsPageOptimize(WxCouponOrder record, Integer pageIndex, Integer pageSize) {

return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findListOfCUserOptimize(record));
PageInfo<WxCouponOrder> pageInfo = PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxCouponOrderMapper.findListOfCUserOptimize(record));
PageInfo<WxCouponOrderCVo> cvoPageInfo = new PageInfo<WxCouponOrderCVo>();
cvoPageInfo.setList(couponOrderListToCVoList(record,pageInfo.getList()));
cvoPageInfo.setPageNum(pageInfo.getPageNum());
cvoPageInfo.setPageSize(pageInfo.getPageSize());
cvoPageInfo.setPages(pageInfo.getPages());
return cvoPageInfo;
}

private List<WxCouponOrderCVo> couponOrderListToCVoList(TenantEntity tenantEntity,List<WxCouponOrder> couponOrderList) {
if (null != couponOrderList) {
//查询coupon
List<Long> couponIds = new ArrayList<Long>();
for (int i = 0 ; i < couponOrderList.size(); i++){
WxCouponOrder co = couponOrderList.get(i);
Long couponId = co.getCouponId();
if (null != couponId && (!couponIds.contains(couponId))) {
couponIds.add(couponId);
}
}
WxCoupon couponQ = new WxCoupon();
couponQ.updateTenantInfo(tenantEntity);
if (couponIds.size() > 0 ) {
couponQ.setIds(couponIds);
}
List<WxCoupon> couponList = wxCouponMapper.findTenantSimpleList(couponQ);
Map<Long,WxCoupon> couponMap = new HashMap<Long,WxCoupon>();
if (null != couponList) {
for (int i = 0 ; i < couponList.size(); i++ ) {
WxCoupon c = couponList.get(i);
if (null != c) {
couponMap.put(c.getId(), c);
}
}
}
List<WxCouponOrderCVo> volist = new ArrayList<WxCouponOrderCVo>();
for (int i = 0 ; i < couponOrderList.size(); i++){
WxCouponOrder co = couponOrderList.get(i);
WxCouponOrderCVo cvo = getCouponOrderCVo(co,couponMap);
if (null != cvo) {
volist.add(cvo);
}
}
return volist;
}
return null;
}
private WxCouponOrderCVo getCouponOrderCVo(WxCouponOrder co,Map<Long,WxCoupon> couponMap) {
if (null == co) {
return null;
}
try {
WxCouponOrderCVo cvo = new WxCouponOrderCVo();
BeanUtils.copyProperties(cvo, co);
WxCoupon coupon = couponMap.get(cvo.getCouponId());
if (null != coupon) {
cvo.setType(coupon.getType());
cvo.setCoverImg(coupon.getCoverImg());
cvo.setTitle(coupon.getTitle());
cvo.setSubTitle(coupon.getSubTitle());
cvo.setSalePrice(coupon.getSalePrice());
cvo.setUsePrice(coupon.getUsePrice());
cvo.setPrice(coupon.getPrice());
cvo.setUnit(coupon.getUnit());
cvo.setValidType(coupon.getValidType());
cvo.setValidStartDate(coupon.getValidStartDate());
cvo.setValidEndDate(coupon.getValidEndDate());
cvo.setAutoRefund(coupon.getAutoRefund());
}
return cvo;
} catch (IllegalAccessException | InvocationTargetException e) {
logger.error("getCouponOrderCVo error.",e);
}
return null;
}
private WxCouponOrderCVo getCouponOrderCDetailVo(WxCouponOrder co) {
if (null == co || null == co.getCouponId()) {
return null;
}
WxCoupon couponQ = new WxCoupon();
couponQ.updateTenantInfo(co);
couponQ.setId(co.getCouponId());
WxCoupon coupon = wxCouponMapper.findSimpleDetail(couponQ);
return getCouponOrderCDetailVo(co,coupon);
}
private WxCouponOrderCVo getCouponOrderCDetailVo(WxCouponOrder co,WxCoupon coupon) {
try {
WxCouponOrderCVo cvo = new WxCouponOrderCVo();
BeanUtils.copyProperties(cvo, co);
if (null != coupon) {
cvo.setType(coupon.getType());
cvo.setCoverImg(coupon.getCoverImg());
cvo.setTitle(coupon.getTitle());
cvo.setSubTitle(coupon.getSubTitle());
cvo.setSalePrice(coupon.getSalePrice());
cvo.setUsePrice(coupon.getUsePrice());
cvo.setPrice(coupon.getPrice());
cvo.setTailPrice(coupon.getTailPrice());
cvo.setOrigPrice(coupon.getOrigPrice());
cvo.setUnit(coupon.getUnit());
cvo.setDetail(coupon.getDetail());
cvo.setRemark(coupon.getRemark());
cvo.setValidType(coupon.getValidType());
cvo.setValidStartDate(coupon.getValidStartDate());
cvo.setValidEndDate(coupon.getValidEndDate());
cvo.setPickStartDate(coupon.getPickStartDate());
cvo.setPickEndDate(coupon.getPickEndDate());
cvo.setAutoRefund(coupon.getAutoRefund());
}
return cvo;
} catch (IllegalAccessException | InvocationTargetException e) {
logger.error("getCouponOrderCVo error.",e);
}
return null;
}
@Override
public WxCouponOrderCVo detailCUserVo(String couponOrderId,TenantEntity tenantinfo) {

WxCouponOrderCVo wxCouponOrderCVo = wxCouponOrderMapper.findDetailOfCUser(Long.valueOf(couponOrderId),tenantinfo.getTenantId());
WxCouponOrder couponOrder = wxCouponOrderMapper.findDetailOfCUser(Long.valueOf(couponOrderId),tenantinfo.getTenantId());
if (null == couponOrder) {
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL);
}
WxCouponOrderCVo wxCouponOrderCVo = getCouponOrderCDetailVo(couponOrder);
if (wxCouponOrderCVo == null)
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL);
return wxCouponOrderCVo;
@@ -538,10 +658,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {

@Override
public WxCouponOrderCVo simpleDetailCUserVo(String couponOrderId,TenantEntity tenantinfo) {
WxCouponOrderCVo wxCouponOrderCVo = wxCouponOrderMapper.findSimpleDetailOfCUser(Long.valueOf(couponOrderId),tenantinfo.getTenantId());
if (wxCouponOrderCVo == null)
throw new MallinkException(ErrorCode.COUPON_ORDER_IS_NULL);
return wxCouponOrderCVo;
return detailCUserVo(couponOrderId,tenantinfo);
}


@@ -555,30 +672,6 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
return wxCouponOrderMapper.findCarListOfCUser(record);
}

@Override
public ResultData detailBUserVo(Long bUserId, String couponOrderId) {
WxMerchantBUser wxMerchantBUser = wxMerchantBUserMapper.selectById(bUserId);
if (wxMerchantBUser == null) {
logger.error("用户不存在:" + bUserId);
throw new MallinkException(ErrorCode.USER_IS_EMPTY);
}

WxMerchant wxMerchant = wxMerchantMapper.selectById(wxMerchantBUser.getMerchantId());
if (wxMerchant == null) {
logger.error("商户不存在:" + bUserId);
throw new MallinkException(ErrorCode.MERCHANT_INFO_NOT_FOUND);
}
WxCouponOrderCVo wxCouponOrderCVo = null;
try {
wxCouponOrderCVo = wxCouponOrderMapper.findDetailOfCUser(Long.valueOf(couponOrderId),wxMerchantBUser.getTenantId());
} catch (Exception e) {
return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL);
}
if (wxCouponOrderCVo == null)
return new ResultData(ErrorCode.COUPON_ORDER_IS_NULL);
return new ResultData(wxCouponOrderCVo);
}

@Override
public ResultData listAdminAsPage(WxCouponOrderBVo wxCouponOrderBVo, Integer pageIndex, Integer pageSize) {
handleWxCouponOrderBVoQueryParam(wxCouponOrderBVo);
@@ -2051,7 +2144,7 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
}
coQ.put("cUserId", cUser.getId());
coQ.put("merchantId", user.getMerchantId());
List<WxCouponOrderCVo> avaCoList = wxCouponOrderMapper.findAvailCouponOrder(coQ);
List<WxCouponOrderCVo> avaCoList = this.findAvailCouponOrder(user,cUser.getId(),user.getMerchantId(),null);
JSONArray couponList = new JSONArray();
for(int i=0;i<avaCoList.size();i++) {
WxCouponOrderCVo couponOrderCVo = avaCoList.get(i);
@@ -2531,4 +2624,116 @@ public class WxCouponOrderServiceImpl implements WxCouponOrderService {
return null;
}

@Override
public List<WxCouponOrderCVo> findAvailCouponOrder(TenantEntity tenantEntity,Long cUserId,Long merchantId,Long posOrderId) {
Map param = posCouponOrderQueryParam(tenantEntity,cUserId,merchantId);
List<Long> realCouponIds = (List<Long>) param.get("couponIds");
if (realCouponIds.size() <= 0 ) {
return null;
}
param.put("status", 0);
List<WxCouponOrder> couponOrderList = wxCouponOrderMapper.findCouponOrderForPos(param);
List<WxCouponOrder> couponOrderList1 = null;
if (null != posOrderId) {
param.put("status", 100);
PosCouponOrderVerify posCouponOrderVerifyQ = new PosCouponOrderVerify();
posCouponOrderVerifyQ.setPosOrderId(posOrderId);
List<PosCouponOrderVerify> posList = posCouponOrderVerifyMapper.findList(posCouponOrderVerifyQ);
if (null != posList && posList.size() > 0 ) {
List<Long> ids = new ArrayList<Long>();
for (int i = 0 ; i < posList.size() ; i ++) {
PosCouponOrderVerify pos = posList.get(i);
if (null != pos && null != pos.getCouponOrderId()) {
if (!ids.contains(pos.getCouponOrderId())) {
ids.add(pos.getCouponOrderId());
}
}
}
if (ids.size() > 0) {
param.put("ids",ids);
couponOrderList1 = wxCouponOrderMapper.findCouponOrderForPos(param);
}
}
}
WxCoupon couponQ1 = new WxCoupon();
couponQ1.updateTenantInfo(tenantEntity);
couponQ1.setIds(realCouponIds);
List<WxCoupon> couponList = wxCouponMapper.findSimpleDetailList(couponQ1);
Map<Long,WxCoupon> couponMap = new HashMap<Long,WxCoupon>();
List<WxCouponOrderCVo> retList = new ArrayList<WxCouponOrderCVo>();
if (null != couponList) {
for (int i = 0 ; i < couponList.size() ; i ++) {
WxCoupon c = couponList.get(i);
if (null != c) {
couponMap.put(c.getId(), c);
}
}
}
if (null != couponOrderList) {
for (int i = 0 ; i < couponOrderList.size() ; i ++) {
WxCouponOrderCVo cvo = getPosVo(couponOrderList.get(i),couponMap);
if (null != cvo) {
retList.add(cvo);
}
}
}
if (null != couponOrderList1) {
for (int i = 0 ; i < couponOrderList1.size() ; i ++) {
WxCouponOrderCVo cvo = getPosVo(couponOrderList1.get(i),couponMap);
if (null != cvo) {
retList.add(cvo);
}
}
}
if (retList.size() <= 0 ) {
return null;
}
return retList;
}
private Map posCouponOrderQueryParam(TenantEntity tenantEntity,Long cUserId,Long merchantId) {
Map param = new HashMap();
param.put("cUserId", cUserId);
param.put("tenantId", tenantEntity.getTenantId());
param.put("parentTenantId", tenantEntity.getParentTenantId());
List<Long> merchantIds = new ArrayList<Long>();
merchantIds.add(merchantId);
List<Long> merchantCouponIds = wxCouponMerchantMapper.findMerchantProductIds(tenantEntity.getTenantId(), merchantIds, null);
WxCoupon couponQ = new WxCoupon();
couponQ.updateTenantInfo(tenantEntity);
List<Integer> statusList = new ArrayList<Integer>();
statusList.add(1);
statusList.add(2);
statusList.add(6);
couponQ.setStatusList(statusList);
List<Long> couponIds = wxCouponMapper.findIdList(couponQ);
List<Long> realCouponIds = new ArrayList<Long>();
if (null != merchantCouponIds) {
realCouponIds.addAll(merchantCouponIds);
}
if (null != couponIds) {
realCouponIds.retainAll(couponIds);
}
param.put("couponIds", realCouponIds);
return param;
}
private WxCouponOrderCVo getPosVo(WxCouponOrder co,Map<Long,WxCoupon> couponMap) {
WxCouponOrderCVo cvo = null;
Long couponId = co.getCouponId();
if (null != couponId) {
cvo = getCouponOrderCDetailVo(co,couponMap.get(couponId));
}else {
cvo = getCouponOrderCDetailVo(co,null);
}
return cvo;
}

}

+ 21
- 1
mallinkService/src/main/resources/mapper/WxCouponMapper.xml Просмотреть файл

@@ -307,6 +307,13 @@
#{typeItem}
</foreach>
</if>
<if test=" null != statusList ">
and status in
<foreach collection="statusList" index="index" item="statusItem" open="(" separator="," close=")">
#{statusItem}
</foreach>
</if>

<if test=" null != sortColumns">order by ${sortColumns}</if>
</sql>
@@ -317,7 +324,7 @@
</select>
<select id="findTenantSimpleList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
select id,title,sale_price,use_price,price,auto_refund,business,subsidy_type,source_type,type,unit
select id,title,sale_price,use_price,price,auto_refund,business,subsidy_type,source_type,type,unit,cover_img,sub_title,valid_type,valid_start_date,valid_end_date
from wx_coupon c where c.`tenant_id` = #{tenantId}
<if test=" null != ids ">
and id in
@@ -326,6 +333,19 @@
</foreach>
</if>
</select>
<select id="findSimpleDetail" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
select c.id,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_type,c.valid_start_date,
c.valid_end_date,c.pick_start_date,c.pick_end_date,c.auto_refund,c.business,c.subsidy_type,c.source_type
from wx_coupon c where c.id = #{id} and c.`tenant_id` = #{tenantId}
</select>
<select id="findSimpleDetailList" parameterType="com.iformall.domain.po.WxCoupon" resultMap="BaseResultMap">
select c.id,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_type,c.valid_start_date,
c.valid_end_date,c.pick_start_date,c.pick_end_date,c.auto_refund,c.business,c.subsidy_type,c.source_type
from wx_coupon c
<include refid="dynamicWhereConditions"/>
</select>
<select id="findIdList" parameterType="com.iformall.domain.po.WxCoupon" resultType="Long">
select id


+ 31
- 200
mallinkService/src/main/resources/mapper/WxCouponOrderMapper.xml Просмотреть файл

@@ -912,163 +912,12 @@
</if>
</select>



<sql id="allCUserCouponOrderDetailColumns">
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.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_type,c.valid_start_date,c.valid_end_date,c.pick_start_date,c.pick_end_date,c.auto_refund
</sql>

<sql id="simpleCUserCouponOrderDetailColumns">
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`
</sql>

<resultMap id="CVoResultMap" type="com.iformall.domain.vo.WxCouponOrderCVo">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="tenant_id" jdbcType="BIGINT" property="tenantId" />
<result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
<result column="coupon_id" jdbcType="BIGINT" property="couponId" />
<result column="coupon_type" jdbcType="INTEGER" property="couponType" />
<result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
<result column="owner_id" jdbcType="BIGINT" property="ownerId" />
<result column="b_user_id" jdbcType="BIGINT" property="bUserId" />
<result column="order_id" jdbcType="BIGINT" property="orderId" />
<result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" />
<result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus" />
<result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
<result column="coupon_price" jdbcType="INTEGER" property="couponPrice" />
<result column="verify_type" jdbcType="INTEGER" property="verifyType" />
<result column="verify_remark" jdbcType="VARCHAR" property="verifyRemark" />
<result column="pay_vendor" jdbcType="INTEGER" property="payVendor" />

<result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
<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"/>

<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_type" jdbcType="INTEGER" property="validType" />
<result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
<result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
<result column="auto_refund" jdbcType="INTEGER" property="autoRefund" />

<result column="pick_start_date" jdbcType="TIMESTAMP" property="pickStartDate"/>
<result column="pick_end_date" jdbcType="TIMESTAMP" property="pickEndDate"/>

<result column="send_channel_type" jdbcType="INTEGER" property="sendChannelType" />

<collection column="{productId=coupon_id,tenantId=tenant_id}" property="merchantVoList"
ofType="com.iformall.domain.vo.WxMerchantVo"
javaType="java.util.List"
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" />
<result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId" />
<result column="coupon_id" jdbcType="BIGINT" property="couponId" />
<result column="coupon_type" jdbcType="INTEGER" property="couponType" />
<result column="c_user_id" jdbcType="BIGINT" property="cUserId" />
<result column="owner_id" jdbcType="BIGINT" property="ownerId" />
<result column="b_user_id" jdbcType="BIGINT" property="bUserId" />
<result column="order_id" jdbcType="BIGINT" property="orderId" />
<result column="expired_time" jdbcType="TIMESTAMP" property="expiredTime" />
<result column="coupon_order_status" jdbcType="INTEGER" property="couponOrderStatus" />
<result column="create_date" jdbcType="TIMESTAMP" property="createDate" />
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate" />
<result column="coupon_price" jdbcType="INTEGER" property="couponPrice" />
<result column="verify_type" jdbcType="INTEGER" property="verifyType" />
<result column="verify_remark" jdbcType="VARCHAR" property="verifyRemark" />
<result column="pay_vendor" jdbcType="INTEGER" property="payVendor" />

<result column="freight_price" jdbcType="INTEGER" property="freightPrice"/>
<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"/>

<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="unit" jdbcType="INTEGER" property="unit" />
<result column="remark" jdbcType="VARCHAR" property="remark" />
<result column="valid_type" jdbcType="INTEGER" property="validType" />
<result column="valid_start_date" jdbcType="TIMESTAMP" property="validStartDate"/>
<result column="valid_end_date" jdbcType="TIMESTAMP" property="validEndDate"/>
<result column="auto_refund" jdbcType="INTEGER" property="autoRefund" />

<result column="send_channel_type" jdbcType="INTEGER" property="sendChannelType" />
</resultMap>


<!-- <select id="findListOfCUser" parameterType="com.iformall.domain.vo.WxCouponOrderCVo" resultMap="CVoResultMap">
select <include refid="allCUserCouponOrderListColumns" />
from wx_coupon c,wx_coupon_order co
left join wx_coupon_action_log cal on cal.coupon_order_id = co.id
where 1=1
and co.coupon_id = c.id
and co.coupon_type != 5
and co.coupon_type != 51
and co.coupon_type &lt; 100
<if test="cUserId != null">
and co.c_user_id = #{cUserId}
</if>
<if test="ownerId != null">
and co.owner_id = #{ownerId}
</if>
<if test="tenantId != null">
and co.tenant_id = #{tenantId}
</if>
<if test="couponOrderStatus != null and 0 == couponOrderStatus">
AND (co.coupon_order_status = #{couponOrderStatus} OR co.coupon_order_status = 100 )
</if>
<if test="couponOrderStatus != null and 0 != couponOrderStatus">
AND co.coupon_order_status = #{couponOrderStatus}
</if>
<if test=" null != sortColumns"> order by ${sortColumns} </if>
</select> -->

<!-- <sql id="allCUserCouponOrderListColumns">
co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,co.expired_time,co.coupon_order_status,co.create_date,co.update_date,co.coupon_price,co.verify_type,
c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,c.valid_type,c.valid_start_date,c.valid_end_date,c.auto_refund,
cal.channel_type as send_channel_type
</sql> -->
<sql id="allCUserCouponOrderListColumns">
<select id="findListOfCUserOptimize" parameterType="com.iformall.domain.vo.WxCouponOrderCVo" resultMap="BaseResultMap">
select
co.id,co.tenant_id,co.parent_tenant_id,co.coupon_id,co.coupon_type,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.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,c.valid_type,c.valid_start_date,c.valid_end_date,c.auto_refund
</sql>

<select id="findListOfCUserOptimize" parameterType="com.iformall.domain.vo.WxCouponOrderCVo" resultMap="CVoResultMapOptimize">
select <include refid="allCUserCouponOrderListColumns" />
from wx_coupon c,wx_coupon_order co
<!-- left join wx_coupon_action_log cal on cal.coupon_order_id = co.id -->
where 1=1
and co.coupon_id = c.id
co.`freight_price`,co.`shipping_type`,co.`shipping_address`,co.`shipping_status`,co.`delivery_info`
from wx_coupon_order co
where co.c_user_id = #{cUserId} and co.`tenant_id` = #{tenantId}
<choose>
<when test=" null != couponType">
and co.coupon_type = #{couponType}
@@ -1082,15 +931,9 @@
</otherwise>
</choose>

<if test="cUserId != null">
and co.c_user_id = #{cUserId}
</if>
<if test="ownerId != null">
and co.owner_id = #{ownerId}
</if>
<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>
@@ -1100,63 +943,51 @@
<if test="couponOrderStatus != null and 0 != couponOrderStatus">
AND co.coupon_order_status = #{couponOrderStatus}
</if>
<if test=" null != couponIds">
and co.coupon_id in
<foreach collection="couponIds" index="index" item="couponIdItem" open="(" separator="," close=")">
#{couponIdItem}
</foreach>
</if>
<if test=" null != sortColumns"> order by ${sortColumns} </if>
</select>




<select id="findDetailOfCUser" parameterType="java.util.HashMap" resultMap="CVoResultMap">
select <include refid="allCUserCouponOrderDetailColumns" />
from wx_coupon_order co, wx_coupon c
where co.coupon_id = c.id
and co.id = #{id} and co.tenant_id = #{tenantId}
</select>

<select id="findSimpleDetailOfCUser" parameterType="java.util.HashMap" resultMap="CVoResultMap">
select <include refid="simpleCUserCouponOrderDetailColumns" />
<select id="findDetailOfCUser" parameterType="java.util.HashMap" resultMap="BaseResultMap">
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`,
from wx_coupon_order co
where co.id = #{id} and co.tenant_id = #{tenantId}
</select>

<select id="findAvailCouponOrder" parameterType="java.util.Map" resultMap="CVoResultMap">
select <include refid="allCUserCouponOrderDetailColumns" />
<select id="findCouponOrderForPos" parameterType="java.util.Map" resultMap="BaseResultMap">
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`
from wx_coupon_order co
inner join wx_coupon c on c.id = co.coupon_id
inner join wx_coupon_merchant cm on cm.product_id = co.coupon_id
where co.c_user_id = #{cUserId}
and co.coupon_order_status = 0
and co.coupon_order_status = #{status}
<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>
and cm.merchant_id = #{merchantId}
and co.expired_time > now()
and c.type in (1, 2, 6)
union
select <include refid="allCUserCouponOrderDetailColumns" />
from wx_coupon_order co
inner join wx_coupon c on c.id = co.coupon_id
inner join wx_coupon_merchant cm on cm.product_id = co.coupon_id
inner join pos_coupon_order_verify pco on pco.coupon_order_id = co.id
where co.c_user_id = #{cUserId}
and co.coupon_order_status = 100
<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 test=" null != couponIds">
and co.coupon_id in
<foreach collection="couponIds" index="index" item="couponIdItem" open="(" separator="," close=")">
#{couponIdItem}
</foreach>
</if>
and cm.merchant_id = #{merchantId}
and co.expired_time > now()
and c.type in (1, 2, 6)
<if test="posOrderId != null">
and pco.pos_order_id = #{posOrderId}
<if test=" null != ids ">
and id in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
#{idItem}
</foreach>
</if>
</select>
<sql id="allCUserCouponOrderCarListColumns">
co.id,co.tenant_id,co.parent_tenant_id,co.coupon_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,
c.cover_img,c.title,c.sub_title,c.sale_price,c.use_price,c.price,c.unit,


Загрузка…
Отмена
Сохранить