Commit 84b2f4f7 authored by shiyu's avatar shiyu

出价记录

parent 156af042
...@@ -60,4 +60,11 @@ public interface AuctionRecordDao { ...@@ -60,4 +60,11 @@ public interface AuctionRecordDao {
*/ */
long count(AuctionRecordRequestDto dto); long count(AuctionRecordRequestDto dto);
/**
* 查询用户出价过的商品
* @param userId
* @return
*/
List<Long> findItemsOfRecord(long userId);
} }
package com.wwdz.ch.db.domain.distribution; package com.wwdz.ch.db.domain.distribution;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import com.xxdxxs.entity.Entity; import com.xxdxxs.entity.Entity;
import lombok.Data; import lombok.Data;
/** /**
* @author shiyu * @author shiyu
* @date 2024/02/29 * @date 2024/03/05
*/ */
@Data @Data
public class AuctionRecord implements Entity { public class AuctionRecord implements Entity {
...@@ -24,6 +26,11 @@ public class AuctionRecord implements Entity { ...@@ -24,6 +26,11 @@ public class AuctionRecord implements Entity {
*/ */
private Long userId; private Long userId;
/**
* 微信openid
*/
private String userOpenId;
/** /**
* 出价 * 出价
*/ */
...@@ -60,6 +67,7 @@ public class AuctionRecord implements Entity { ...@@ -60,6 +67,7 @@ public class AuctionRecord implements Entity {
sb.append(", id=").append(id); sb.append(", id=").append(id);
sb.append(", itemId=").append(itemId); sb.append(", itemId=").append(itemId);
sb.append(", userId=").append(userId); sb.append(", userId=").append(userId);
sb.append(", userOpenId=").append(userOpenId);
sb.append(", price=").append(price); sb.append(", price=").append(price);
sb.append(", createTime=").append(createTime); sb.append(", createTime=").append(createTime);
sb.append(", shareRecordId=").append(shareRecordId); sb.append(", shareRecordId=").append(shareRecordId);
...@@ -85,6 +93,7 @@ public class AuctionRecord implements Entity { ...@@ -85,6 +93,7 @@ public class AuctionRecord implements Entity {
return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId())) return (this.getId() == null ? other.getId() == null : this.getId().equals(other.getId()))
&& (this.getItemId() == null ? other.getItemId() == null : this.getItemId().equals(other.getItemId())) && (this.getItemId() == null ? other.getItemId() == null : this.getItemId().equals(other.getItemId()))
&& (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId())) && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
&& (this.getUserOpenId() == null ? other.getUserOpenId() == null : this.getUserOpenId().equals(other.getUserOpenId()))
&& (this.getPrice() == null ? other.getPrice() == null : this.getPrice().equals(other.getPrice())) && (this.getPrice() == null ? other.getPrice() == null : this.getPrice().equals(other.getPrice()))
&& (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime())) && (this.getCreateTime() == null ? other.getCreateTime() == null : this.getCreateTime().equals(other.getCreateTime()))
&& (this.getShareRecordId() == null ? other.getShareRecordId() == null : this.getShareRecordId().equals(other.getShareRecordId())) && (this.getShareRecordId() == null ? other.getShareRecordId() == null : this.getShareRecordId().equals(other.getShareRecordId()))
...@@ -99,6 +108,7 @@ public class AuctionRecord implements Entity { ...@@ -99,6 +108,7 @@ public class AuctionRecord implements Entity {
result = prime * result + ((getId() == null) ? 0 : getId().hashCode()); result = prime * result + ((getId() == null) ? 0 : getId().hashCode());
result = prime * result + ((getItemId() == null) ? 0 : getItemId().hashCode()); result = prime * result + ((getItemId() == null) ? 0 : getItemId().hashCode());
result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode()); result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
result = prime * result + ((getUserOpenId() == null) ? 0 : getUserOpenId().hashCode());
result = prime * result + ((getPrice() == null) ? 0 : getPrice().hashCode()); result = prime * result + ((getPrice() == null) ? 0 : getPrice().hashCode());
result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode()); result = prime * result + ((getCreateTime() == null) ? 0 : getCreateTime().hashCode());
result = prime * result + ((getShareRecordId() == null) ? 0 : getShareRecordId().hashCode()); result = prime * result + ((getShareRecordId() == null) ? 0 : getShareRecordId().hashCode());
...@@ -118,6 +128,7 @@ public class AuctionRecord implements Entity { ...@@ -118,6 +128,7 @@ public class AuctionRecord implements Entity {
id("id", "id", "INTEGER", false), id("id", "id", "INTEGER", false),
itemId("item_id", "itemId", "BIGINT", false), itemId("item_id", "itemId", "BIGINT", false),
userId("user_id", "userId", "BIGINT", false), userId("user_id", "userId", "BIGINT", false),
userOpenId("user_open_id", "userOpenId", "VARCHAR", false),
price("price", "price", "BIGINT", false), price("price", "price", "BIGINT", false),
createTime("create_time", "createTime", "TIMESTAMP", false), createTime("create_time", "createTime", "TIMESTAMP", false),
shareRecordId("share_record_id", "shareRecordId", "VARCHAR", false), shareRecordId("share_record_id", "shareRecordId", "VARCHAR", false),
......
...@@ -544,6 +544,148 @@ public class AuctionRecordExample { ...@@ -544,6 +544,148 @@ public class AuctionRecordExample {
return (Criteria) this; return (Criteria) this;
} }
public Criteria andUserOpenIdIsNull() {
addCriterion("user_open_id is null");
return (Criteria) this;
}
public Criteria andUserOpenIdIsNotNull() {
addCriterion("user_open_id is not null");
return (Criteria) this;
}
public Criteria andUserOpenIdEqualTo(String value) {
addCriterion("user_open_id =", value, "userOpenId");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table auction_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andUserOpenIdEqualToColumn(AuctionRecord.Column column) {
addCriterion(new StringBuilder("user_open_id = ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andUserOpenIdNotEqualTo(String value) {
addCriterion("user_open_id <>", value, "userOpenId");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table auction_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andUserOpenIdNotEqualToColumn(AuctionRecord.Column column) {
addCriterion(new StringBuilder("user_open_id <> ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andUserOpenIdGreaterThan(String value) {
addCriterion("user_open_id >", value, "userOpenId");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table auction_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andUserOpenIdGreaterThanColumn(AuctionRecord.Column column) {
addCriterion(new StringBuilder("user_open_id > ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andUserOpenIdGreaterThanOrEqualTo(String value) {
addCriterion("user_open_id >=", value, "userOpenId");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table auction_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andUserOpenIdGreaterThanOrEqualToColumn(AuctionRecord.Column column) {
addCriterion(new StringBuilder("user_open_id >= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andUserOpenIdLessThan(String value) {
addCriterion("user_open_id <", value, "userOpenId");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table auction_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andUserOpenIdLessThanColumn(AuctionRecord.Column column) {
addCriterion(new StringBuilder("user_open_id < ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andUserOpenIdLessThanOrEqualTo(String value) {
addCriterion("user_open_id <=", value, "userOpenId");
return (Criteria) this;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table auction_record
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public Criteria andUserOpenIdLessThanOrEqualToColumn(AuctionRecord.Column column) {
addCriterion(new StringBuilder("user_open_id <= ").append(column.getEscapedColumnName()).toString());
return (Criteria) this;
}
public Criteria andUserOpenIdLike(String value) {
addCriterion("user_open_id like", value, "userOpenId");
return (Criteria) this;
}
public Criteria andUserOpenIdNotLike(String value) {
addCriterion("user_open_id not like", value, "userOpenId");
return (Criteria) this;
}
public Criteria andUserOpenIdIn(List<String> values) {
addCriterion("user_open_id in", values, "userOpenId");
return (Criteria) this;
}
public Criteria andUserOpenIdNotIn(List<String> values) {
addCriterion("user_open_id not in", values, "userOpenId");
return (Criteria) this;
}
public Criteria andUserOpenIdBetween(String value1, String value2) {
addCriterion("user_open_id between", value1, value2, "userOpenId");
return (Criteria) this;
}
public Criteria andUserOpenIdNotBetween(String value1, String value2) {
addCriterion("user_open_id not between", value1, value2, "userOpenId");
return (Criteria) this;
}
public Criteria andPriceIsNull() { public Criteria andPriceIsNull() {
addCriterion("price is null"); addCriterion("price is null");
return (Criteria) this; return (Criteria) this;
......
...@@ -21,6 +21,11 @@ public class AuctionRecordRequestDto extends BaseRequestDto implements Entity { ...@@ -21,6 +21,11 @@ public class AuctionRecordRequestDto extends BaseRequestDto implements Entity {
*/ */
private Long userId; private Long userId;
/**
* 微信openid
*/
private String userOpenId;
/** /**
* 出价 * 出价
*/ */
......
...@@ -83,4 +83,10 @@ public class AuctionRecordDaoImpl implements AuctionRecordDao { ...@@ -83,4 +83,10 @@ public class AuctionRecordDaoImpl implements AuctionRecordDao {
JdbcHelper.ifPresent(dto.getIsLead(), criteria::andIsLeadEqualTo); JdbcHelper.ifPresent(dto.getIsLead(), criteria::andIsLeadEqualTo);
return auctionRecordMapper.countByExample(example); return auctionRecordMapper.countByExample(example);
} }
@Override
public List<Long> findItemsOfRecord(long userId) {
return null;
}
} }
...@@ -66,4 +66,7 @@ public interface AuctionRecordMapper { ...@@ -66,4 +66,7 @@ public interface AuctionRecordMapper {
int updateByPrimaryKeySelective(AuctionRecord record); int updateByPrimaryKeySelective(AuctionRecord record);
int updateByPrimaryKey(AuctionRecord record); int updateByPrimaryKey(AuctionRecord record);
List<Long> findItemsOfRecord(@Param("itemId")Long userId);
} }
\ No newline at end of file
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<id column="id" jdbcType="INTEGER" property="id" /> <id column="id" jdbcType="INTEGER" property="id" />
<result column="item_id" jdbcType="BIGINT" property="itemId" /> <result column="item_id" jdbcType="BIGINT" property="itemId" />
<result column="user_id" jdbcType="BIGINT" property="userId" /> <result column="user_id" jdbcType="BIGINT" property="userId" />
<result column="user_open_id" jdbcType="VARCHAR" property="userOpenId" />
<result column="price" jdbcType="BIGINT" property="price" /> <result column="price" jdbcType="BIGINT" property="price" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="share_record_id" jdbcType="VARCHAR" property="shareRecordId" /> <result column="share_record_id" jdbcType="VARCHAR" property="shareRecordId" />
...@@ -70,7 +71,8 @@ ...@@ -70,7 +71,8 @@
</where> </where>
</sql> </sql>
<sql id="Base_Column_List"> <sql id="Base_Column_List">
id, item_id, user_id, price, create_time, share_record_id, distributor_id, is_lead id, item_id, user_id, user_open_id, price, create_time, share_record_id, distributor_id,
is_lead
</sql> </sql>
<select id="selectByExample" parameterType="com.wwdz.ch.db.domain.distribution.AuctionRecordExample" resultMap="BaseResultMap"> <select id="selectByExample" parameterType="com.wwdz.ch.db.domain.distribution.AuctionRecordExample" resultMap="BaseResultMap">
select select
...@@ -99,14 +101,14 @@ ...@@ -99,14 +101,14 @@
distinct distinct
</if> </if>
<choose> <choose>
<when test="selective != null and selective.length > 0"> <when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=","> <foreach collection="selective" item="column" separator=",">
${column.escapedColumnName} ${column.escapedColumnName}
</foreach> </foreach>
</when> </when>
<otherwise> <otherwise>
id, item_id, user_id, price, create_time, share_record_id, distributor_id, is_lead id, item_id, user_id, user_open_id, price, create_time, share_record_id, distributor_id,
is_lead
</otherwise> </otherwise>
</choose> </choose>
from auction_record from auction_record
...@@ -131,14 +133,14 @@ ...@@ -131,14 +133,14 @@
--> -->
select select
<choose> <choose>
<when test="selective != null and selective.length > 0"> <when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=","> <foreach collection="selective" item="column" separator=",">
${column.escapedColumnName} ${column.escapedColumnName}
</foreach> </foreach>
</when> </when>
<otherwise> <otherwise>
id, item_id, user_id, price, create_time, share_record_id, distributor_id, is_lead id, item_id, user_id, user_open_id, price, create_time, share_record_id, distributor_id,
is_lead
</otherwise> </otherwise>
</choose> </choose>
from auction_record from auction_record
...@@ -158,12 +160,12 @@ ...@@ -158,12 +160,12 @@
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer"> <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
SELECT LAST_INSERT_ID() SELECT LAST_INSERT_ID()
</selectKey> </selectKey>
insert into auction_record (item_id, user_id, price, insert into auction_record (item_id, user_id, user_open_id,
create_time, share_record_id, distributor_id, price, create_time, share_record_id,
is_lead) distributor_id, is_lead)
values (#{itemId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{price,jdbcType=BIGINT}, values (#{itemId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT}, #{userOpenId,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{shareRecordId,jdbcType=VARCHAR}, #{distributorId,jdbcType=BIGINT}, #{price,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP}, #{shareRecordId,jdbcType=VARCHAR},
#{isLead,jdbcType=BIT}) #{distributorId,jdbcType=BIGINT}, #{isLead,jdbcType=BIT})
</insert> </insert>
<insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.distribution.AuctionRecord"> <insert id="insertSelective" parameterType="com.wwdz.ch.db.domain.distribution.AuctionRecord">
<selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer"> <selectKey keyProperty="id" order="AFTER" resultType="java.lang.Integer">
...@@ -177,6 +179,9 @@ ...@@ -177,6 +179,9 @@
<if test="userId != null"> <if test="userId != null">
user_id, user_id,
</if> </if>
<if test="userOpenId != null">
user_open_id,
</if>
<if test="price != null"> <if test="price != null">
price, price,
</if> </if>
...@@ -200,6 +205,9 @@ ...@@ -200,6 +205,9 @@
<if test="userId != null"> <if test="userId != null">
#{userId,jdbcType=BIGINT}, #{userId,jdbcType=BIGINT},
</if> </if>
<if test="userOpenId != null">
#{userOpenId,jdbcType=VARCHAR},
</if>
<if test="price != null"> <if test="price != null">
#{price,jdbcType=BIGINT}, #{price,jdbcType=BIGINT},
</if> </if>
...@@ -235,6 +243,9 @@ ...@@ -235,6 +243,9 @@
<if test="record.userId != null"> <if test="record.userId != null">
user_id = #{record.userId,jdbcType=BIGINT}, user_id = #{record.userId,jdbcType=BIGINT},
</if> </if>
<if test="record.userOpenId != null">
user_open_id = #{record.userOpenId,jdbcType=VARCHAR},
</if>
<if test="record.price != null"> <if test="record.price != null">
price = #{record.price,jdbcType=BIGINT}, price = #{record.price,jdbcType=BIGINT},
</if> </if>
...@@ -260,6 +271,7 @@ ...@@ -260,6 +271,7 @@
set id = #{record.id,jdbcType=INTEGER}, set id = #{record.id,jdbcType=INTEGER},
item_id = #{record.itemId,jdbcType=BIGINT}, item_id = #{record.itemId,jdbcType=BIGINT},
user_id = #{record.userId,jdbcType=BIGINT}, user_id = #{record.userId,jdbcType=BIGINT},
user_open_id = #{record.userOpenId,jdbcType=VARCHAR},
price = #{record.price,jdbcType=BIGINT}, price = #{record.price,jdbcType=BIGINT},
create_time = #{record.createTime,jdbcType=TIMESTAMP}, create_time = #{record.createTime,jdbcType=TIMESTAMP},
share_record_id = #{record.shareRecordId,jdbcType=VARCHAR}, share_record_id = #{record.shareRecordId,jdbcType=VARCHAR},
...@@ -278,6 +290,9 @@ ...@@ -278,6 +290,9 @@
<if test="userId != null"> <if test="userId != null">
user_id = #{userId,jdbcType=BIGINT}, user_id = #{userId,jdbcType=BIGINT},
</if> </if>
<if test="userOpenId != null">
user_open_id = #{userOpenId,jdbcType=VARCHAR},
</if>
<if test="price != null"> <if test="price != null">
price = #{price,jdbcType=BIGINT}, price = #{price,jdbcType=BIGINT},
</if> </if>
...@@ -300,6 +315,7 @@ ...@@ -300,6 +315,7 @@
update auction_record update auction_record
set item_id = #{itemId,jdbcType=BIGINT}, set item_id = #{itemId,jdbcType=BIGINT},
user_id = #{userId,jdbcType=BIGINT}, user_id = #{userId,jdbcType=BIGINT},
user_open_id = #{userOpenId,jdbcType=VARCHAR},
price = #{price,jdbcType=BIGINT}, price = #{price,jdbcType=BIGINT},
create_time = #{createTime,jdbcType=TIMESTAMP}, create_time = #{createTime,jdbcType=TIMESTAMP},
share_record_id = #{shareRecordId,jdbcType=VARCHAR}, share_record_id = #{shareRecordId,jdbcType=VARCHAR},
...@@ -334,14 +350,14 @@ ...@@ -334,14 +350,14 @@
select select
'true' as QUERYID, 'true' as QUERYID,
<choose> <choose>
<when test="selective != null and selective.length > 0"> <when test="selective != null and selective.length &gt; 0">
<foreach collection="selective" item="column" separator=","> <foreach collection="selective" item="column" separator=",">
${column.escapedColumnName} ${column.escapedColumnName}
</foreach> </foreach>
</when> </when>
<otherwise> <otherwise>
id, item_id, user_id, price, create_time, share_record_id, distributor_id, is_lead id, item_id, user_id, user_open_id, price, create_time, share_record_id, distributor_id,
is_lead
</otherwise> </otherwise>
</choose> </choose>
from auction_record from auction_record
...@@ -353,4 +369,9 @@ ...@@ -353,4 +369,9 @@
</if> </if>
limit 1 limit 1
</select> </select>
<select id="findItemsOfRecord" parameterType="java.lang.Long" resultType="java.lang.Long">
select DISTINCT(`item_id`) from `auction_record` where user_id = = #{userId}
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
<javaClientGenerator type="XMLMAPPER" targetPackage="com.wwdz.ch.db.mapper.distribution" <javaClientGenerator type="XMLMAPPER" targetPackage="com.wwdz.ch.db.mapper.distribution"
targetProject="ch-dao/src/main/java"/> targetProject="ch-dao/src/main/java"/>
<table tableName="distribution_order" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true"> <table tableName="auction_record" enableCountByExample="true" enableUpdateByExample="true" enableDeleteByExample="true" enableSelectByExample="true" selectByExampleQueryId="true">
<generatedKey column="id" sqlStatement="Mysql" identity="true" /> <generatedKey column="id" sqlStatement="Mysql" identity="true" />
</table> </table>
......
...@@ -5,14 +5,8 @@ import com.wwdz.ch.core.consts.DistributionEnum; ...@@ -5,14 +5,8 @@ import com.wwdz.ch.core.consts.DistributionEnum;
import com.wwdz.ch.core.consts.ResultCode; import com.wwdz.ch.core.consts.ResultCode;
import com.wwdz.ch.core.type.Result; import com.wwdz.ch.core.type.Result;
import com.wwdz.ch.core.util.PriceUtil; import com.wwdz.ch.core.util.PriceUtil;
import com.wwdz.ch.db.dao.distribution.AuctionConfigDao; import com.wwdz.ch.db.dao.distribution.*;
import com.wwdz.ch.db.dao.distribution.AuctionRecordDao; import com.wwdz.ch.db.domain.distribution.*;
import com.wwdz.ch.db.dao.distribution.DistributionOrderDao;
import com.wwdz.ch.db.dao.distribution.SupplierItemDao;
import com.wwdz.ch.db.domain.distribution.AuctionConfig;
import com.wwdz.ch.db.domain.distribution.AuctionRecord;
import com.wwdz.ch.db.domain.distribution.DistributionOrder;
import com.wwdz.ch.db.domain.distribution.SupplierItem;
import com.wwdz.ch.db.dto.request.distribution.AuctionRecordRequestDto; import com.wwdz.ch.db.dto.request.distribution.AuctionRecordRequestDto;
import com.wwdz.ch.db.dto.request.distribution.DistributionOrderRequestDto; import com.wwdz.ch.db.dto.request.distribution.DistributionOrderRequestDto;
import com.wwdz.ch.wx.entity.vo.distribution.AuctionRecordVo; import com.wwdz.ch.wx.entity.vo.distribution.AuctionRecordVo;
...@@ -39,7 +33,7 @@ public class AuctionRecordServiceImpl implements AuctionRecordService { ...@@ -39,7 +33,7 @@ public class AuctionRecordServiceImpl implements AuctionRecordService {
private static final Logger logger = LoggerFactory.getLogger(AuctionRecordServiceImpl.class); private static final Logger logger = LoggerFactory.getLogger(AuctionRecordServiceImpl.class);
private static final String LOCK_KEY_PRE = "AUCTION:"; private static final String LOCK_KEY_PRE = "AUCTION:OFFER:";
@Autowired @Autowired
AuctionConfigDao auctionConfigDao; AuctionConfigDao auctionConfigDao;
...@@ -59,13 +53,14 @@ public class AuctionRecordServiceImpl implements AuctionRecordService { ...@@ -59,13 +53,14 @@ public class AuctionRecordServiceImpl implements AuctionRecordService {
@Autowired @Autowired
WxPayServiceApi wxPayServiceApi; WxPayServiceApi wxPayServiceApi;
@Autowired
DistributorShareRecordDao distributorShareRecordDao;
@Override @Override
@Transactional @Transactional
public Result createAuctionRecord(AuctionRecordRequestDto dto) { public Result createAuctionRecord(AuctionRecordRequestDto dto) {
long itemId = dto.getItemId(); long itemId = dto.getItemId();
String itemIdKey = LOCK_KEY_PRE + itemId; String itemIdKey = LOCK_KEY_PRE + itemId;
RLock lock = redissonClient.getLock(itemIdKey); RLock lock = redissonClient.getLock(itemIdKey);
try { try {
if (lock.tryLock(5, 5, TimeUnit.SECONDS)) { if (lock.tryLock(5, 5, TimeUnit.SECONDS)) {
...@@ -80,6 +75,11 @@ public class AuctionRecordServiceImpl implements AuctionRecordService { ...@@ -80,6 +75,11 @@ public class AuctionRecordServiceImpl implements AuctionRecordService {
} else if (!auctionConfig.getIsValid()) { } else if (!auctionConfig.getIsValid()) {
return Result.failed("该商品已截拍"); return Result.failed("该商品已截拍");
} }
String shareRecordId = dto.getShareRecordId();
DistributorShareRecord distributorShareRecord = distributorShareRecordDao.findById(shareRecordId);
if (!distributorShareRecord.getEnabled()) {
return Result.failed("该商品分享链接已失效");
}
//查询当前最新的价格 //查询当前最新的价格
AuctionRecord auctionRecord = auctionRecordDao.findLastedRecord(itemId); AuctionRecord auctionRecord = auctionRecordDao.findLastedRecord(itemId);
...@@ -95,12 +95,13 @@ public class AuctionRecordServiceImpl implements AuctionRecordService { ...@@ -95,12 +95,13 @@ public class AuctionRecordServiceImpl implements AuctionRecordService {
//插入最新出价记录 //插入最新出价记录
AuctionRecord addRecord = new AuctionRecord(); AuctionRecord addRecord = new AuctionRecord();
addRecord.setIsLead(true); addRecord.setIsLead(true);
addRecord.setShareRecordId(dto.getShareRecordId()); addRecord.setShareRecordId(shareRecordId);
addRecord.setCreateTime(now); addRecord.setCreateTime(now);
addRecord.setDistributorId(dto.getDistributorId()); addRecord.setDistributorId(distributorShareRecord.getDistributorId());
addRecord.setItemId(itemId); addRecord.setItemId(itemId);
addRecord.setPrice(price); addRecord.setPrice(price);
addRecord.setUserId(dto.getUserId()); addRecord.setUserId(dto.getUserId());
addRecord.setUserOpenId(dto.getUserOpenId());
auctionRecordDao.insert(addRecord); auctionRecordDao.insert(addRecord);
//如果当前时间是拍卖截止时间的最后五分钟内,则再延长五分钟 //如果当前时间是拍卖截止时间的最后五分钟内,则再延长五分钟
...@@ -131,6 +132,8 @@ public class AuctionRecordServiceImpl implements AuctionRecordService { ...@@ -131,6 +132,8 @@ public class AuctionRecordServiceImpl implements AuctionRecordService {
public Result findList(AuctionRecordRequestDto dto) { public Result findList(AuctionRecordRequestDto dto) {
try { try {
AuctionRecordVo auctionRecordVo = new AuctionRecordVo(); AuctionRecordVo auctionRecordVo = new AuctionRecordVo();
AuctionRecordRequestDto searchDto = new AuctionRecordRequestDto();
searchDto.setUserId(dto.getUserId());
List<AuctionRecord> auctionRecordList = auctionRecordDao.findByPage(dto); List<AuctionRecord> auctionRecordList = auctionRecordDao.findByPage(dto);
//查询商品竞拍信息 //查询商品竞拍信息
AuctionConfig auctionConfig = auctionConfigDao.findByItemId(dto.getItemId()); AuctionConfig auctionConfig = auctionConfigDao.findByItemId(dto.getItemId());
...@@ -165,30 +168,4 @@ public class AuctionRecordServiceImpl implements AuctionRecordService { ...@@ -165,30 +168,4 @@ public class AuctionRecordServiceImpl implements AuctionRecordService {
return Result.failed(); return Result.failed();
} }
@Override
public Result auctionPay(AuctionRecordRequestDto dto) {
try {
long itemId = dto.getItemId();
SupplierItem supplierItem = supplierItemDao.findById(itemId);
String distributionOrderId = dto.getDistributionOrderId();
DistributionOrder distributionOrder = distributionOrderDao.findById(distributionOrderId);
DistributionOrderRequestDto prePayDto = new DistributionOrderRequestDto();
prePayDto.setDistributionOrderId(distributionOrderId);
prePayDto.setAmount(PriceUtil.convertPriceFenToYuan(distributionOrder.getAmount()));
prePayDto.setBuyerOpenid(distributionOrder.getBuyerOpenid());
prePayDto.setItemName(supplierItem.getName());
Result prePayResult = wxPayServiceApi.createPrepareOrder(prePayDto);
if (!prePayResult.getSuccess()) {
logger.error(">>>>>>>> 订单号: {}, 预下单失败 <<<<<<<<",distributionOrderId );
return Result.failed(ResultCode.PAY_FAILED);
}
String prepayId = (String) prePayResult.getData();
Result getPayParamResult = wxPayServiceApi.wxAppPayTuneUp(prepayId);
return getPayParamResult;
} catch (Exception e) {
logger.error("支付失败 error : {}", e);
}
return Result.failed();
}
} }
...@@ -19,10 +19,4 @@ public interface AuctionRecordService { ...@@ -19,10 +19,4 @@ public interface AuctionRecordService {
*/ */
Result findList(AuctionRecordRequestDto dto); Result findList(AuctionRecordRequestDto dto);
/**
* 中拍支付
* @param dto
* @return
*/
Result auctionPay(AuctionRecordRequestDto dto);
} }
...@@ -21,6 +21,14 @@ public interface DistributionOrderService { ...@@ -21,6 +21,14 @@ public interface DistributionOrderService {
Result createAuctionOrder(DistributionOrderRequestDto dto); Result createAuctionOrder(DistributionOrderRequestDto dto);
/**
* 拍卖订单付款,先调用微信预支付接口,再拿prepay_id获取支付参数返回前端
* @param dto
* @return
*/
Result auctionPay(DistributionOrderRequestDto dto);
/** /**
* 分销商购买样品 * 分销商购买样品
* @param dto * @param dto
......
...@@ -31,7 +31,7 @@ public class AuctionRecordController { ...@@ -31,7 +31,7 @@ public class AuctionRecordController {
@PostMapping("/findList") @PostMapping("/findList")
public Result findList(@RequestBody AuctionRecordRequestDto dto) { public Result findList(@RequestBody AuctionRecordRequestDto dto) {
logger.info("查询出价记录,请求参数:{}", JSON.toJSONString(dto)); logger.info("查询出价记录,请求参数:{}", JSON.toJSONString(dto));
if (dto.getItemId() == null) { if (dto.getItemId() == null || dto.getUserId() == null) {
return Result.failed(ResultCode.PARAM_ERROR); return Result.failed(ResultCode.PARAM_ERROR);
} }
return auctionRecordService.findList(dto); return auctionRecordService.findList(dto);
...@@ -46,6 +46,7 @@ public class AuctionRecordController { ...@@ -46,6 +46,7 @@ public class AuctionRecordController {
validator.set("itemId", "商品id").must().number() validator.set("itemId", "商品id").must().number()
.set("price", "出价").must().string() .set("price", "出价").must().string()
.set("userId", "userId").must().number() .set("userId", "userId").must().number()
.set("userOpenId", "微信openid").must().string()
.set("shareRecordId", "分享id").must().string() .set("shareRecordId", "分享id").must().string()
.end(); .end();
if (!validator.isValid()) { if (!validator.isValid()) {
...@@ -54,22 +55,4 @@ public class AuctionRecordController { ...@@ -54,22 +55,4 @@ public class AuctionRecordController {
return auctionRecordService.createAuctionRecord(dto); return auctionRecordService.createAuctionRecord(dto);
} }
@ApiOperation(value = "中拍支付")
@PostMapping("/auctionPay")
public Result auctionPay(@RequestBody AuctionRecordRequestDto dto) {
logger.info("中拍支付,请求参数:{}", JSON.toJSONString(dto));
Validator validator = new Validator(FormHandler.ofEntity(dto));
validator.set("itemId", "商品id").must().number()
.set("userId", "userId").must().number()
.end();
if (!validator.isValid()) {
return Result.failed(validator.getErrorInfo());
}
return auctionRecordService.auctionPay(dto);
}
} }
...@@ -53,7 +53,6 @@ public class DistributionOrderController { ...@@ -53,7 +53,6 @@ public class DistributionOrderController {
logger.info("拍卖分销单下单,请求参数:{}", JSON.toJSONString(dto)); logger.info("拍卖分销单下单,请求参数:{}", JSON.toJSONString(dto));
Validator validator = new Validator(FormHandler.ofEntity(dto)); Validator validator = new Validator(FormHandler.ofEntity(dto));
validator.set("itemId", "商品id").must().number() validator.set("itemId", "商品id").must().number()
.set("userId", "userId").must().number()
.end(); .end();
if (!validator.isValid()) { if (!validator.isValid()) {
return Result.failed(validator.getErrorInfo()); return Result.failed(validator.getErrorInfo());
...@@ -62,6 +61,21 @@ public class DistributionOrderController { ...@@ -62,6 +61,21 @@ public class DistributionOrderController {
} }
@ApiOperation(value = "拍卖分销单付款,预下单并获取支付参数")
@PostMapping("/auctionPay")
public Result auctionPay(@RequestBody DistributionOrderRequestDto dto) {
logger.info("拍卖分销单付款,请求参数:{}", JSON.toJSONString(dto));
Validator validator = new Validator(FormHandler.ofEntity(dto));
validator.set("distributionOrderId", "分销订单号").must().string()
.end();
if (!validator.isValid()) {
return Result.failed(validator.getErrorInfo());
}
return distributionOrderService.auctionPay(dto);
}
@ApiOperation(value = "分销商购买样品,尚未付款") @ApiOperation(value = "分销商购买样品,尚未付款")
@PostMapping("/buySample") @PostMapping("/buySample")
public Result buySample(@RequestBody DistributionOrderRequestDto dto) { public Result buySample(@RequestBody DistributionOrderRequestDto dto) {
......
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