Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Q
qk_backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
quanku
qk_backend
Commits
84b2f4f7
Commit
84b2f4f7
authored
Mar 05, 2024
by
shiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
出价记录
parent
156af042
Changes
14
Hide whitespace changes
Inline
Side-by-side
Showing
14 changed files
with
340 additions
and
132 deletions
+340
-132
ch-dao/src/main/java/com/wwdz/ch/db/dao/distribution/AuctionRecordDao.java
...ava/com/wwdz/ch/db/dao/distribution/AuctionRecordDao.java
+7
-0
ch-dao/src/main/java/com/wwdz/ch/db/domain/distribution/AuctionRecord.java
...ava/com/wwdz/ch/db/domain/distribution/AuctionRecord.java
+12
-1
ch-dao/src/main/java/com/wwdz/ch/db/domain/distribution/AuctionRecordExample.java
.../wwdz/ch/db/domain/distribution/AuctionRecordExample.java
+142
-0
ch-dao/src/main/java/com/wwdz/ch/db/dto/request/distribution/AuctionRecordRequestDto.java
.../db/dto/request/distribution/AuctionRecordRequestDto.java
+5
-0
ch-dao/src/main/java/com/wwdz/ch/db/impl/distribution/AuctionRecordDaoImpl.java
...om/wwdz/ch/db/impl/distribution/AuctionRecordDaoImpl.java
+6
-0
ch-dao/src/main/java/com/wwdz/ch/db/mapper/distribution/AuctionRecordMapper.java
...m/wwdz/ch/db/mapper/distribution/AuctionRecordMapper.java
+3
-0
ch-dao/src/main/resources/com/wwdz/ch/db/mapper/distribution/AuctionRecordMapper.xml
...om/wwdz/ch/db/mapper/distribution/AuctionRecordMapper.xml
+37
-16
ch-dao/src/main/resources/generatorConfig_new.xml
ch-dao/src/main/resources/generatorConfig_new.xml
+1
-1
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/AuctionRecordServiceImpl.java
...wdz/ch/wx/impl/distribution/AuctionRecordServiceImpl.java
+16
-39
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/DistributionOrderServiceImpl.java
...ch/wx/impl/distribution/DistributionOrderServiceImpl.java
+86
-49
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/distribution/AuctionRecordService.java
...wwdz/ch/wx/service/distribution/AuctionRecordService.java
+0
-6
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/distribution/DistributionOrderService.java
.../ch/wx/service/distribution/DistributionOrderService.java
+8
-0
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/distribution/AuctionRecordController.java
.../wwdz/ch/wx/web/distribution/AuctionRecordController.java
+2
-19
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/distribution/DistributionOrderController.java
...z/ch/wx/web/distribution/DistributionOrderController.java
+15
-1
No files found.
ch-dao/src/main/java/com/wwdz/ch/db/dao/distribution/AuctionRecordDao.java
View file @
84b2f4f7
...
@@ -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
);
}
}
ch-dao/src/main/java/com/wwdz/ch/db/domain/distribution/AuctionRecord.java
View file @
84b2f4f7
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/0
2/29
* @date 2024/0
3/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
),
...
...
ch-dao/src/main/java/com/wwdz/ch/db/domain/distribution/AuctionRecordExample.java
View file @
84b2f4f7
...
@@ -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
;
...
...
ch-dao/src/main/java/com/wwdz/ch/db/dto/request/distribution/AuctionRecordRequestDto.java
View file @
84b2f4f7
...
@@ -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
;
/**
/**
* 出价
* 出价
*/
*/
...
...
ch-dao/src/main/java/com/wwdz/ch/db/impl/distribution/AuctionRecordDaoImpl.java
View file @
84b2f4f7
...
@@ -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
;
}
}
}
ch-dao/src/main/java/com/wwdz/ch/db/mapper/distribution/AuctionRecordMapper.java
View file @
84b2f4f7
...
@@ -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
ch-dao/src/main/resources/com/wwdz/ch/db/mapper/distribution/AuctionRecordMapper.xml
View file @
84b2f4f7
...
@@ -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
>
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
>
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
>
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
ch-dao/src/main/resources/generatorConfig_new.xml
View file @
84b2f4f7
...
@@ -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>
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/AuctionRecordServiceImpl.java
View file @
84b2f4f7
...
@@ -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
(
d
to
.
getDistributorId
());
addRecord
.
setDistributorId
(
d
istributorShareRecord
.
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
();
}
}
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/DistributionOrderServiceImpl.java
View file @
84b2f4f7
...
@@ -23,6 +23,7 @@ import com.wwdz.ch.wx.entity.vo.distribution.DistributionOrderVo;
...
@@ -23,6 +23,7 @@ import com.wwdz.ch.wx.entity.vo.distribution.DistributionOrderVo;
import
com.wwdz.ch.wx.service.distribution.DistributionOrderService
;
import
com.wwdz.ch.wx.service.distribution.DistributionOrderService
;
import
com.wwdz.ch.wx.service.distribution.SendMsgService
;
import
com.wwdz.ch.wx.service.distribution.SendMsgService
;
import
com.xxdxxs.utils.EntityMapper
;
import
com.xxdxxs.utils.EntityMapper
;
import
org.redisson.api.RLock
;
import
org.redisson.api.RedissonClient
;
import
org.redisson.api.RedissonClient
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
...
@@ -36,6 +37,7 @@ import org.springframework.util.StringUtils;
...
@@ -36,6 +37,7 @@ import org.springframework.util.StringUtils;
import
java.time.Duration
;
import
java.time.Duration
;
import
java.time.Instant
;
import
java.time.Instant
;
import
java.util.*
;
import
java.util.*
;
import
java.util.concurrent.TimeUnit
;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
@Service
@Service
...
@@ -49,6 +51,8 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
...
@@ -49,6 +51,8 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
private
final
static
String
SECRET
=
"117eb48AX0864490fbe4d1ef081B9cc25"
;
private
final
static
String
SECRET
=
"117eb48AX0864490fbe4d1ef081B9cc25"
;
private
static
final
String
CREATE_ORDER_KEY_PRE
=
"AUCTION:CREATE:"
;
private
final
static
Long
SYSTEM_ACCOUNT
=
8888888888L
;
private
final
static
Long
SYSTEM_ACCOUNT
=
8888888888L
;
@Autowired
@Autowired
...
@@ -145,6 +149,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
...
@@ -145,6 +149,7 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
distributionOrder
.
setReceiverPhone
(
dto
.
getReceiverPhone
());
distributionOrder
.
setReceiverPhone
(
dto
.
getReceiverPhone
());
distributionOrder
.
setCreateTime
(
new
Date
());
distributionOrder
.
setCreateTime
(
new
Date
());
distributionOrder
.
setUpdateTime
(
new
Date
());
distributionOrder
.
setUpdateTime
(
new
Date
());
distributionOrder
.
setType
(
DistributionEnum
.
DistributionTypeEnum
.
FIXED_PRICE
.
getCode
());
distributionOrder
.
setState
(
DistributionEnum
.
DistributionOrderStateEnum
.
PRE_PAY
.
getCode
());
distributionOrder
.
setState
(
DistributionEnum
.
DistributionOrderStateEnum
.
PRE_PAY
.
getCode
());
distributionOrderDao
.
insert
(
distributionOrder
);
distributionOrderDao
.
insert
(
distributionOrder
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
Map
<
String
,
String
>
map
=
new
HashMap
<>();
...
@@ -176,68 +181,100 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
...
@@ -176,68 +181,100 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
@Override
@Override
@Transactional
public
Result
createAuctionOrder
(
DistributionOrderRequestDto
dto
)
{
public
Result
createAuctionOrder
(
DistributionOrderRequestDto
dto
)
{
String
itemIdKey
=
CREATE_ORDER_KEY_PRE
+
dto
.
getItemId
();
RLock
lock
=
redissonClient
.
getLock
(
itemIdKey
);
try
{
try
{
String
distributionOrderId
=
IdUtils
.
getOrderNumber
(
DISTRIBUTION_ORDER_PREFIX
);
if
(
lock
.
tryLock
(
5
,
5
,
TimeUnit
.
SECONDS
))
{
AuctionRecord
auctionRecord
=
auctionRecordDao
.
findLastedRecord
(
dto
.
getItemId
());
String
distributionOrderId
=
IdUtils
.
getOrderNumber
(
DISTRIBUTION_ORDER_PREFIX
);
if
(
auctionRecord
.
getUserId
().
longValue
()
!=
dto
.
getBuyerId
().
longValue
())
{
AuctionRecord
auctionRecord
=
auctionRecordDao
.
findLastedRecord
(
dto
.
getItemId
());
return
Result
.
failed
(
"下单信息错误"
);
if
(
auctionRecord
.
getUserId
().
longValue
()
!=
dto
.
getBuyerId
().
longValue
())
{
return
Result
.
failed
(
"下单信息错误"
);
}
String
shareRecordId
=
auctionRecord
.
getShareRecordId
();
DistributorShareRecord
distributorShareRecord
=
distributorShareRecordDao
.
findById
(
shareRecordId
);
SupplierItem
supplierItem
=
supplierItemDao
.
findById
(
dto
.
getItemId
());
DistributionOrder
distributionOrder
=
new
DistributionOrder
();
distributionOrder
.
setItemId
(
dto
.
getItemId
());
distributionOrder
.
setItemNum
(
1
);
distributionOrder
.
setShareRecordId
(
shareRecordId
);
distributionOrder
.
setDistributionOrderId
(
distributionOrderId
);
distributionOrder
.
setBuyerId
(
auctionRecord
.
getUserId
());
distributionOrder
.
setBuyerOpenid
(
auctionRecord
.
getUserOpenId
());
distributionOrder
.
setShopId
(
distributorShareRecord
.
getShopId
());
distributionOrder
.
setSellerId
(
distributorShareRecord
.
getDistributorId
());
distributionOrder
.
setAmount
(
PriceUtil
.
convertPriceFromStr
(
dto
.
getAmount
()));
distributionOrder
.
setCreateTime
(
new
Date
());
distributionOrder
.
setUpdateTime
(
new
Date
());
distributionOrder
.
setState
(
DistributionEnum
.
DistributionOrderStateEnum
.
PRE_PAY
.
getCode
());
distributionOrder
.
setType
(
DistributionEnum
.
DistributionTypeEnum
.
AUCTION
.
getCode
());
distributionOrderDao
.
insert
(
distributionOrder
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"distributionOrderId"
,
distributionOrderId
);
map
.
put
(
"prepayId"
,
null
);
//计算分销商的利润
DistributorProfit
distributorProfit
=
new
DistributorProfit
();
//利润,该记录在用户未付款时未无效,仅用于在分销商查看订单详情时,计算预计利润
Double
profit
=
distributionOrder
.
getAmount
().
doubleValue
()
*
0.03
;
distributorProfit
.
setDistributionOrderId
(
distributionOrderId
);
distributorProfit
.
setDistributorId
(
distributionOrder
.
getSellerId
());
distributorProfit
.
setItemId
(
distributionOrder
.
getItemId
());
distributorProfit
.
setItemNum
(
distributionOrder
.
getItemNum
());
distributorProfit
.
setAmount
(
distributionOrder
.
getAmount
());
distributorProfit
.
setItemCost
(
supplierItem
.
getDistributionPrice
());
distributorProfit
.
setProfit
((
long
)
Math
.
floor
(
profit
));
distributorProfit
.
setCreateTime
(
new
Date
());
distributorProfit
.
setIsValid
(
false
);
distributorProfitDao
.
insert
(
distributorProfit
);
return
Result
.
success
(
map
);
}
else
{
return
Result
.
failed
(
"创建订单失败,稍后再试"
);
}
}
SupplierItem
supplierItem
=
supplierItemDao
.
findById
(
dto
.
getItemId
());
}
catch
(
Exception
e
)
{
logger
.
error
(
"创建拍卖分销订单失败 error : {}"
,
e
);
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
}
finally
{
if
(
lock
!=
null
&&
lock
.
isHeldByCurrentThread
())
{
lock
.
unlock
();
}
}
return
Result
.
failed
(
"拍卖分销订单下单失败"
);
}
@Override
public
Result
auctionPay
(
DistributionOrderRequestDto
dto
)
{
try
{
String
distributionOrderId
=
dto
.
getDistributionOrderId
();
DistributionOrder
distributionOrder
=
distributionOrderDao
.
findById
(
distributionOrderId
);
SupplierItem
supplierItem
=
supplierItemDao
.
findById
(
distributionOrder
.
getItemId
());
DistributionOrderRequestDto
prePayDto
=
new
DistributionOrderRequestDto
();
DistributionOrderRequestDto
prePayDto
=
new
DistributionOrderRequestDto
();
prePayDto
.
setDistributionOrderId
(
distributionOrderId
);
prePayDto
.
setDistributionOrderId
(
distributionOrderId
);
prePayDto
.
setAmount
(
d
to
.
getAmount
());
prePayDto
.
setAmount
(
d
istributionOrder
.
getAmount
().
toString
());
prePayDto
.
setBuyerOpenid
(
d
to
.
getBuyerOpenid
());
prePayDto
.
setBuyerOpenid
(
d
istributionOrder
.
getBuyerOpenid
());
prePayDto
.
setItemName
(
supplierItem
.
getName
());
prePayDto
.
setItemName
(
supplierItem
.
getName
());
Result
prePayResult
=
wxPayServiceApi
.
createPrepareOrder
(
prePayDto
);
Result
prePayResult
=
wxPayServiceApi
.
createPrepareOrder
(
prePayDto
);
if
(!
prePayResult
.
getSuccess
())
{
if
(!
prePayResult
.
getSuccess
())
{
logger
.
error
(
">>>>>>>> 订单号: {}, 预下单失败 <<<<<<<<"
,
distributionOrderId
);
logger
.
error
(
">>>>>>>> 订单号: {}, 预下单失败 <<<<<<<<"
,
distributionOrderId
);
return
Result
.
failed
(
ResultCode
.
PAY_FAILED
);
return
Result
.
failed
(
ResultCode
.
PAY_FAILED
);
}
}
String
prepayId
=
(
String
)
prePayResult
.
getData
();
String
prepayId
=
(
String
)
prePayResult
.
getData
();
String
shareRecordId
=
auctionRecord
.
getShareRecordId
();
Result
result
=
wxPayServiceApi
.
wxAppPayTuneUp
(
prepayId
);
DistributionOrder
distributionOrder
=
new
DistributionOrder
();
//保存用户收货地址,每次都要获取新的prepayid,并且要更新表中的数据
distributionOrder
.
setItemId
(
dto
.
getItemId
());
DistributionOrder
updateOrder
=
new
DistributionOrder
();
distributionOrder
.
setItemNum
(
1
);
updateOrder
.
setDistributionOrderId
(
distributionOrderId
);
distributionOrder
.
setPrepayId
(
prepayId
);
updateOrder
.
setPrepayId
(
prepayId
);
distributionOrder
.
setShareRecordId
(
shareRecordId
);
updateOrder
.
setAddressId
(
dto
.
getAddressId
());
distributionOrder
.
setDistributionOrderId
(
distributionOrderId
);
updateOrder
.
setReceiverAddress
(
dto
.
getReceiverAddress
());
distributionOrder
.
setBuyerId
(
dto
.
getBuyerId
());
updateOrder
.
setReceiverName
(
dto
.
getReceiverName
());
distributionOrder
.
setBuyerOpenid
(
dto
.
getBuyerOpenid
());
updateOrder
.
setReceiverPhone
(
dto
.
getReceiverPhone
());
distributionOrder
.
setShopId
(
dto
.
getShopId
());
distributionOrderDao
.
update
(
updateOrder
);
distributionOrder
.
setSellerId
(
dto
.
getSellerId
());
return
result
;
distributionOrder
.
setAmount
(
PriceUtil
.
convertPriceFromStr
(
dto
.
getAmount
()));
}
catch
(
Exception
e
)
{
distributionOrder
.
setAddressId
(
dto
.
getAddressId
());
logger
.
error
(
"拍卖订单付款失败 error : {}"
,
e
);
distributionOrder
.
setReceiverAddress
(
dto
.
getReceiverAddress
());
distributionOrder
.
setReceiverName
(
dto
.
getReceiverName
());
distributionOrder
.
setReceiverPhone
(
dto
.
getReceiverPhone
());
distributionOrder
.
setCreateTime
(
new
Date
());
distributionOrder
.
setUpdateTime
(
new
Date
());
distributionOrder
.
setState
(
DistributionEnum
.
DistributionOrderStateEnum
.
PRE_PAY
.
getCode
());
distributionOrderDao
.
insert
(
distributionOrder
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"distributionOrderId"
,
distributionOrderId
);
map
.
put
(
"prepayId"
,
prepayId
);
//计算分销商的利润
DistributorProfit
distributorProfit
=
new
DistributorProfit
();
//利润,该记录在用户未付款时未无效,仅用于在分销商查看订单详情时,计算预计利润
Double
profit
=
distributionOrder
.
getAmount
().
doubleValue
()
*
0.03
;
distributorProfit
.
setDistributionOrderId
(
distributionOrderId
);
distributorProfit
.
setDistributorId
(
distributionOrder
.
getSellerId
());
distributorProfit
.
setItemId
(
distributionOrder
.
getItemId
());
distributorProfit
.
setItemNum
(
distributionOrder
.
getItemNum
());
distributorProfit
.
setAmount
(
distributionOrder
.
getAmount
());
distributorProfit
.
setItemCost
(
supplierItem
.
getDistributionPrice
());
distributorProfit
.
setProfit
((
long
)
Math
.
floor
(
profit
));
distributorProfit
.
setCreateTime
(
new
Date
());
distributorProfit
.
setIsValid
(
false
);
distributorProfitDao
.
insert
(
distributorProfit
);
return
Result
.
success
(
map
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"创建拍卖分销订单失败 error : {}"
,
e
);
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
}
}
return
Result
.
failed
(
"拍卖
分销订单下单
失败"
);
return
Result
.
failed
(
"拍卖
订单付款
失败"
);
}
}
@Override
@Override
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/distribution/AuctionRecordService.java
View file @
84b2f4f7
...
@@ -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
);
}
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/service/distribution/DistributionOrderService.java
View file @
84b2f4f7
...
@@ -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
...
...
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/distribution/AuctionRecordController.java
View file @
84b2f4f7
...
@@ -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
);
}
}
}
ch-wx-api/src/main/java/com/wwdz/ch/wx/web/distribution/DistributionOrderController.java
View file @
84b2f4f7
...
@@ -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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment