Toggle navigation
Toggle navigation
This project
Loading...
Sign in
jiujian
/
client-customer-order-service
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
zhuyifan
2025-02-28 14:28:14 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
877407e8dd0f08aa1862d695c3d59ac0c5474204
877407e8
1 parent
0e685719
feat(ClientCustomerOrderService): 添加 SKU 菜品库存相关 RPC接口
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
308 additions
and
5 deletions
src/main/java/com/tianting/infoloop/mapper/SkuSellQuantityMapper.java
src/main/java/com/tianting/infoloop/model/db/SkuSellQuantity.java
src/main/java/com/tianting/infoloop/service/SkuSellQuantityService.java
src/main/java/com/tianting/infoloop/service/grpc/OrderGrpcService.java
src/main/java/com/tianting/infoloop/service/impl/SkuSellQuantityServiceImpl.java
src/main/proto/ClientCustomerOrderService.proto
src/main/resources/mapper/SkuSellQuantityMapper.xml
src/main/java/com/tianting/infoloop/mapper/SkuSellQuantityMapper.java
0 → 100644
View file @
877407e
package
com
.
tianting
.
infoloop
.
mapper
;
import
com.tianting.infoloop.inject.MyBaseMapper
;
import
com.tianting.infoloop.model.db.SkuSellQuantity
;
/**
* @author zhuyf
* @description 针对表【sku_sell_quantities(sku售卖量)】的数据库操作Mapper
* @createDate 2025-02-28 14:03:59
* @Entity com.tianting.infoloop.model.db.SkuSellQuantity
*/
public
interface
SkuSellQuantityMapper
extends
MyBaseMapper
<
SkuSellQuantity
>
{
}
src/main/java/com/tianting/infoloop/model/db/SkuSellQuantity.java
0 → 100644
View file @
877407e
package
com
.
tianting
.
infoloop
.
model
.
db
;
import
com.baomidou.mybatisplus.annotation.FieldFill
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableLogic
;
import
com.baomidou.mybatisplus.annotation.TableName
;
import
com.baomidou.mybatisplus.extension.activerecord.Model
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
import
lombok.experimental.Accessors
;
import
java.io.Serializable
;
import
java.time.LocalDateTime
;
/**
* sku售卖量
* @TableName sku_sell_quantities
*/
@EqualsAndHashCode
(
callSuper
=
true
)
@Data
@Accessors
(
chain
=
true
)
@TableName
(
value
=
"sku_sell_quantities"
)
public
class
SkuSellQuantity
extends
Model
<
OrderDetailDb
>
implements
Serializable
{
@TableId
(
type
=
IdType
.
AUTO
)
private
Integer
id
;
/**
*
*/
private
Integer
enterpriseId
;
/**
*
*/
private
Integer
stallId
;
/**
* 商品ID
*/
private
Integer
skuId
;
/**
* 最大可售量
*/
private
Integer
maxSellQuantity
;
/**
* 今日已售量
*/
private
Integer
todaySellQuantity
;
/**
*
*/
private
Integer
createdBy
;
@TableField
(
fill
=
FieldFill
.
INSERT
)
private
LocalDateTime
createdAt
;
/**
*
*/
private
Integer
creationSource
;
/**
*
*/
private
Integer
updatedBy
;
@TableField
(
fill
=
FieldFill
.
INSERT_UPDATE
)
private
LocalDateTime
updatedAt
;
/**
*
*/
private
Integer
updateSource
;
@TableLogic
private
Integer
isDeleted
;
}
\ No newline at end of file
src/main/java/com/tianting/infoloop/service/SkuSellQuantityService.java
0 → 100644
View file @
877407e
package
com
.
tianting
.
infoloop
.
service
;
import
com.baomidou.mybatisplus.extension.service.IService
;
import
com.tianting.infoloop.model.db.SkuSellQuantity
;
/**
* @author zhuyf
* @description 针对表【sku_sell_quantities(sku售卖量)】的数据库操作Service
* @createDate 2025-02-28 14:03:59
*/
public
interface
SkuSellQuantityService
extends
IService
<
SkuSellQuantity
>
{
}
src/main/java/com/tianting/infoloop/service/grpc/OrderGrpcService.java
View file @
877407e
...
...
@@ -13,6 +13,8 @@ import com.infoloop.tianting.clientcustomerorderservice.BatchCreateClientCustome
import
com.infoloop.tianting.clientcustomerorderservice.BatchCreateClientCustomerOrdersRpcResponse
;
import
com.infoloop.tianting.clientcustomerorderservice.BatchCreateOrderOperationRecordsRequest
;
import
com.infoloop.tianting.clientcustomerorderservice.BatchCreateOrderOperationRecordsResponse
;
import
com.infoloop.tianting.clientcustomerorderservice.BatchSaveSkuSellQuantitiesRpcRequest
;
import
com.infoloop.tianting.clientcustomerorderservice.BatchSaveSkuSellQuantitiesRpcResponse
;
import
com.infoloop.tianting.clientcustomerorderservice.BatchUpdateClientCustomerOrderDetailsRpcRequest
;
import
com.infoloop.tianting.clientcustomerorderservice.BatchUpdateClientCustomerOrderDetailsRpcResponse
;
import
com.infoloop.tianting.clientcustomerorderservice.BatchUpdateClientCustomerOrdersRpcRequest
;
...
...
@@ -42,13 +44,18 @@ import com.infoloop.tianting.clientcustomerorderservice.GetOrderOperationRecords
import
com.infoloop.tianting.clientcustomerorderservice.GetOrderOperationRecordsByOrderIdResponse
;
import
com.infoloop.tianting.clientcustomerorderservice.OrderCountByStatus
;
import
com.infoloop.tianting.clientcustomerorderservice.OrderOperationRecord
;
import
com.infoloop.tianting.clientcustomerorderservice.OrderSourceEnum
;
import
com.infoloop.tianting.clientcustomerorderservice.OrderStatusEnum
;
import
com.infoloop.tianting.clientcustomerorderservice.QueryClientCustomerOrdersByConditionRpcRequest
;
import
com.infoloop.tianting.clientcustomerorderservice.QueryClientCustomerOrdersByConditionRpcResponse
;
import
com.infoloop.tianting.clientcustomerorderservice.QueryClientCustomerOrdersByPaginationRpcRequest
;
import
com.infoloop.tianting.clientcustomerorderservice.QueryClientCustomerOrdersByPaginationRpcResponse
;
import
com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderDetailRpcResponse
;
import
com.infoloop.tianting.clientcustomerorderservice.SingleClientCustomerOrderRpcResponse
;
import
com.infoloop.tianting.clientcustomerorderservice.QuerySkuSellQuantitiesByStallAndSkuIdsRpcRequest
;
import
com.infoloop.tianting.clientcustomerorderservice.QuerySkuSellQuantitiesByStallAndSkuIdsRpcResponse
;
import
com.infoloop.tianting.clientcustomerorderservice.QuerySkuSellQuantitiesByStallRpcRequest
;
import
com.infoloop.tianting.clientcustomerorderservice.QuerySkuSellQuantitiesByStallRpcResponse
;
import
com.infoloop.tianting.clientcustomerorderservice.SingleSkuSellQuantityRpcResponse
;
import
com.infoloop.tianting.clientcustomerorderservice.SkuSellQuantityModification
;
import
com.infoloop.tianting.clientcustomerorderservice.UpdateClientCustomerOrderDetailRpcRequest
;
import
com.infoloop.tianting.clientcustomerorderservice.UpdateClientCustomerOrderDetailRpcResponse
;
import
com.infoloop.tianting.clientcustomerorderservice.UpdateClientCustomerOrderRpcRequest
;
...
...
@@ -56,9 +63,11 @@ import com.infoloop.tianting.clientcustomerorderservice.UpdateClientCustomerOrde
import
com.tianting.infoloop.model.db.OrderDb
;
import
com.tianting.infoloop.model.db.OrderDetailDb
;
import
com.tianting.infoloop.model.db.OrderOperationRecordDb
;
import
com.tianting.infoloop.model.db.SkuSellQuantity
;
import
com.tianting.infoloop.service.OrderDbService
;
import
com.tianting.infoloop.service.OrderDetailDbService
;
import
com.tianting.infoloop.service.OrderOperationRecordDbService
;
import
com.tianting.infoloop.service.SkuSellQuantityService
;
import
com.tianting.infoloop.utils.DbToProtoUtil
;
import
com.tianting.infoloop.utils.ProtoBeanUtil
;
import
io.grpc.Status
;
...
...
@@ -68,9 +77,12 @@ import lombok.extern.slf4j.Slf4j;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
static
com
.
tianting
.
infoloop
.
constants
.
ConfigConstants
.
DATA_SOURCE_MASTER
;
import
static
com
.
tianting
.
infoloop
.
constants
.
ConfigConstants
.
DATA_SOURCE_SLAVE
;
@Slf4j
@Service
...
...
@@ -79,6 +91,7 @@ public class OrderGrpcService extends ClientCustomerOrderServiceRpcGrpc.ClientCu
private
final
OrderDbService
orderDbService
;
private
final
OrderDetailDbService
orderDetailDbService
;
private
final
OrderOperationRecordDbService
orderOperationRecordDbService
;
private
final
SkuSellQuantityService
skuSellQuantityService
;
@Override
@DS
(
DATA_SOURCE_MASTER
)
...
...
@@ -203,7 +216,7 @@ public class OrderGrpcService extends ClientCustomerOrderServiceRpcGrpc.ClientCu
int
preparingCount
=
0
;
int
allServedCount
=
0
;
int
canceledCount
=
0
;
for
(
OrderStatusEnum
status
:
OrderStatusEnum
.
values
())
{
for
(
OrderStatusEnum
status
:
OrderStatusEnum
.
values
())
{
LambdaQueryWrapper
<
OrderDb
>
queryCountWrapper
=
Wrappers
.
lambdaQuery
();
if
(!
request
.
getKeyword
().
isEmpty
())
{
queryCountWrapper
.
like
(
OrderDb:
:
getMealTime
,
request
.
getKeyword
());
...
...
@@ -627,8 +640,7 @@ public class OrderGrpcService extends ClientCustomerOrderServiceRpcGrpc.ClientCu
@DS
(
DATA_SOURCE_MASTER
)
public
void
batchCreateOrderOperationRecords
(
final
BatchCreateOrderOperationRecordsRequest
request
,
final
StreamObserver
<
BatchCreateOrderOperationRecordsResponse
>
responseStreamObserver
)
{
final
StreamObserver
<
BatchCreateOrderOperationRecordsResponse
>
responseStreamObserver
)
{
final
var
builder
=
BatchCreateOrderOperationRecordsResponse
.
newBuilder
();
try
{
final
var
data
=
orderOperationRecordDbService
.
batchCreateOrderOperationRecords
(
request
);
...
...
@@ -641,4 +653,74 @@ public class OrderGrpcService extends ClientCustomerOrderServiceRpcGrpc.ClientCu
responseStreamObserver
.
onNext
(
builder
.
build
());
responseStreamObserver
.
onCompleted
();
}
@Override
@DS
(
DATA_SOURCE_SLAVE
)
public
void
querySkuSellQuantitiesByStall
(
final
QuerySkuSellQuantitiesByStallRpcRequest
request
,
final
StreamObserver
<
QuerySkuSellQuantitiesByStallRpcResponse
>
responseStreamObserver
)
{
final
var
builder
=
QuerySkuSellQuantitiesByStallRpcResponse
.
newBuilder
();
try
{
LambdaQueryWrapper
<
SkuSellQuantity
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
SkuSellQuantity:
:
getEnterpriseId
,
request
.
getEnterpriseId
());
queryWrapper
.
eq
(
SkuSellQuantity:
:
getStallId
,
request
.
getStallId
());
final
var
list
=
skuSellQuantityService
.
list
(
queryWrapper
);
builder
.
addAllResponses
(
ProtoBeanUtil
.
beanListToProtoList
(
list
,
SingleSkuSellQuantityRpcResponse
.
class
));
}
catch
(
final
Exception
e
)
{
log
.
error
(
"querySkuSellQuantitiesByStall error;"
,
e
);
responseStreamObserver
.
onError
(
Status
.
INTERNAL
.
withDescription
(
e
.
getMessage
()).
asException
());
}
responseStreamObserver
.
onNext
(
builder
.
build
());
responseStreamObserver
.
onCompleted
();
}
@Override
@DS
(
DATA_SOURCE_SLAVE
)
public
void
querySkuSellQuantitiesByStallAndSkuIds
(
final
QuerySkuSellQuantitiesByStallAndSkuIdsRpcRequest
request
,
final
StreamObserver
<
QuerySkuSellQuantitiesByStallAndSkuIdsRpcResponse
>
responseStreamObserver
)
{
final
var
builder
=
QuerySkuSellQuantitiesByStallAndSkuIdsRpcResponse
.
newBuilder
();
try
{
LambdaQueryWrapper
<
SkuSellQuantity
>
queryWrapper
=
new
LambdaQueryWrapper
<>();
queryWrapper
.
eq
(
SkuSellQuantity:
:
getEnterpriseId
,
request
.
getEnterpriseId
());
queryWrapper
.
eq
(
SkuSellQuantity:
:
getStallId
,
request
.
getStallId
());
queryWrapper
.
in
(
SkuSellQuantity:
:
getSkuId
,
request
.
getSkuIdsList
());
final
var
list
=
skuSellQuantityService
.
list
(
queryWrapper
);
builder
.
addAllResponses
(
ProtoBeanUtil
.
beanListToProtoList
(
list
,
SingleSkuSellQuantityRpcResponse
.
class
));
}
catch
(
final
Exception
e
)
{
log
.
error
(
"querySkuSellQuantitiesByStallAndSkuIds error;"
,
e
);
responseStreamObserver
.
onError
(
Status
.
INTERNAL
.
withDescription
(
e
.
getMessage
()).
asException
());
}
responseStreamObserver
.
onNext
(
builder
.
build
());
responseStreamObserver
.
onCompleted
();
}
@Override
@DS
(
DATA_SOURCE_MASTER
)
public
void
batchSaveSkuSellQuantities
(
final
BatchSaveSkuSellQuantitiesRpcRequest
request
,
final
StreamObserver
<
BatchSaveSkuSellQuantitiesRpcResponse
>
responseStreamObserver
)
{
final
var
builder
=
BatchSaveSkuSellQuantitiesRpcResponse
.
newBuilder
();
try
{
List
<
SkuSellQuantity
>
skuSellQuantities
=
new
ArrayList
<>();
for
(
SkuSellQuantityModification
skuSellQuantityModification
:
request
.
getSkuSellQuantityModificationsList
())
{
SkuSellQuantity
skuSellQuantity
=
new
SkuSellQuantity
();
skuSellQuantity
.
setId
(
skuSellQuantityModification
.
getId
()
==
0
?
null
:
skuSellQuantityModification
.
getId
());
skuSellQuantity
.
setEnterpriseId
(
request
.
getEnterpriseId
());
skuSellQuantity
.
setStallId
(
skuSellQuantityModification
.
getStallId
());
skuSellQuantity
.
setSkuId
(
skuSellQuantityModification
.
getSkuId
());
skuSellQuantity
.
setMaxSellQuantity
(
skuSellQuantityModification
.
getMaxSellQuantity
());
skuSellQuantity
.
setCreatedBy
(
request
.
getUpdatedBy
());
skuSellQuantity
.
setCreationSource
(
OrderSourceEnum
.
STALL_VALUE
);
skuSellQuantity
.
setUpdatedBy
(
request
.
getUpdatedBy
());
skuSellQuantity
.
setUpdateSource
(
OrderSourceEnum
.
STALL_VALUE
);
skuSellQuantities
.
add
(
skuSellQuantity
);
}
final
boolean
saveOrUpdateBatch
=
skuSellQuantityService
.
saveOrUpdateBatch
(
skuSellQuantities
);
builder
.
setIsSaved
(
saveOrUpdateBatch
);
}
catch
(
final
Exception
e
)
{
log
.
error
(
"batchSaveSkuSellQuantities error;"
,
e
);
responseStreamObserver
.
onError
(
Status
.
INTERNAL
.
withDescription
(
e
.
getMessage
()).
asException
());
}
responseStreamObserver
.
onNext
(
builder
.
build
());
responseStreamObserver
.
onCompleted
();
}
}
...
...
src/main/java/com/tianting/infoloop/service/impl/SkuSellQuantityServiceImpl.java
0 → 100644
View file @
877407e
package
com
.
tianting
.
infoloop
.
service
.
impl
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
com.tianting.infoloop.mapper.SkuSellQuantityMapper
;
import
com.tianting.infoloop.model.db.SkuSellQuantity
;
import
com.tianting.infoloop.service.SkuSellQuantityService
;
import
org.springframework.stereotype.Service
;
/**
* @author zhuyf
* @description 针对表【sku_sell_quantities(sku售卖量)】的数据库操作Service实现
* @createDate 2025-02-28 14:03:59
*/
@Service
public
class
SkuSellQuantityServiceImpl
extends
ServiceImpl
<
SkuSellQuantityMapper
,
SkuSellQuantity
>
implements
SkuSellQuantityService
{
}
src/main/proto/ClientCustomerOrderService.proto
View file @
877407e
...
...
@@ -33,6 +33,13 @@ service ClientCustomerOrderServiceRpc {
// 操作记录
rpc
GetOrderOperationRecordsByOrderId
(
GetOrderOperationRecordsByOrderIdRequest
)
returns
(
GetOrderOperationRecordsByOrderIdResponse
)
{}
rpc
BatchCreateOrderOperationRecords
(
BatchCreateOrderOperationRecordsRequest
)
returns
(
BatchCreateOrderOperationRecordsResponse
)
{}
// sku菜品库存
rpc
QuerySkuSellQuantitiesByStall
(
QuerySkuSellQuantitiesByStallRpcRequest
)
returns
(
QuerySkuSellQuantitiesByStallRpcResponse
)
{}
rpc
QuerySkuSellQuantitiesByStallAndSkuIds
(
QuerySkuSellQuantitiesByStallAndSkuIdsRpcRequest
)
returns
(
QuerySkuSellQuantitiesByStallAndSkuIdsRpcResponse
)
{}
rpc
BatchSaveSkuSellQuantities
(
BatchSaveSkuSellQuantitiesRpcRequest
)
returns
(
BatchSaveSkuSellQuantitiesRpcResponse
)
{}
}
enum
OrderStatusEnum
{
...
...
@@ -608,3 +615,56 @@ message BatchCreateOrderOperationRecordsResponse {
bool
isCreated
=
1
;
repeated
int32
ids
=
2
;
}
message
SingleSkuSellQuantityRpcResponse
{
int32
id
=
1
;
int32
enterpriseId
=
2
;
int32
stallId
=
3
;
int32
skuId
=
4
;
int32
maxSellQuantity
=
5
;
int32
todaySellQuantity
=
6
;
int32
createdBy
=
7
;
int64
createdAt
=
8
;
int32
creationSource
=
9
;
int32
updatedBy
=
10
;
int64
updatedAt
=
11
;
int32
updateSource
=
12
;
bool
isDeleted
=
13
;
}
message
QuerySkuSellQuantitiesByStallRpcRequest
{
int32
enterpriseId
=
1
;
int32
stallId
=
2
;
}
message
QuerySkuSellQuantitiesByStallRpcResponse
{
repeated
SingleSkuSellQuantityRpcResponse
responses
=
1
;
}
message
QuerySkuSellQuantitiesByStallAndSkuIdsRpcRequest
{
int32
enterpriseId
=
1
;
int32
stallId
=
2
;
repeated
int32
skuIds
=
3
;
}
message
QuerySkuSellQuantitiesByStallAndSkuIdsRpcResponse
{
repeated
SingleSkuSellQuantityRpcResponse
responses
=
1
;
}
message
BatchSaveSkuSellQuantitiesRpcRequest
{
repeated
SkuSellQuantityModification
skuSellQuantityModifications
=
1
;
int32
enterpriseId
=
2
;
int32
updatedBy
=
3
;
int32
updateSource
=
4
;
}
message
SkuSellQuantityModification
{
int32
id
=
1
;
int32
stallId
=
2
;
int32
skuId
=
3
;
int32
maxSellQuantity
=
4
;
}
message
BatchSaveSkuSellQuantitiesRpcResponse
{
bool
isSaved
=
1
;
}
...
...
src/main/resources/mapper/SkuSellQuantityMapper.xml
0 → 100644
View file @
877407e
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.tianting.infoloop.mapper.SkuSellQuantityMapper"
>
<resultMap
id=
"BaseResultMap"
type=
"com.tianting.infoloop.model.db.SkuSellQuantity"
>
<id
property=
"id"
column=
"id"
jdbcType=
"INTEGER"
/>
<result
property=
"enterpriseId"
column=
"enterpriseId"
jdbcType=
"INTEGER"
/>
<result
property=
"stallId"
column=
"stallId"
jdbcType=
"INTEGER"
/>
<result
property=
"skuId"
column=
"skuId"
jdbcType=
"INTEGER"
/>
<result
property=
"maxSellQuantity"
column=
"maxSellQuantity"
jdbcType=
"INTEGER"
/>
<result
property=
"todaySellQuantity"
column=
"todaySellQuantity"
jdbcType=
"INTEGER"
/>
<result
property=
"createdBy"
column=
"createdBy"
jdbcType=
"INTEGER"
/>
<result
property=
"createdAt"
column=
"createdAt"
jdbcType=
"TIMESTAMP"
/>
<result
property=
"creationSource"
column=
"creationSource"
jdbcType=
"INTEGER"
/>
<result
property=
"updatedBy"
column=
"updatedBy"
jdbcType=
"INTEGER"
/>
<result
property=
"updatedAt"
column=
"updatedAt"
jdbcType=
"TIMESTAMP"
/>
<result
property=
"updateSource"
column=
"updateSource"
jdbcType=
"INTEGER"
/>
<result
property=
"isDeleted"
column=
"isDeleted"
jdbcType=
"TINYINT"
/>
</resultMap>
<sql
id=
"Base_Column_List"
>
id,enterpriseId,stallId,
skuId,maxSellQuantity,todaySellQuantity,
createdBy,createdAt,creationSource,
updatedBy,updatedAt,updateSource,
isDeleted
</sql>
</mapper>
Please
register
or
login
to post a comment