Commit 1d5445f6 authored by shiyu's avatar shiyu

藏品详情新增藏家二维码

parent 269bb643
package com.wwdz.ch.admin.job;
import com.github.pagehelper.PageInfo;
import com.wwdz.ch.core.api.LogisticsApi;
import com.wwdz.ch.core.consts.DistributionEnum;
import com.wwdz.ch.core.entity.LogisticsInfo;
import com.wwdz.ch.core.entity.LogisticsRequestDto;
import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.db.dao.distribution.DistributionOrderDao;
import com.wwdz.ch.db.domain.User;
import com.wwdz.ch.db.domain.distribution.DistributionOrder;
import com.wwdz.ch.db.domain.distribution.SpecialPerformance;
import com.wwdz.ch.db.dto.request.UserRequestDto;
import com.wwdz.ch.db.dto.request.distribution.DistributionOrderRequestDto;
import com.wwdz.ch.db.dto.request.distribution.SpecialPerformanceRequestDto;
import com.xxdxxs.utils.DateUtils;
import com.xxdxxs.utils.StringUtils;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.time.Duration;
import java.time.Instant;
import java.util.Date;
import java.util.List;
@Component
public class RefreshLogisticsJob {
private static final Logger logger = LoggerFactory.getLogger(RefreshLogisticsJob.class);
private final static String REFRESH_LOGISTICS_KEY = "REFRESH_LOGISTICS_KEY";
@Autowired
RedissonClient redissonClient;
@Autowired
DistributionOrderDao distributionOrderDao;
@Autowired
LogisticsApi logisticsApi;
/**
* 隔4小时运行一次
*/
// @Scheduled(fixedDelay = 1000 * 60 * 60 * 4)
public void execute() {
RLock lock = redissonClient.getLock(REFRESH_LOGISTICS_KEY);
if (!lock.tryLock()) {
logger.warn("更新物流状态,当前服务实例获取锁成功: {} 获取锁失败,锁被占用不执行", Thread.currentThread().getId());
return;
}
logger.info(">>>>>>>>>>>>>>>>>>>>>>> 更新物流状态任务,开始执行 <<<<<<<<<<<<<<<<<<<<<");
try {
//查询7天前发货订单
boolean hasNextPage = true;
int page = 0;
while (hasNextPage) {
page = page + 1;
DistributionOrderRequestDto distributionOrderRequestDto = new DistributionOrderRequestDto();
distributionOrderRequestDto.setPage(page);
distributionOrderRequestDto.setState(DistributionEnum.DistributionOrderStateEnum.PRE_SIGNED.getCode());
Date now = new Date();
Instant startInstant = now.toInstant().minus(Duration.ofDays(7));
Date startTime = Date.from(startInstant);
distributionOrderRequestDto.setStartDeliveryTime(startTime);
distributionOrderRequestDto.setEndDeliveryTime(now);
List<DistributionOrder> distributionOrderList = distributionOrderDao.findByPage(distributionOrderRequestDto);
PageInfo pageInfo = new PageInfo(distributionOrderList);
for (DistributionOrder distributionOrder : distributionOrderList) {
String orderId = distributionOrder.getDistributionOrderId();
LogisticsRequestDto logisticsRequestDto = new LogisticsRequestDto();
logisticsRequestDto.setLogisticsCode(distributionOrder.getLogisticsCode());
logisticsRequestDto.setWaybill(distributionOrder.getWaybill());
Result result = logisticsApi.findTrails(logisticsRequestDto);
if (!result.getSuccess()) {
logger.error("订单号:{} 查询物流轨迹失败", orderId);
continue;
}
LogisticsInfo logisticsInfo = (LogisticsInfo) result.getData();
int logisticsState = Integer.parseInt(logisticsInfo.getState());
if (logisticsState != distributionOrder.getLogisticsState().intValue()) {
DistributionOrder updateDto = new DistributionOrder();
updateDto.setDistributionOrderId(orderId);
updateDto.setLogisticsState(logisticsState);
distributionOrderDao.update(distributionOrder);
}
}
hasNextPage = pageInfo.isHasNextPage();
}
logger.info("================更新物流状态任务执行成功 ==============");
} catch (Exception e) {
logger.error("更新物流状态任务 error {}", e);
} finally {
if (lock != null && lock.isHeldByCurrentThread()) {
lock.unlock();
logger.info("======================== 线程id: {} , 更新物流状态任务执行结束, 释放锁成功 ========================", Thread.currentThread().getId());
}
}
}
}
package com.wwdz.ch.wx.api;
package com.wwdz.ch.core.api;
import com.wwdz.ch.core.consts.CommonEnum;
import com.wwdz.ch.core.consts.LogisticsEnum;
......@@ -80,7 +80,6 @@ public class LogisticsApi {
logisticsInfo.setStateName(CommonEnum.LogisticsStateEnum.getNameByCode(Integer.parseInt(state)));
return Result.success(logisticsInfo);
}
return Result.failed();
} catch (Exception e) {
logger.error("查询物流轨迹error :{}", e);
}
......
package com.wwdz.ch.core.consts;
/**
* 物流状态
*/
public class LogisticsStateEnum {
public enum StateEnum {
NO_TRAIL(0, "暂无轨迹信息"),
TAKED(1, "已揽收"),
ON_THE_WAY(2, "在途中"),
SIGNED(3, "已签收"),
PROBLEM(4, "问题件"),
;
private int code;
private String name;
StateEnum(Integer code, String name) {
this.code = code;
this.name = name;
}
public static String getNameByCode(Integer code) {
for (LogisticsStateEnum.StateEnum stateEnum : LogisticsStateEnum.StateEnum.values()) {
if (code != null && stateEnum.getCode() == code) {
return stateEnum.getName();
}
}
return null;
}
public int getCode() {
return code;
}
public String getName() {
return name;
}
}
}
......@@ -277,4 +277,14 @@ public class SupplierItemVo implements Entity {
*/
private Boolean isHasDiscountOrder;
/**
* 藏家二维码
*/
private String wechatQrCode;
/**
* 介绍人佣金
*/
private String introduceCost;
}
......@@ -10,7 +10,7 @@ import lombok.Data;
/**
* @author shiyu
* @date 2024/02/29
* @date 2024/06/17
*/
@Data
public class DistributionOrder implements Entity {
......@@ -132,7 +132,12 @@ public class DistributionOrder implements Entity {
private Integer state;
/**
* 订单类型1一口价2竞拍
* 物流状态
*/
private Integer logisticsState;
/**
* 订单类型1一口价2竞拍3藏馆订单4促销订单
*/
private Integer type;
......@@ -168,6 +173,7 @@ public class DistributionOrder implements Entity {
sb.append(", updateTime=").append(updateTime);
sb.append(", shareRecordId=").append(shareRecordId);
sb.append(", state=").append(state);
sb.append(", logisticsState=").append(logisticsState);
sb.append(", type=").append(type);
sb.append(", serialVersionUID=").append(serialVersionUID);
sb.append("]");
......@@ -210,6 +216,7 @@ public class DistributionOrder implements Entity {
&& (this.getUpdateTime() == null ? other.getUpdateTime() == null : this.getUpdateTime().equals(other.getUpdateTime()))
&& (this.getShareRecordId() == null ? other.getShareRecordId() == null : this.getShareRecordId().equals(other.getShareRecordId()))
&& (this.getState() == null ? other.getState() == null : this.getState().equals(other.getState()))
&& (this.getLogisticsState() == null ? other.getLogisticsState() == null : this.getLogisticsState().equals(other.getLogisticsState()))
&& (this.getType() == null ? other.getType() == null : this.getType().equals(other.getType()));
}
......@@ -241,6 +248,7 @@ public class DistributionOrder implements Entity {
result = prime * result + ((getUpdateTime() == null) ? 0 : getUpdateTime().hashCode());
result = prime * result + ((getShareRecordId() == null) ? 0 : getShareRecordId().hashCode());
result = prime * result + ((getState() == null) ? 0 : getState().hashCode());
result = prime * result + ((getLogisticsState() == null) ? 0 : getLogisticsState().hashCode());
result = prime * result + ((getType() == null) ? 0 : getType().hashCode());
return result;
}
......@@ -277,6 +285,7 @@ public class DistributionOrder implements Entity {
updateTime("update_time", "updateTime", "TIMESTAMP", false),
shareRecordId("share_record_id", "shareRecordId", "VARCHAR", false),
state("state", "state", "INTEGER", true),
logisticsState("logistics_state", "logisticsState", "INTEGER", false),
type("type", "type", "INTEGER", true);
/**
......
......@@ -3416,6 +3416,138 @@ public class DistributionOrderExample {
return (Criteria) this;
}
public Criteria andLogisticsStateIsNull() {
addCriterion("logistics_state is null");
return (Criteria) this;
}
public Criteria andLogisticsStateIsNotNull() {
addCriterion("logistics_state is not null");
return (Criteria) this;
}
public Criteria andLogisticsStateEqualTo(Integer value) {
addCriterion("logistics_state =", value, "logisticsState");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table distribution_order
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andLogisticsStateEqualToColumn(DistributionOrder.Column column) {
addCriterion(new StringBuilder("logistics_state = ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andLogisticsStateNotEqualTo(Integer value) {
addCriterion("logistics_state <>", value, "logisticsState");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table distribution_order
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andLogisticsStateNotEqualToColumn(DistributionOrder.Column column) {
addCriterion(new StringBuilder("logistics_state <> ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andLogisticsStateGreaterThan(Integer value) {
addCriterion("logistics_state >", value, "logisticsState");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table distribution_order
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andLogisticsStateGreaterThanColumn(DistributionOrder.Column column) {
addCriterion(new StringBuilder("logistics_state > ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andLogisticsStateGreaterThanOrEqualTo(Integer value) {
addCriterion("logistics_state >=", value, "logisticsState");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table distribution_order
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andLogisticsStateGreaterThanOrEqualToColumn(DistributionOrder.Column column) {
addCriterion(new StringBuilder("logistics_state >= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andLogisticsStateLessThan(Integer value) {
addCriterion("logistics_state <", value, "logisticsState");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table distribution_order
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andLogisticsStateLessThanColumn(DistributionOrder.Column column) {
addCriterion(new StringBuilder("logistics_state < ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andLogisticsStateLessThanOrEqualTo(Integer value) {
addCriterion("logistics_state <=", value, "logisticsState");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table distribution_order
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andLogisticsStateLessThanOrEqualToColumn(DistributionOrder.Column column) {
addCriterion(new StringBuilder("logistics_state <= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andLogisticsStateIn(List<Integer> values) {
addCriterion("logistics_state in", values, "logisticsState");
return (Criteria) this;
}
public Criteria andLogisticsStateNotIn(List<Integer> values) {
addCriterion("logistics_state not in", values, "logisticsState");
return (Criteria) this;
}
public Criteria andLogisticsStateBetween(Integer value1, Integer value2) {
addCriterion("logistics_state between", value1, value2, "logisticsState");
return (Criteria) this;
}
public Criteria andLogisticsStateNotBetween(Integer value1, Integer value2) {
addCriterion("logistics_state not between", value1, value2, "logisticsState");
return (Criteria) this;
}
public Criteria andTypeIsNull() {
addCriterion("`type` is null");
return (Criteria) this;
......
......@@ -153,6 +153,15 @@ public class DistributionOrderRequestDto extends BaseRequestDto implements Entit
private Date endCreateTime;
private Date startDeliveryTime;
private Date endDeliveryTime;
/**
* 物流状态
*/
private Integer logisticsState;
/**
* 订单类型
* 1 一口价
......
......@@ -4,11 +4,8 @@ import com.wwdz.ch.db.bean.DistributionOrderNum;
import com.wwdz.ch.db.domain.distribution.DistributionOrder;
import com.wwdz.ch.db.domain.distribution.DistributionOrderExample;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface DistributionOrderMapper {
long countByExample(DistributionOrderExample example);
......
......@@ -26,6 +26,7 @@
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="share_record_id" jdbcType="VARCHAR" property="shareRecordId" />
<result column="state" jdbcType="INTEGER" property="state" />
<result column="logistics_state" jdbcType="INTEGER" property="logisticsState" />
<result column="type" jdbcType="INTEGER" property="type" />
</resultMap>
<sql id="Example_Where_Clause">
......@@ -90,7 +91,7 @@
id, distribution_order_id, prepay_id, transaction_id, item_id, item_num, buyer_id,
buyer_openid, shop_id, seller_id, amount, address_id, receiver_name, receiver_phone,
receiver_address, logistics_code, waybill, create_time, pay_time, delivery_time,
finish_time, update_time, share_record_id, `state`, `type`
finish_time, update_time, share_record_id, `state`, logistics_state, `type`
</sql>
<select id="selectByExample" parameterType="com.wwdz.ch.db.domain.distribution.DistributionOrderExample" resultMap="BaseResultMap">
select
......@@ -128,7 +129,7 @@
id, distribution_order_id, prepay_id, transaction_id, item_id, item_num, buyer_id,
buyer_openid, shop_id, seller_id, amount, address_id, receiver_name, receiver_phone,
receiver_address, logistics_code, waybill, create_time, pay_time, delivery_time,
finish_time, update_time, share_record_id, `state`, `type`
finish_time, update_time, share_record_id, `state`, logistics_state, `type`
</otherwise>
</choose>
from distribution_order
......@@ -162,7 +163,7 @@
id, distribution_order_id, prepay_id, transaction_id, item_id, item_num, buyer_id,
buyer_openid, shop_id, seller_id, amount, address_id, receiver_name, receiver_phone,
receiver_address, logistics_code, waybill, create_time, pay_time, delivery_time,
finish_time, update_time, share_record_id, `state`, `type`
finish_time, update_time, share_record_id, `state`, logistics_state, `type`
</otherwise>
</choose>
from distribution_order
......@@ -189,8 +190,8 @@
receiver_phone, receiver_address, logistics_code,
waybill, create_time, pay_time,
delivery_time, finish_time, update_time,
share_record_id, `state`, `type`
)
share_record_id, `state`, logistics_state,
`type`)
values (#{distributionOrderId,jdbcType=VARCHAR}, #{prepayId,jdbcType=VARCHAR}, #{transactionId,jdbcType=VARCHAR},
#{itemId,jdbcType=BIGINT}, #{itemNum,jdbcType=INTEGER}, #{buyerId,jdbcType=BIGINT},
#{buyerOpenid,jdbcType=VARCHAR}, #{shopId,jdbcType=BIGINT}, #{sellerId,jdbcType=BIGINT},
......@@ -198,8 +199,8 @@
#{receiverPhone,jdbcType=VARCHAR}, #{receiverAddress,jdbcType=VARCHAR}, #{logisticsCode,jdbcType=VARCHAR},
#{waybill,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, #{payTime,jdbcType=TIMESTAMP},
#{deliveryTime,jdbcType=TIMESTAMP}, #{finishTime,jdbcType=TIMESTAMP}, #{updateTime,jdbcType=TIMESTAMP},
#{shareRecordId,jdbcType=VARCHAR}, #{state,jdbcType=INTEGER}, #{type,jdbcType=INTEGER}
)
#{shareRecordId,jdbcType=VARCHAR}, #{state,jdbcType=INTEGER}, #{logisticsState,jdbcType=INTEGER},
#{type,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.distribution.DistributionOrder">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
......@@ -276,6 +277,9 @@
<if test="state != null">
`state`,
</if>
<if test="logisticsState != null">
logistics_state,
</if>
<if test="type != null">
`type`,
</if>
......@@ -350,6 +354,9 @@
<if test="state != null">
#{state,jdbcType=INTEGER},
</if>
<if test="logisticsState != null">
#{logisticsState,jdbcType=INTEGER},
</if>
<if test="type != null">
#{type,jdbcType=INTEGER},
</if>
......@@ -436,6 +443,9 @@
<if test="record.state != null">
`state` = #{record.state,jdbcType=INTEGER},
</if>
<if test="record.logisticsState != null">
logistics_state = #{record.logisticsState,jdbcType=INTEGER},
</if>
<if test="record.type != null">
`type` = #{record.type,jdbcType=INTEGER},
</if>
......@@ -470,6 +480,7 @@
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
share_record_id = #{record.shareRecordId,jdbcType=VARCHAR},
`state` = #{record.state,jdbcType=INTEGER},
logistics_state = #{record.logisticsState,jdbcType=INTEGER},
`type` = #{record.type,jdbcType=INTEGER}
<if test="_parameter != null">
<include refid="Update_By_Example_Where_Clause" />
......@@ -547,6 +558,9 @@
<if test="state != null">
`state` = #{state,jdbcType=INTEGER},
</if>
<if test="logisticsState != null">
logistics_state = #{logisticsState,jdbcType=INTEGER},
</if>
<if test="type != null">
`type` = #{type,jdbcType=INTEGER},
</if>
......@@ -578,6 +592,7 @@
update_time = #{updateTime,jdbcType=TIMESTAMP},
share_record_id = #{shareRecordId,jdbcType=VARCHAR},
`state` = #{state,jdbcType=INTEGER},
logistics_state = #{logisticsState,jdbcType=INTEGER},
`type` = #{type,jdbcType=INTEGER}
where id = #{id,jdbcType=INTEGER}
</update>
......@@ -617,7 +632,7 @@
id, distribution_order_id, prepay_id, transaction_id, item_id, item_num, buyer_id,
buyer_openid, shop_id, seller_id, amount, address_id, receiver_name, receiver_phone,
receiver_address, logistics_code, waybill, create_time, pay_time, delivery_time,
finish_time, update_time, share_record_id, `state`, `type`
finish_time, update_time, share_record_id, `state`, logistics_state, `type`
</otherwise>
</choose>
from distribution_order
......
......@@ -63,16 +63,16 @@
<!--生成Model类存放位置-->
<javaModelGenerator targetPackage="com.wwdz.ch.db.domain" targetProject="ch-dao/src/main/java">
<javaModelGenerator targetPackage="com.wwdz.ch.db.domain.distribution" targetProject="ch-dao/src/main/java">
<property name="enableSubPackages" value="true"/>
<property name="trimStrings" value="true"/>
</javaModelGenerator>
<sqlMapGenerator targetPackage="com.wwdz.ch.db.mapper" targetProject="ch-dao/src/main/resources"/>
<javaClientGenerator type="XMLMAPPER" targetPackage="com.wwdz.ch.db.mapper"
<sqlMapGenerator targetPackage="com.wwdz.ch.db.mapper.distribution" targetProject="ch-dao/src/main/resources"/>
<javaClientGenerator type="XMLMAPPER" targetPackage="com.wwdz.ch.db.mapper.distribution"
targetProject="ch-dao/src/main/java"/>
<table tableName="user" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<table tableName="distribution_order" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<generatedKey column="id" sqlStatement="Mysql" identity="true" />
</table>
......
......@@ -144,6 +144,13 @@ public class DistributionOrderVo implements Entity {
*/
private String stateName;
/**
* 物流状态
*/
private Integer logisticsState;
private Integer logisticsStateName;
/**
* 商品单价
*/
......
......@@ -54,7 +54,7 @@ public class DistributorProfitServiceImpl implements DistributorProfitService {
if (year == 1) {
rebate = 0.03;
} else if (year == 2){
rebate = 0.03;
rebate = 0.02;
} else if (year == 3) {
rebate = 0.01;
}
......
......@@ -9,7 +9,7 @@ import com.wwdz.ch.db.dao.distribution.DistributionOrderDao;
import com.wwdz.ch.db.dao.distribution.IdentifyOrderDao;
import com.wwdz.ch.db.domain.distribution.DistributionOrder;
import com.wwdz.ch.db.domain.distribution.IdentifyOrder;
import com.wwdz.ch.wx.api.LogisticsApi;
import com.wwdz.ch.core.api.LogisticsApi;
import com.wwdz.ch.wx.service.distribution.LogisticsService;
import com.xxdxxs.utils.StringUtils;
import org.slf4j.Logger;
......
......@@ -787,6 +787,11 @@ public class SupplierItemServiceImpl implements SupplierItemService {
logger.info("用户id:{} 关注了 用户id为 {}, 介绍人为", dto.getUserId(), collectionShareRecord.getItemUserId(), collectionShareRecord.getSharerId());
}
}
//返回用户二维码
User user = cacheUtil.appletUserInfoCache.get(supplierItem.getCreatorId()).get();
if (user != null) {
supplierItemVo.setWechatQrCode(user.getWechatQrCode());
}
} else {
supplierItemVo.setIsMine(true);
//查询收藏该商品的最新的五个用户
......@@ -815,6 +820,12 @@ public class SupplierItemServiceImpl implements SupplierItemService {
//查询藏品被收藏的次数
long countNum = itemCollectedRecordDao.countByItemId(itemId);
supplierItemVo.setCollectedNum((int) countNum);
//估算介绍佣金
double rebate = 0.03;
double introduceCost = supplierItem.getDistributionPrice().doubleValue() * rebate;
supplierItemVo.setIntroduceCost(PriceUtil.convertDoubleToString(introduceCost));
supplierItemVo.setRebate("3%");
//查询商品所属标签
List<CollectionItemsRelation> collectionItemsRelations = collectionItemsRelationDao.findByItemId(itemId);
List<Long> collectBookIds = collectionItemsRelations.stream().map(CollectionItemsRelation::getCollectionBookId).collect(Collectors.toList());
......
package com.wwdz.ch.wx.api;
import com.wwdz.ch.core.api.LogisticsApi;
import com.wwdz.ch.core.entity.LogisticsRequestDto;
import com.wwdz.ch.core.type.Result;
import org.junit.Test;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment