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

//update poi

release_toaliyun_real
xhxu 4 лет назад
Родитель
Сommit
4245b7efa6
11 измененных файлов: 370 добавлений и 32 удалений
  1. +10
    -0
      mallinkCApi/src/main/java/com/iformall/controller/WxCouponChannelController.java
  2. +41
    -4
      mallinkCApi/src/main/java/com/iformall/controller/WxCouponOrderController.java
  3. +46
    -25
      mallinkSchedule/src/main/java/com/iformall/schedule/TtMerchantPoiSchedule.java
  4. +43
    -0
      mallinkService/src/main/java/com/iformall/domain/po/TtCouponChannelPoi.java
  5. +40
    -0
      mallinkService/src/main/java/com/iformall/enums/EnumSpuSyncStatus.java
  6. +14
    -0
      mallinkService/src/main/java/com/iformall/mapper/TtCouponChannelPoiMapper.java
  7. +2
    -1
      mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java
  8. +80
    -1
      mallinkService/src/main/java/com/iformall/service/impl/TtMerchantPoiServiceImpl.java
  9. +13
    -0
      mallinkService/src/main/java/com/iformall/service/impl/WxCouponChannelServiceImpl.java
  10. +1
    -1
      mallinkService/src/main/java/com/iformall/service/impl/WxPayOrderServiceImpl.java
  11. +80
    -0
      mallinkService/src/main/resources/mapper/TtCouponChannelPoiMapper.xml

+ 10
- 0
mallinkCApi/src/main/java/com/iformall/controller/WxCouponChannelController.java Просмотреть файл

@@ -218,4 +218,14 @@ public class WxCouponChannelController extends BaseController {
}


@ApiOperation("获取poi数据")
@GetMapping("getChannelPoi")
public ResultData getChannelPoi(Long id) {
if (null == id){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
return wxCouponChannelService.getCouponChannelPoi(getTenantInfo(),id);
}


}

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

@@ -14,10 +14,7 @@ import com.iformall.domain.vo.WxCouponCVo;
import com.iformall.domain.vo.WxCouponOrderCVo;
import com.iformall.enums.*;
import com.iformall.exception.MallinkException;
import com.iformall.service.MemCouponFromDspService;
import com.iformall.service.SysConfigService;
import com.iformall.service.WxCouponOrderService;
import com.iformall.service.WxCouponService;
import com.iformall.service.*;
import com.iformall.utils.Constant;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
@@ -61,6 +58,9 @@ public class WxCouponOrderController extends BaseController {
@Autowired
SysConfigService sysConfigService;

@Autowired
private WxPayOrderService wxPayOrderService;

//@RedisCache(expireTime = 100)
@ApiOperation("券包分页列表接口")
@GetMapping("list")
@@ -522,4 +522,41 @@ public class WxCouponOrderController extends BaseController {
return new ResultData(couponOrder);
}


@ApiOperation("获取支付订单")
@GetMapping("getChannelPoi")
public ResultData getChannelPoi(Long id) {
if (null == id){
return new ResultData(ErrorCode.SYS_PARAMETER_NOT_NULL);
}
WxCUserBasicInfo member;
try {
member = getCacheMember();
} catch (Exception e) {
return new ResultData(Result.ERROR,e.getMessage());
}

WxCouponOrder wxCouponOrder = wxCouponOrderService.getById(id,getTenantInfo().getTenantId());
if (wxCouponOrder == null) {
logger.error("券ID不存在:" + id);
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);
}
try{
WxPayOrder payOrderQ = new WxPayOrder();
payOrderQ.updateTenantInfo(getTenantInfo());
payOrderQ.setCUserId(member.getId());
payOrderQ.setOrderId(wxCouponOrder.getComposeOrderId());
payOrderQ.setPayOrderStatus(EnumPayStatus.PAY_STATUS_SUCCESS.getCode());
WxPayOrder payOrder = wxPayOrderService.getByObj(payOrderQ);
return new ResultData(payOrder);
}catch(MallinkException e) {
return new ResultData(e.getErrorCode(),e.getMessage());
}

}

}

+ 46
- 25
mallinkSchedule/src/main/java/com/iformall/schedule/TtMerchantPoiSchedule.java Просмотреть файл

@@ -1,26 +1,30 @@
//package com.iformall.schedule;
//
//import com.iformall.domain.po.*;
//import com.iformall.enums.EnumSupplierMathStatus;
//import com.iformall.enums.EnumSupplierSyncStatus;
//import com.iformall.service.TtMerchantPoiService;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.annotation.Async;
//import org.springframework.scheduling.annotation.Scheduled;
//import org.springframework.stereotype.Component;
//
//import java.util.List;
//
//@Component
//public class TtMerchantPoiSchedule {
//
// private final Logger logger = LoggerFactory.getLogger(this.getClass());
//
// @Autowired
// private TtMerchantPoiService ttMerchantPoiService;
//
package com.iformall.schedule;

import com.iformall.domain.po.*;
import com.iformall.enums.EnumSpuSyncStatus;
import com.iformall.enums.EnumSupplierMathStatus;
import com.iformall.mapper.TtCouponChannelPoiMapper;
import com.iformall.service.TtMerchantPoiService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class TtMerchantPoiSchedule {

private final Logger logger = LoggerFactory.getLogger(this.getClass());

@Autowired
private TtMerchantPoiService ttMerchantPoiService;

@Autowired
private TtCouponChannelPoiMapper ttCouponChannelPoiMapper;

// @Async
// @Scheduled(cron = "0 0 */1 * * *?") // 每小时检查一次
// public void supplierQueryTaskSchedule() {
@@ -54,5 +58,22 @@
// }
// }
// }
//
//}

@Async
@Scheduled(cron = "0 0 */1 * * *?") // 每小时检查一次
public void supplierQueryTaskSchedule() {
TtCouponChannelPoi ttCouponChannelPoi = new TtCouponChannelPoi();
ttCouponChannelPoi.setLastStatus(EnumSpuSyncStatus.sync_auditing.getCode());
List<TtCouponChannelPoi> list = ttCouponChannelPoiMapper.findList(ttCouponChannelPoi);
if(list != null && list.size() > 0){
for (TtCouponChannelPoi poi:list) {
try{
ttMerchantPoiService.spuGet(poi,poi.getId());
}catch(Exception e){
logger.error("查询商品同步任务失败");
}
}
}
}

}

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

@@ -0,0 +1,43 @@
package com.iformall.domain.po;

import com.baomidou.mybatisplus.annotation.TableName;
import com.google.gson.JsonObject;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.utils.Constant;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import java.math.BigDecimal;
import java.util.Date;

@TableName(value = "tt_coupon_channel_poi")
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
public class TtCouponChannelPoi extends TenantEntity {

protected Long id;//coupon_channel_id

@io.swagger.annotations.ApiModelProperty(value="spuId",name="spuId")
private String spuId;

@io.swagger.annotations.ApiModelProperty(value="状态:0-审核中,1-上架,2-下架,3-审核拒绝 4-审核通过",name="status")
private Integer status;

@io.swagger.annotations.ApiModelProperty(value="描述",name="statusDesc")
private String statusDesc;

@io.swagger.annotations.ApiModelProperty(value="状态:0-审核中,1-上架,2-下架,3-审核拒绝 4-审核通过",name="lastStatus")
private Integer lastStatus;

@io.swagger.annotations.ApiModelProperty(value="描述",name="lastStatusDesc")
private String lastStatusDesc;

@io.swagger.annotations.ApiModelProperty(value="创建时间",name="createDate")
private Date createDate;
@io.swagger.annotations.ApiModelProperty(value="更新时间",name="updateDate")
private Date updateDate;


}

+ 40
- 0
mallinkService/src/main/java/com/iformall/enums/EnumSpuSyncStatus.java Просмотреть файл

@@ -0,0 +1,40 @@
package com.iformall.enums;

/**
* Created by Stormeye on 2018/08/09.
*/
public enum EnumSpuSyncStatus {
// 状态:0-审核中,1-上架,2-下架,3-审核拒绝 4-审核通过
// sync_update(-1, "等待重新同步"),
sync_auditing(0, "审核中"),
sync_put_on(1, "上架"),
sync_pull_off(2, "下架"),
sync_audit_rejection(3, "审核拒绝"),
sync_audit_pass(4, "审核通过"),
;

public static EnumSpuSyncStatus getEnum(Integer code) {
for (EnumSpuSyncStatus value : values()) {
if (value.getCode().equals(code)) {
return value;
}
}
return null;
}

private Integer code;
private String message;

EnumSpuSyncStatus(Integer code, String message) {
this.code = code;
this.message = message;
}

public Integer getCode() {
return code;
}

public String getMessage() {
return message;
}
}

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

@@ -0,0 +1,14 @@
package com.iformall.mapper;

import com.iformall.common.CommonMapper;
import com.iformall.domain.po.TtCouponChannelPoi;

import java.util.List;

public interface TtCouponChannelPoiMapper extends CommonMapper<TtCouponChannelPoi, Long> {

List<TtCouponChannelPoi> findList(TtCouponChannelPoi record);

List<Long> findIdList(TtCouponChannelPoi record);

}

+ 2
- 1
mallinkService/src/main/java/com/iformall/service/WxCouponChannelService.java Просмотреть файл

@@ -67,5 +67,6 @@ public interface WxCouponChannelService {
void setChannelStock(WxCouponChannel record,Integer number);
void releaseChannelStock(WxCouponChannel record);
void setChannelPrice(WxCouponChannel record);

ResultData getCouponChannelPoi(TenantEntity tenantInfo, Long id);
}

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

@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.iformall.common.ErrorCode;
@@ -55,6 +54,9 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService {
@Autowired
WxCouponChannelMapper wxCouponChannelMapper;

@Autowired
TtCouponChannelPoiMapper ttCouponChannelPoiMapper;

@Autowired
WxCouponMapper wxCouponMapper;

@@ -605,9 +607,31 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService {
ccUpd.setTtSpuId(spuId);
ccUpd.setUpdateDate(new Date());
wxCouponChannelMapper.updateById(ccUpd);

syncCouponChannelPoi(ccUpd);
return new ResultData();
}

private void syncCouponChannelPoi(WxCouponChannel ccUpd){
TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(ccUpd.getId());
if(ttCouponChannelPoi != null){
ttCouponChannelPoi.setLastStatus(EnumSpuSyncStatus.sync_auditing.getCode());
ttCouponChannelPoi.setLastStatusDesc("");
ttCouponChannelPoi.setUpdateDate(ccUpd.getUpdateDate());
ttCouponChannelPoiMapper.updateById(ttCouponChannelPoi);
}else{
ttCouponChannelPoi = new TtCouponChannelPoi();
ttCouponChannelPoi.setId(ccUpd.getId());
ttCouponChannelPoi.updateTenantInfo(ccUpd);
ttCouponChannelPoi.setSpuId(ccUpd.getTtSpuId());
ttCouponChannelPoi.setStatus(EnumSpuSyncStatus.sync_auditing.getCode());
ttCouponChannelPoi.setLastStatus(EnumSpuSyncStatus.sync_auditing.getCode());
ttCouponChannelPoi.setCreateDate(ccUpd.getUpdateDate());
ttCouponChannelPoi.setUpdateDate(ccUpd.getUpdateDate());
ttCouponChannelPoiMapper.insert(ttCouponChannelPoi);
}
}

private String spuSync(WxCoupon coupon,WxCouponChannel couponChannel, List<Long> merchantIds){
TtSpuSync spuSync = new TtSpuSync();
spuSync.setEntryInfo(getEntryInfo(couponChannel));
@@ -759,6 +783,7 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService {
spuGet.setSpuDraftcount(3);
try {
TtSpuGetResult spuGetResult = getTtWebService(tenantInfo).getProductService().spuGet(spuGet);
handSyncCouponChannelPoi(tenantInfo,spuGetResult);
//处理一下数据
Map<String,Object> map = new HashMap<>();
if(spuGetResult.getSpuDetail() != null){//线上数据
@@ -776,6 +801,60 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService {
}
}

private void handSyncCouponChannelPoi(TenantEntity tenantInfo,TtSpuGetResult spuGetResult){
Date now = new Date();
TtSpuSync spuDetail = spuGetResult.getSpuDetail();
if(spuDetail != null && StringUtils.isNotBlank(spuDetail.getSpuId()) && StringUtils.isNotBlank(spuDetail.getSpuExtId())
&& spuDetail.getStatus() != null){
TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(Long.parseLong(spuDetail.getSpuExtId()));
if(ttCouponChannelPoi != null && !spuDetail.getStatus().equals(ttCouponChannelPoi.getStatus())){
TtCouponChannelPoi ccPoi = new TtCouponChannelPoi();
ccPoi.setId(ttCouponChannelPoi.getId());
ccPoi.setStatus(spuDetail.getStatus());
ccPoi.setStatusDesc(spuDetail.getStatusDesc());
ccPoi.setUpdateDate(now);
ttCouponChannelPoiMapper.updateById(ccPoi);
}else if(ttCouponChannelPoi == null){
ttCouponChannelPoi = new TtCouponChannelPoi();
ttCouponChannelPoi.setId(Long.parseLong(spuDetail.getSpuExtId()));
ttCouponChannelPoi.updateTenantInfo(tenantInfo);
ttCouponChannelPoi.setSpuId(spuDetail.getSpuId());
ttCouponChannelPoi.setStatus(spuDetail.getStatus());
ttCouponChannelPoi.setStatusDesc(spuDetail.getStatusDesc());
ttCouponChannelPoi.setCreateDate(now);
ttCouponChannelPoi.setUpdateDate(now);
ttCouponChannelPoiMapper.insert(ttCouponChannelPoi);
}
}
List<TtSpuSync> spuDraftList = spuGetResult.getSpuDraft();
if(spuDraftList != null && spuDraftList.size() > 0){
TtSpuSync spuDraft = spuDraftList.get(0);
if(spuDraft != null && StringUtils.isNotBlank(spuDraft.getSpuId()) && StringUtils.isNotBlank(spuDraft.getSpuExtId())
&& spuDraft.getStatus() != null){
TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(Long.parseLong(spuDraft.getSpuExtId()));
if(ttCouponChannelPoi != null && !spuDraft.getStatus().equals(ttCouponChannelPoi.getStatus())){
TtCouponChannelPoi ccPoi = new TtCouponChannelPoi();
ccPoi.setId(ttCouponChannelPoi.getId());
ccPoi.setLastStatus(spuDraft.getStatus());
ccPoi.setLastStatusDesc(spuDraft.getStatusDesc());
ccPoi.setUpdateDate(now);
ttCouponChannelPoiMapper.updateById(ccPoi);
}else if(ttCouponChannelPoi == null){
ttCouponChannelPoi = new TtCouponChannelPoi();
ttCouponChannelPoi.setId(Long.parseLong(spuDetail.getSpuExtId()));
ttCouponChannelPoi.updateTenantInfo(tenantInfo);
ttCouponChannelPoi.setSpuId(spuDraft.getSpuId());
ttCouponChannelPoi.setStatus(EnumSpuSyncStatus.sync_auditing.getCode());
ttCouponChannelPoi.setLastStatus(spuDraft.getStatus());
ttCouponChannelPoi.setLastStatusDesc(spuDraft.getStatusDesc());
ttCouponChannelPoi.setCreateDate(now);
ttCouponChannelPoi.setUpdateDate(now);
ttCouponChannelPoiMapper.insert(ttCouponChannelPoi);
}
}
}
}

private Map<String,Object> handSpuSync(TtSpuSync spuSync){
Map<String,Object> map = new HashMap<>();
map.put("id",spuSync.getSpuExtId());


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

@@ -6,6 +6,7 @@ import com.iformall.common.ErrorCode;
import com.iformall.common.IdWorker;
import com.iformall.common.Result;
import com.iformall.common.ResultData;
import com.iformall.domain.po.TtCouponChannelPoi;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.po.WxCoupon;
import com.iformall.domain.po.WxCouponChannel;
@@ -56,6 +57,9 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService {
WxMerchantMapper wxMerchantMapper;
@Autowired
WxCouponMerchantMapper wxCouponMerchantMapper;

@Autowired
TtCouponChannelPoiMapper ttCouponChannelPoiMapper;
@Lazy
@Autowired
@@ -727,5 +731,14 @@ public class WxCouponChannelServiceImpl implements WxCouponChannelService {
wxCouponChannelMapper.setChannelPrice(record.getId(), record.getTenantId(), record.getChannelPrice());
}

@Override
public ResultData getCouponChannelPoi(TenantEntity tenantInfo, Long id) {
TtCouponChannelPoi ttCouponChannelPoi = ttCouponChannelPoiMapper.selectById(id);
if(ttCouponChannelPoi != null && ttCouponChannelPoi.getStatus() != null && ttCouponChannelPoi.getStatus().intValue() > 0){
return new ResultData(ttCouponChannelPoi);
}
return new ResultData(ErrorCode.SYS_NULLPOINTER_ERROR.getCode(),"未找到可用的数据");
}

}


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

@@ -1326,7 +1326,7 @@ public class WxPayOrderServiceImpl implements WxPayOrderService {
}else if(list != null && list.size() > 1){
throw new MallinkException(ErrorCode.PAY_ORDER_ERROR);
}
return null;
throw new MallinkException(ErrorCode.PAY_ORDER_NOT_FOUND);
}

@Override


+ 80
- 0
mallinkService/src/main/resources/mapper/TtCouponChannelPoiMapper.xml Просмотреть файл

@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.iformall.mapper.TtCouponChannelPoiMapper">
<resultMap id="BaseResultMap" type="com.iformall.domain.po.TtCouponChannelPoi">
<id column="id" jdbcType="BIGINT" property="id"/>
<result column="tenant_id" jdbcType="VARCHAR" property="tenantId"/>
<result column="parent_tenant_id" jdbcType="VARCHAR" property="parentTenantId"/>
<result column="spu_id" jdbcType="VARCHAR" property="spuId"/>
<result column="status" jdbcType="INTEGER" property="status"/>
<result column="status_desc" jdbcType="VARCHAR" property="statusDesc"/>

<result column="last_status" jdbcType="INTEGER" property="lastStatus"/>
<result column="last_status_desc" jdbcType="VARCHAR" property="lastStatusDesc"/>

<result column="create_date" jdbcType="TIMESTAMP" property="createDate"/>
<result column="update_date" jdbcType="TIMESTAMP" property="updateDate"/>

</resultMap>
<sql id="allColumns">
`id`,`tenant_id`,`parent_tenant_id`,`spu_id`,
`status`,`status_desc`,`last_status`,`last_status_desc`,
`create_date`,`update_date`
</sql>
<sql id="dynamicWhereConditions">
where is_del = 0

<if test=" null != id ">
and `id` = #{id}
</if>

<if test=" null != tenantId and '' != tenantId">
and `tenant_id` = #{tenantId}
</if>
<if test=" null != parentTenantId and '' != parentTenantId">
and `parent_tenant_id` = #{parentTenantId}
</if>

<if test=" null != spuId and '' != spuId">
and `spu_id` = #{spuId}
</if>

<if test=" null != status">
and `status` = #{status}
</if>

<if test=" null != lastStatus">
and `last_status` = #{lastStatus}
</if>

<if test=" null != ids ">
and `id` in
<foreach collection="ids" index="index" item="idItem" open="(" separator="," close=")">
#{idItem}
</foreach>
</if>

<if test=" null != sortColumns">order by ${sortColumns}</if>
</sql>

<select id="findList" parameterType="com.iformall.domain.po.TtCouponChannelPoi" resultMap="BaseResultMap">
select
<include refid="allColumns"/>
from tt_coupon_channel_poi
<include refid="dynamicWhereConditions"/>
</select>
<select id="findIdList" parameterType="com.iformall.domain.po.TtCouponChannelPoi" resultType="Long">
select id
from tt_coupon_channel_poi
<include refid="dynamicWhereConditions"/>
</select>

<update id="deleteByUpdate" parameterType="Long">
update tt_coupon_channel_poi set is_del = 1
where id = #{id}
</update>

</mapper>

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