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
055a150d
Commit
055a150d
authored
Feb 19, 2024
by
shiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
限购
parent
458d6bd5
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
192 additions
and
12 deletions
+192
-12
ch-dao/src/main/java/com/wwdz/ch/db/domain/distribution/SupplierItem.java
...java/com/wwdz/ch/db/domain/distribution/SupplierItem.java
+12
-1
ch-dao/src/main/java/com/wwdz/ch/db/domain/distribution/SupplierItemExample.java
...m/wwdz/ch/db/domain/distribution/SupplierItemExample.java
+132
-0
ch-dao/src/main/resources/com/wwdz/ch/db/mapper/distribution/SupplierItemMapper.xml
...com/wwdz/ch/db/mapper/distribution/SupplierItemMapper.xml
+32
-11
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/DistributionOrderServiceImpl.java
...ch/wx/impl/distribution/DistributionOrderServiceImpl.java
+16
-0
No files found.
ch-dao/src/main/java/com/wwdz/ch/db/domain/distribution/SupplierItem.java
View file @
055a150d
package
com.wwdz.ch.db.domain.distribution
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
com.xxdxxs.entity.Entity
;
import
lombok.Data
;
/**
* @author shiyu
* @date 2024/0
1/24
* @date 2024/0
2/19
*/
@Data
public
class
SupplierItem
implements
Entity
{
...
...
@@ -69,6 +71,11 @@ public class SupplierItem implements Entity {
*/
private
Boolean
isDeleted
;
/**
* 限购数量
*/
private
Integer
buyLimitNum
;
/**
* 商品图片,分号分隔
*/
...
...
@@ -104,6 +111,7 @@ public class SupplierItem implements Entity {
sb
.
append
(
", createTime="
).
append
(
createTime
);
sb
.
append
(
", updateTime="
).
append
(
updateTime
);
sb
.
append
(
", isDeleted="
).
append
(
isDeleted
);
sb
.
append
(
", buyLimitNum="
).
append
(
buyLimitNum
);
sb
.
append
(
", images="
).
append
(
images
);
sb
.
append
(
", videos="
).
append
(
videos
);
sb
.
append
(
", description="
).
append
(
description
);
...
...
@@ -136,6 +144,7 @@ public class SupplierItem implements Entity {
&&
(
this
.
getCreateTime
()
==
null
?
other
.
getCreateTime
()
==
null
:
this
.
getCreateTime
().
equals
(
other
.
getCreateTime
()))
&&
(
this
.
getUpdateTime
()
==
null
?
other
.
getUpdateTime
()
==
null
:
this
.
getUpdateTime
().
equals
(
other
.
getUpdateTime
()))
&&
(
this
.
getIsDeleted
()
==
null
?
other
.
getIsDeleted
()
==
null
:
this
.
getIsDeleted
().
equals
(
other
.
getIsDeleted
()))
&&
(
this
.
getBuyLimitNum
()
==
null
?
other
.
getBuyLimitNum
()
==
null
:
this
.
getBuyLimitNum
().
equals
(
other
.
getBuyLimitNum
()))
&&
(
this
.
getImages
()
==
null
?
other
.
getImages
()
==
null
:
this
.
getImages
().
equals
(
other
.
getImages
()))
&&
(
this
.
getVideos
()
==
null
?
other
.
getVideos
()
==
null
:
this
.
getVideos
().
equals
(
other
.
getVideos
()))
&&
(
this
.
getDescription
()
==
null
?
other
.
getDescription
()
==
null
:
this
.
getDescription
().
equals
(
other
.
getDescription
()));
...
...
@@ -157,6 +166,7 @@ public class SupplierItem implements Entity {
result
=
prime
*
result
+
((
getCreateTime
()
==
null
)
?
0
:
getCreateTime
().
hashCode
());
result
=
prime
*
result
+
((
getUpdateTime
()
==
null
)
?
0
:
getUpdateTime
().
hashCode
());
result
=
prime
*
result
+
((
getIsDeleted
()
==
null
)
?
0
:
getIsDeleted
().
hashCode
());
result
=
prime
*
result
+
((
getBuyLimitNum
()
==
null
)
?
0
:
getBuyLimitNum
().
hashCode
());
result
=
prime
*
result
+
((
getImages
()
==
null
)
?
0
:
getImages
().
hashCode
());
result
=
prime
*
result
+
((
getVideos
()
==
null
)
?
0
:
getVideos
().
hashCode
());
result
=
prime
*
result
+
((
getDescription
()
==
null
)
?
0
:
getDescription
().
hashCode
());
...
...
@@ -183,6 +193,7 @@ public class SupplierItem implements Entity {
createTime
(
"create_time"
,
"createTime"
,
"TIMESTAMP"
,
false
),
updateTime
(
"update_time"
,
"updateTime"
,
"TIMESTAMP"
,
false
),
isDeleted
(
"is_deleted"
,
"isDeleted"
,
"BIT"
,
false
),
buyLimitNum
(
"buy_limit_num"
,
"buyLimitNum"
,
"INTEGER"
,
false
),
images
(
"images"
,
"images"
,
"LONGVARCHAR"
,
false
),
videos
(
"videos"
,
"videos"
,
"LONGVARCHAR"
,
false
),
description
(
"description"
,
"description"
,
"LONGVARCHAR"
,
false
);
...
...
ch-dao/src/main/java/com/wwdz/ch/db/domain/distribution/SupplierItemExample.java
View file @
055a150d
...
...
@@ -1751,6 +1751,138 @@ public class SupplierItemExample {
addCriterion
(
"is_deleted not between"
,
value1
,
value2
,
"isDeleted"
);
return
(
Criteria
)
this
;
}
public
Criteria
andBuyLimitNumIsNull
()
{
addCriterion
(
"buy_limit_num is null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andBuyLimitNumIsNotNull
()
{
addCriterion
(
"buy_limit_num is not null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andBuyLimitNumEqualTo
(
Integer
value
)
{
addCriterion
(
"buy_limit_num ="
,
value
,
"buyLimitNum"
);
return
(
Criteria
)
this
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table supplier_item
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
andBuyLimitNumEqualToColumn
(
SupplierItem
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"buy_limit_num = "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andBuyLimitNumNotEqualTo
(
Integer
value
)
{
addCriterion
(
"buy_limit_num <>"
,
value
,
"buyLimitNum"
);
return
(
Criteria
)
this
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table supplier_item
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
andBuyLimitNumNotEqualToColumn
(
SupplierItem
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"buy_limit_num <> "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andBuyLimitNumGreaterThan
(
Integer
value
)
{
addCriterion
(
"buy_limit_num >"
,
value
,
"buyLimitNum"
);
return
(
Criteria
)
this
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table supplier_item
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
andBuyLimitNumGreaterThanColumn
(
SupplierItem
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"buy_limit_num > "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andBuyLimitNumGreaterThanOrEqualTo
(
Integer
value
)
{
addCriterion
(
"buy_limit_num >="
,
value
,
"buyLimitNum"
);
return
(
Criteria
)
this
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table supplier_item
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
andBuyLimitNumGreaterThanOrEqualToColumn
(
SupplierItem
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"buy_limit_num >= "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andBuyLimitNumLessThan
(
Integer
value
)
{
addCriterion
(
"buy_limit_num <"
,
value
,
"buyLimitNum"
);
return
(
Criteria
)
this
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table supplier_item
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
andBuyLimitNumLessThanColumn
(
SupplierItem
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"buy_limit_num < "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andBuyLimitNumLessThanOrEqualTo
(
Integer
value
)
{
addCriterion
(
"buy_limit_num <="
,
value
,
"buyLimitNum"
);
return
(
Criteria
)
this
;
}
/**
* This method was generated by MyBatis Generator.
* This method corresponds to the database table supplier_item
*
* @mbg.generated
* @project https://github.com/itfsw/mybatis-generator-plugin
*/
public
Criteria
andBuyLimitNumLessThanOrEqualToColumn
(
SupplierItem
.
Column
column
)
{
addCriterion
(
new
StringBuilder
(
"buy_limit_num <= "
).
append
(
column
.
getEscapedColumnName
()).
toString
());
return
(
Criteria
)
this
;
}
public
Criteria
andBuyLimitNumIn
(
List
<
Integer
>
values
)
{
addCriterion
(
"buy_limit_num in"
,
values
,
"buyLimitNum"
);
return
(
Criteria
)
this
;
}
public
Criteria
andBuyLimitNumNotIn
(
List
<
Integer
>
values
)
{
addCriterion
(
"buy_limit_num not in"
,
values
,
"buyLimitNum"
);
return
(
Criteria
)
this
;
}
public
Criteria
andBuyLimitNumBetween
(
Integer
value1
,
Integer
value2
)
{
addCriterion
(
"buy_limit_num between"
,
value1
,
value2
,
"buyLimitNum"
);
return
(
Criteria
)
this
;
}
public
Criteria
andBuyLimitNumNotBetween
(
Integer
value1
,
Integer
value2
)
{
addCriterion
(
"buy_limit_num not between"
,
value1
,
value2
,
"buyLimitNum"
);
return
(
Criteria
)
this
;
}
}
public
static
class
Criteria
extends
GeneratedCriteria
{
...
...
ch-dao/src/main/resources/com/wwdz/ch/db/mapper/distribution/SupplierItemMapper.xml
View file @
055a150d
...
...
@@ -14,6 +14,7 @@
<result
column=
"create_time"
jdbcType=
"TIMESTAMP"
property=
"createTime"
/>
<result
column=
"update_time"
jdbcType=
"TIMESTAMP"
property=
"updateTime"
/>
<result
column=
"is_deleted"
jdbcType=
"BIT"
property=
"isDeleted"
/>
<result
column=
"buy_limit_num"
jdbcType=
"INTEGER"
property=
"buyLimitNum"
/>
</resultMap>
<resultMap
extends=
"BaseResultMap"
id=
"ResultMapWithBLOBs"
type=
"com.wwdz.ch.db.domain.distribution.SupplierItem"
>
<result
column=
"images"
jdbcType=
"LONGVARCHAR"
property=
"images"
/>
...
...
@@ -80,7 +81,7 @@
</sql>
<sql
id=
"Base_Column_List"
>
id, `name`, supplier_id, is_on_sale, sort, top_image, distribution_price, supply_price,
stock, create_time, update_time, is_deleted
stock, create_time, update_time, is_deleted
, buy_limit_num
</sql>
<sql
id=
"Blob_Column_List"
>
images, videos, description
...
...
@@ -136,7 +137,8 @@
</when>
<otherwise>
id, `name`, supplier_id, is_on_sale, sort, top_image, distribution_price, supply_price,
stock, create_time, update_time, is_deleted, images, videos, description
stock, create_time, update_time, is_deleted, buy_limit_num, images, videos, description
</otherwise>
</choose>
from supplier_item
...
...
@@ -170,7 +172,8 @@
</when>
<otherwise>
id, `name`, supplier_id, is_on_sale, sort, top_image, distribution_price, supply_price,
stock, create_time, update_time, is_deleted, images, videos, description
stock, create_time, update_time, is_deleted, buy_limit_num, images, videos, description
</otherwise>
</choose>
from supplier_item
...
...
@@ -193,13 +196,15 @@
insert into supplier_item (`name`, supplier_id, is_on_sale,
sort, top_image, distribution_price,
supply_price, stock, create_time,
update_time, is_deleted, images,
videos, description)
update_time, is_deleted, buy_limit_num,
images, videos, description
)
values (#{name,jdbcType=VARCHAR}, #{supplierId,jdbcType=BIGINT}, #{isOnSale,jdbcType=BIT},
#{sort,jdbcType=INTEGER}, #{topImage,jdbcType=VARCHAR}, #{distributionPrice,jdbcType=BIGINT},
#{supplyPrice,jdbcType=BIGINT}, #{stock,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP},
#{updateTime,jdbcType=TIMESTAMP}, #{isDeleted,jdbcType=BIT}, #{images,jdbcType=LONGVARCHAR},
#{videos,jdbcType=LONGVARCHAR}, #{description,jdbcType=LONGVARCHAR})
#{updateTime,jdbcType=TIMESTAMP}, #{isDeleted,jdbcType=BIT}, #{buyLimitNum,jdbcType=INTEGER},
#{images,jdbcType=LONGVARCHAR}, #{videos,jdbcType=LONGVARCHAR}, #{description,jdbcType=LONGVARCHAR}
)
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.wwdz.ch.db.domain.distribution.SupplierItem"
>
<selectKey
keyProperty=
"id"
order=
"AFTER"
resultType=
"java.lang.Long"
>
...
...
@@ -240,6 +245,9 @@
<if
test=
"isDeleted != null"
>
is_deleted,
</if>
<if
test=
"buyLimitNum != null"
>
buy_limit_num,
</if>
<if
test=
"images != null"
>
images,
</if>
...
...
@@ -284,6 +292,9 @@
<if
test=
"isDeleted != null"
>
#{isDeleted,jdbcType=BIT},
</if>
<if
test=
"buyLimitNum != null"
>
#{buyLimitNum,jdbcType=INTEGER},
</if>
<if
test=
"images != null"
>
#{images,jdbcType=LONGVARCHAR},
</if>
...
...
@@ -340,6 +351,9 @@
<if
test=
"record.isDeleted != null"
>
is_deleted = #{record.isDeleted,jdbcType=BIT},
</if>
<if
test=
"record.buyLimitNum != null"
>
buy_limit_num = #{record.buyLimitNum,jdbcType=INTEGER},
</if>
<if
test=
"record.images != null"
>
images = #{record.images,jdbcType=LONGVARCHAR},
</if>
...
...
@@ -368,6 +382,7 @@
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
is_deleted = #{record.isDeleted,jdbcType=BIT},
buy_limit_num = #{record.buyLimitNum,jdbcType=INTEGER},
images = #{record.images,jdbcType=LONGVARCHAR},
videos = #{record.videos,jdbcType=LONGVARCHAR},
description = #{record.description,jdbcType=LONGVARCHAR}
...
...
@@ -388,7 +403,8 @@
stock = #{record.stock,jdbcType=INTEGER},
create_time = #{record.createTime,jdbcType=TIMESTAMP},
update_time = #{record.updateTime,jdbcType=TIMESTAMP},
is_deleted = #{record.isDeleted,jdbcType=BIT}
is_deleted = #{record.isDeleted,jdbcType=BIT},
buy_limit_num = #{record.buyLimitNum,jdbcType=INTEGER}
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
</if>
...
...
@@ -429,6 +445,9 @@
<if
test=
"isDeleted != null"
>
is_deleted = #{isDeleted,jdbcType=BIT},
</if>
<if
test=
"buyLimitNum != null"
>
buy_limit_num = #{buyLimitNum,jdbcType=INTEGER},
</if>
<if
test=
"images != null"
>
images = #{images,jdbcType=LONGVARCHAR},
</if>
...
...
@@ -454,6 +473,7 @@
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
is_deleted = #{isDeleted,jdbcType=BIT},
buy_limit_num = #{buyLimitNum,jdbcType=INTEGER},
images = #{images,jdbcType=LONGVARCHAR},
videos = #{videos,jdbcType=LONGVARCHAR},
description = #{description,jdbcType=LONGVARCHAR}
...
...
@@ -471,7 +491,8 @@
stock = #{stock,jdbcType=INTEGER},
create_time = #{createTime,jdbcType=TIMESTAMP},
update_time = #{updateTime,jdbcType=TIMESTAMP},
is_deleted = #{isDeleted,jdbcType=BIT}
is_deleted = #{isDeleted,jdbcType=BIT},
buy_limit_num = #{buyLimitNum,jdbcType=INTEGER}
where id = #{id,jdbcType=BIGINT}
</update>
<select
id=
"selectOneByExample"
parameterType=
"com.wwdz.ch.db.domain.distribution.SupplierItemExample"
resultMap=
"BaseResultMap"
>
...
...
@@ -528,7 +549,8 @@
</when>
<otherwise>
id, `name`, supplier_id, is_on_sale, sort, top_image, distribution_price, supply_price,
stock, create_time, update_time, is_deleted, images, videos, description
stock, create_time, update_time, is_deleted, buy_limit_num, images, videos, description
</otherwise>
</choose>
from supplier_item
...
...
@@ -540,5 +562,4 @@
</if>
limit 1
</select>
</mapper>
\ No newline at end of file
ch-wx-api/src/main/java/com/wwdz/ch/wx/impl/distribution/DistributionOrderServiceImpl.java
View file @
055a150d
...
...
@@ -77,12 +77,28 @@ public class DistributionOrderServiceImpl implements DistributionOrderService {
if
(
distributorShareRecord
==
null
)
{
return
Result
.
failed
(
"该分享链接无效"
);
}
if
(!
distributorShareRecord
.
getEnabled
())
{
return
Result
.
failed
(
"该分享链接已失效"
);
}
//查询商品信息,检查商品库存
SupplierItem
supplierItem
=
supplierItemDao
.
findById
(
distributorShareRecord
.
getItemId
());
int
stock
=
supplierItem
.
getStock
();
if
(
stock
<=
0
)
{
return
Result
.
failed
(
"商品库存不足"
);
}
//商品限购数量
int
buyLimitNum
=
supplierItem
.
getBuyLimitNum
()
==
null
?
5
:
supplierItem
.
getBuyLimitNum
();
//检查该购买者是否超出限购数量
//1.查询购买者对该商品的历史购买记录
List
<
DistributionOrder
>
distributionOrders
=
distributionOrderDao
.
findByBuyerId
(
dto
.
getBuyerId
());
int
buyNum
=
0
;
if
(!
CollectionUtils
.
isEmpty
(
distributionOrders
))
{
buyNum
=
distributionOrders
.
stream
().
mapToInt
(
DistributionOrder:
:
getItemNum
).
sum
();
}
if
(
buyNum
+
dto
.
getItemNum
()
>
buyLimitNum
)
{
return
Result
.
failed
(
"超出购买上限,不能下单"
);
}
String
distributionOrderId
=
IdUtils
.
getOrderNumber
(
DISTRIBUTION_ORDER_PREFIX
);
DistributionOrderRequestDto
prePayDto
=
new
DistributionOrderRequestDto
();
prePayDto
.
setDistributionOrderId
(
distributionOrderId
);
...
...
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