Compare commits
232 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c69af3e751 | ||
|
|
dfb98c107e | ||
|
|
9d3ed4a4a7 | ||
|
|
e89be8eb8c | ||
|
|
3559971a8d | ||
|
|
dc1d1a7e7e | ||
|
|
10ecce1e0d | ||
|
|
2520c27f77 | ||
|
|
63d684c972 | ||
|
|
35739b64a3 | ||
|
|
ddcda57a08 | ||
|
|
16ae69ed06 | ||
|
|
fd067d8abf | ||
|
|
42b3c72977 | ||
|
|
e34b4172b8 | ||
|
|
30d6ab64f8 | ||
|
|
2e8c40bcf3 | ||
|
|
f2385c3ace | ||
|
|
a45355b125 | ||
|
|
b3bb771066 | ||
|
|
068c6b986e | ||
|
|
18e2c89891 | ||
|
|
7b485753a6 | ||
|
|
8556d27173 | ||
|
|
d677aabbf4 | ||
|
|
aaa0748409 | ||
|
|
57ee156798 | ||
|
|
5ae4d8b4fa | ||
|
|
681327274c | ||
|
|
6ab2888fd0 | ||
|
|
80a0e0e8c7 | ||
|
|
80773e2d58 | ||
|
|
065bcc8a55 | ||
|
|
9398413999 | ||
|
|
cf623f6756 | ||
|
|
1b316baac6 | ||
|
|
4fc1d0e346 | ||
|
|
159fe37120 | ||
|
|
6f9486f065 | ||
|
|
94da71336a | ||
|
|
8c5ce396b2 | ||
|
|
0063820fdf | ||
|
|
fe80edebbd | ||
|
|
6b59c1e643 | ||
|
|
1b52381c71 | ||
|
|
763519876e | ||
|
|
cede181bc0 | ||
|
|
cb776eb4c0 | ||
|
|
8ed4f6eb3c | ||
|
|
9cf97f3203 | ||
|
|
2a984b8c56 | ||
|
|
22ecf48168 | ||
|
|
89422b2736 | ||
|
|
bcd4bf4ff1 | ||
|
|
a263bc6301 | ||
|
|
27ae773e20 | ||
|
|
085b61c2ab | ||
|
|
c7682680ee | ||
|
|
a301432a87 | ||
|
|
526de18a42 | ||
|
|
c940bf6cb2 | ||
|
|
a7643a6b93 | ||
|
|
24f6b9e80f | ||
|
|
d349616957 | ||
|
|
f7c9ba820d | ||
|
|
f99f59963a | ||
|
|
caaf9c74f3 | ||
|
|
076f47f5c4 | ||
|
|
f0e4e4c2bc | ||
|
|
c87fe45dfa | ||
|
|
49fd03df7f | ||
|
|
6deed61311 | ||
|
|
6311767320 | ||
|
|
2463d1b5bb | ||
|
|
9d41ae3cae | ||
|
|
2be8bf27bf | ||
|
|
2d052ffb1a | ||
|
|
88ab071ac7 | ||
|
|
bda72da679 | ||
|
|
95e5ef2d33 | ||
|
|
48a294e7c6 | ||
|
|
794fa63302 | ||
|
|
cdb8e851a8 | ||
|
|
f8ee3a8d15 | ||
|
|
76ab997922 | ||
|
|
97e7a130f1 | ||
|
|
2a96ad4af7 | ||
|
|
e1aee4a744 | ||
|
|
ecfe1524d4 | ||
|
|
42ea2dc986 | ||
|
|
230e2e7407 | ||
|
|
92639ba309 | ||
|
|
19b3225312 | ||
|
|
e56c20469d | ||
|
|
a28eceaf61 | ||
|
|
1925c6d33c | ||
|
|
fcac4002b1 | ||
|
|
ed3a2ae9fc | ||
|
|
4955d2135b | ||
|
|
9f1dacc1d4 | ||
|
|
f0765a6627 | ||
|
|
a31a9fdfbd | ||
|
|
fd2d0724a7 | ||
|
|
82d7389092 | ||
|
|
a53eb3cfde | ||
|
|
bd048d725c | ||
|
|
8e275613e1 | ||
|
|
fc869a34e0 | ||
|
|
48c84acb7c | ||
|
|
40d40a344e | ||
|
|
d31257ba76 | ||
|
|
f0a80338da | ||
|
|
6b5ca5b337 | ||
|
|
61f9d7812d | ||
|
|
d5eeafc554 | ||
|
|
2175433444 | ||
|
|
cfbb1a1519 | ||
|
|
1302ca6de4 | ||
|
|
239b520939 | ||
|
|
56d9dbee5b | ||
|
|
41decf1fa1 | ||
|
|
1d2cb5737d | ||
|
|
a2496b267a | ||
|
|
178544fe2d | ||
|
|
9e3b9c8f38 | ||
|
|
b439d8283f | ||
|
|
fb48bce38d | ||
|
|
b189fbe238 | ||
|
|
26c1c97442 | ||
|
|
ee8f5b6e1e | ||
|
|
6755515b1f | ||
|
|
074036c0b5 | ||
|
|
c7d0820eed | ||
|
|
97c0fdbf1d | ||
|
|
a962939db8 | ||
|
|
a9802710ef | ||
|
|
aaaa0b1ebf | ||
|
|
f34d10146a | ||
|
|
b875cbdda4 | ||
|
|
d80a3f7f48 | ||
|
|
259946e78f | ||
|
|
9c24adf77d | ||
|
|
4c47d4aba2 | ||
|
|
7f9061cfc5 | ||
|
|
085dad2107 | ||
|
|
055a7fffdb | ||
|
|
6cea6af59b | ||
|
|
6f0f8106e0 | ||
|
|
c9a0ce7985 | ||
|
|
b40533c553 | ||
|
|
e2fff23080 | ||
|
|
72482ee395 | ||
|
|
5366034556 | ||
|
|
484e2a2318 | ||
|
|
0873fba7df | ||
|
|
4aa6f864f0 | ||
|
|
183b2ba30c | ||
|
|
071f15347e | ||
|
|
71ed58e665 | ||
|
|
50c7e20ba6 | ||
|
|
876b801fa1 | ||
|
|
bd42b88b71 | ||
|
|
b2dfb3abe2 | ||
|
|
164f726222 | ||
|
|
24cdf5cf00 | ||
|
|
93cb9da558 | ||
|
|
66c6bfa0fb | ||
|
|
edd93a6ad4 | ||
|
|
ea1626a2ef | ||
|
|
1f3b7f21bb | ||
|
|
e6fe055cd5 | ||
|
|
1422b6fdbc | ||
|
|
cfb70eff8a | ||
|
|
dfe6085432 | ||
|
|
b8e8db0e36 | ||
|
|
fb2e41422b | ||
|
|
f3db8f2e45 | ||
|
|
6bc2c0adf1 | ||
|
|
df75e08d22 | ||
|
|
b2ccdad483 | ||
|
|
3d6eb7b4fa | ||
|
|
96cfb8a8ce | ||
|
|
4a4672c80a | ||
|
|
a0c1cd1019 | ||
|
|
ed20d1abbb | ||
|
|
0ebb9c01f8 | ||
|
|
dd3176f841 | ||
|
|
a910a97719 | ||
|
|
cdf8ab3a3c | ||
|
|
074e4ed5b7 | ||
|
|
9e43d186d7 | ||
|
|
8b61d40ff8 | ||
|
|
f9b3001eb3 | ||
|
|
f1ec44869d | ||
|
|
72341acb57 | ||
|
|
fa696e6c11 | ||
|
|
b30909942a | ||
|
|
7c64e1f11d | ||
|
|
d1c6988d0f | ||
|
|
efe0bd4bad | ||
|
|
7523481be0 | ||
|
|
23182106b9 | ||
|
|
515ffbcf0a | ||
|
|
8f52a1e2a2 | ||
|
|
bdd9045fc1 | ||
|
|
518616483b | ||
|
|
817f662cb7 | ||
|
|
01419cde15 | ||
|
|
118efe0833 | ||
|
|
46911004db | ||
|
|
b87190d135 | ||
|
|
39e22f5561 | ||
|
|
02dd37c87f | ||
|
|
7db7afad4a | ||
|
|
25582e2958 | ||
|
|
3c5609545b | ||
|
|
061d924d46 | ||
|
|
49af6777ee | ||
|
|
e9d9a95cb4 | ||
|
|
7e70e7d6cd | ||
|
|
ebb48c7d0f | ||
|
|
e0d464906e | ||
|
|
9189a6d433 | ||
|
|
b3f6bad6f8 | ||
|
|
105162aa89 | ||
|
|
51c4161f68 | ||
|
|
488d9352f3 | ||
|
|
56b800e4ff | ||
|
|
03864ca1a9 | ||
|
|
94c87f5645 | ||
|
|
dadf48ac25 | ||
|
|
a47bfcc5fd |
11
DB/b2c.sql
Normal file
11
DB/b2c.sql
Normal file
@@ -0,0 +1,11 @@
|
||||
/**
|
||||
物流公司增加电子面单参数
|
||||
*/
|
||||
ALTER TABLE li_logistics ADD `customer_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '客户代码';
|
||||
ALTER TABLE li_logistics ADD `customer_pwd` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '客户密码';
|
||||
ALTER TABLE li_logistics ADD `month_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '月结号/密钥';
|
||||
ALTER TABLE li_logistics ADD `send_site` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '归属网点';
|
||||
ALTER TABLE li_logistics ADD `send_staff` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '收件快递员';
|
||||
ALTER TABLE li_logistics ADD `face_sheet_flag` bit(1) DEFAULT NULL COMMENT '是否使用电子面单';
|
||||
ALTER TABLE li_logistics ADD `pay_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '支付方式';
|
||||
ALTER TABLE li_logistics ADD `exp_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin DEFAULT NULL COMMENT '快递类型';
|
||||
@@ -84,7 +84,7 @@ ALTER TABLE li_foot_print ADD `store_id` varchar(255) DEFAULT NULL COMMENT '店
|
||||
|
||||
|
||||
/**
|
||||
订单增加自提信息
|
||||
用户提现申请增加字段
|
||||
*/
|
||||
ALTER TABLE li_member_withdraw_apply ADD `real_name` varchar(255) DEFAULT NULL;
|
||||
ALTER TABLE li_member_withdraw_apply ADD `connect_number` varchar(255) DEFAULT NULL;
|
||||
167
DB/version4.3to4.4.sql
Normal file
167
DB/version4.3to4.4.sql
Normal file
@@ -0,0 +1,167 @@
|
||||
CREATE TABLE `li_file_directory`
|
||||
(
|
||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`create_time` datetime NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`create_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '创建者',
|
||||
`update_time` datetime NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`update_by` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_bin NULL DEFAULT NULL COMMENT '更新者',
|
||||
`delete_flag` tinyint(1) NULL DEFAULT 0 COMMENT '删除标志 true/false 删除/未删除',
|
||||
`directory_type` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '文件目录类型',
|
||||
`directory_name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '拥有者名称',
|
||||
`owner_id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NULL DEFAULT NULL COMMENT '拥有者id',
|
||||
`parent_id` bigint NULL DEFAULT NULL COMMENT '父分类ID',
|
||||
`level` int NULL DEFAULT NULL COMMENT '层级',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB
|
||||
AUTO_INCREMENT = 1698937596963311619
|
||||
CHARACTER SET = utf8mb4
|
||||
COLLATE = utf8mb4_0900_ai_ci COMMENT = '文件夹'
|
||||
ROW_FORMAT = DYNAMIC;
|
||||
|
||||
SET FOREIGN_KEY_CHECKS = 1;
|
||||
|
||||
ALTER TABLE li_file
|
||||
ADD file_directory_id varchar(255) COMMENT '文件夹ID';
|
||||
|
||||
/**
|
||||
订单包裹
|
||||
*/
|
||||
CREATE TABLE `li_order_package` (
|
||||
`id` bigint NOT NULL COMMENT 'ID',
|
||||
`create_by` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin DEFAULT NULL COMMENT '创建者',
|
||||
`create_time` datetime(6) DEFAULT NULL COMMENT '创建时间',
|
||||
`delete_flag` bit(1) DEFAULT NULL COMMENT '是否删除',
|
||||
`update_by` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin DEFAULT NULL COMMENT '修改者',
|
||||
`update_time` datetime(6) DEFAULT NULL COMMENT '修改时间',
|
||||
`package_no` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin DEFAULT NULL COMMENT '包裹单号',
|
||||
`order_sn` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin DEFAULT NULL COMMENT '订单编号',
|
||||
`logistics_no` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin DEFAULT NULL COMMENT '发货单号',
|
||||
`logistics_code` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin DEFAULT NULL COMMENT '物流公司CODE',
|
||||
`logistics_name` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin DEFAULT NULL COMMENT '物流公司名称',
|
||||
`consignee_mobile` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin DEFAULT NULL COMMENT '收件人手机',
|
||||
`status` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin DEFAULT NULL COMMENT '状态',
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin ROW_FORMAT=DYNAMIC;
|
||||
|
||||
/**
|
||||
分包货物
|
||||
*/
|
||||
CREATE TABLE `li_order_package_item` (
|
||||
`id` bigint NOT NULL COMMENT 'ID',
|
||||
`create_by` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin DEFAULT NULL COMMENT '创建者',
|
||||
`create_time` datetime(6) DEFAULT NULL COMMENT '创建时间',
|
||||
`delete_flag` bit(1) DEFAULT NULL COMMENT '是否删除',
|
||||
`update_by` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin DEFAULT NULL COMMENT '修改者',
|
||||
`update_time` datetime(6) DEFAULT NULL COMMENT '修改时间',
|
||||
`package_no` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin DEFAULT NULL COMMENT '包裹单号',
|
||||
`order_sn` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_bin DEFAULT NULL COMMENT '订单编号',
|
||||
`order_item_sn` varchar(255) COLLATE utf8mb3_bin DEFAULT NULL COMMENT '子订单编号',
|
||||
`deliver_number` int DEFAULT NULL COMMENT '发货数量',
|
||||
`logistics_time` datetime(6) DEFAULT NULL COMMENT '发货时间',
|
||||
`goods_name` varchar(255) COLLATE utf8mb3_bin DEFAULT NULL,
|
||||
`thumbnail` varchar(255) COLLATE utf8mb3_bin DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin ROW_FORMAT=DYNAMIC;
|
||||
|
||||
/*
|
||||
订单货物增加发货数量
|
||||
*/
|
||||
ALTER TABLE li_order_item ADD `deliver_number` int DEFAULT NULL COMMENT '发货数量';
|
||||
|
||||
/*
|
||||
sku增加预警库存
|
||||
*/
|
||||
ALTER TABLE li_goods_sku ADD `alert_quantity` int DEFAULT NULL COMMENT '预警库存';
|
||||
/*
|
||||
增加库存预警菜单
|
||||
*/
|
||||
INSERT INTO `lilishop`.`li_store_menu`(`id`, `create_by`, `create_time`, `delete_flag`, `update_by`, `update_time`, `description`, `front_route`, `icon`, `level`, `name`, `parent_id`, `path`, `sort_order`, `title`, `permission`) VALUES (1349237928434098177, NULL, '2022-01-11 22:35:45.000000', b'0', NULL, '2022-01-11 22:37:05', NULL, 'goods/goods-seller/alertQuantity', 'ios-american-football', 2, 'alert-goods-quantity', '1348810864748945408', 'alert-goods-quantity', '1.14', '库存预警', NULL);
|
||||
|
||||
/**
|
||||
交易唤醒表,增加交易流水详情
|
||||
*/
|
||||
ALTER TABLE li_order_item ADD `is_refund` varchar(255) DEFAULT NULL COMMENT '是否退款';
|
||||
|
||||
/**
|
||||
交易表增加订单状态字段
|
||||
*/
|
||||
ALTER TABLE li_order_item ADD `refund_price` decimal(10,2) DEFAULT NULL COMMENT '退款金额';
|
||||
|
||||
/**
|
||||
结算单表,增加砍价/积分退款金额字段
|
||||
*/
|
||||
ALTER TABLE li_bill ADD `point_refund_settlement_price` decimal(10,2) DEFAULT NULL COMMENT '退货积分补贴返还';
|
||||
ALTER TABLE li_bill ADD `kanjia_refund_settlement_price` decimal(10,2) DEFAULT NULL COMMENT '退货砍价补贴返还';
|
||||
|
||||
UPDATE li_bill b
|
||||
SET b.point_refund_settlement_price =IFNULL((
|
||||
SELECT
|
||||
SUM( point_settlement_price )
|
||||
FROM
|
||||
li_store_flow sf
|
||||
WHERE
|
||||
sf.flow_type = 'REFUND'
|
||||
AND sf.store_id=b.store_id
|
||||
AND sf.create_time BETWEEN b.start_time
|
||||
AND b.end_time),0);
|
||||
|
||||
UPDATE li_bill b
|
||||
SET b.kanjia_refund_settlement_price =IFNULL((
|
||||
SELECT
|
||||
SUM( kanjia_settlement_price )
|
||||
FROM
|
||||
li_store_flow sf
|
||||
WHERE
|
||||
sf.flow_type = 'REFUND'
|
||||
AND sf.store_id=b.store_id
|
||||
AND sf.create_time BETWEEN b.start_time
|
||||
AND b.end_time),0);
|
||||
|
||||
/**
|
||||
文件表增加拥有者名称
|
||||
*/
|
||||
ALTER TABLE li_file ADD `owner_name` varchar(255) DEFAULT NULL COMMENT '拥有者名称';
|
||||
|
||||
/**
|
||||
初始化文件拥有者名称
|
||||
*/
|
||||
UPDATE li_file f JOIN li_store s ON f.owner_id = s.id
|
||||
SET f.owner_name = s.store_name
|
||||
WHERE user_enums = 'STORE';
|
||||
|
||||
UPDATE li_file f JOIN li_admin_user a ON f.owner_id = a.id
|
||||
SET f.owner_name = a.nick_name
|
||||
WHERE user_enums = 'MANAGER';
|
||||
|
||||
UPDATE li_file f JOIN li_member m ON f.owner_id = m.id
|
||||
SET f.owner_name = m.nick_name
|
||||
WHERE user_enums = 'MEMBER';
|
||||
|
||||
ALTER TABLE `li_order`
|
||||
ADD COLUMN `seller_remark` varchar(255) NULL COMMENT '商家订单备注' AFTER `remark`;
|
||||
|
||||
|
||||
ALTER TABLE `li_distribution_cash`
|
||||
ADD COLUMN `name` varchar(255) NULL COMMENT '会员姓名';
|
||||
ALTER TABLE `li_distribution_cash`
|
||||
ADD COLUMN `id_number` varchar(255) NULL COMMENT '身份证号' ;
|
||||
ALTER TABLE `li_distribution_cash`
|
||||
ADD COLUMN `settlement_bank_account_name` varchar(255) NULL COMMENT '结算银行开户行名称' ;
|
||||
ALTER TABLE `li_distribution_cash`
|
||||
ADD COLUMN `settlement_bank_account_num` varchar(255) NULL COMMENT '结算银行开户账号' ;
|
||||
ALTER TABLE `li_distribution_cash`
|
||||
ADD COLUMN `settlement_bank_branch_name` varchar(255) NULL COMMENT '结算银行开户支行名称' ;
|
||||
|
||||
ALTER TABLE `li_distribution` ADD `distribution_order_price` decimal(10,2) DEFAULT NULL COMMENT '分销订单金额';
|
||||
|
||||
ALTER TABLE `li_distribution_order` ADD `refund_num` int DEFAULT NULL COMMENT '退款商品数量';
|
||||
|
||||
ALTER TABLE `li_store_flow` ADD `bill_time` datetime(6) DEFAULT NULL COMMENT '结算时间';
|
||||
ALTER TABLE `li_store_flow` ADD `full_refund` bit(1) DEFAULT NULL COMMENT '是否全部退款';
|
||||
ALTER TABLE `li_store_flow` ADD `profit_sharing_status` varchar(255) NULL COMMENT '分账状态';
|
||||
ALTER TABLE `li_store_flow` ADD `profit_sharing` varchar(255) NULL COMMENT '分账详情';
|
||||
|
||||
|
||||
|
||||
INSERT INTO `lilishop`.`li_setting` (`id`, `create_by`, `create_time`, `delete_flag`, `update_by`, `update_time`, `setting_value`) VALUES ('CONNECT_SETTING', 'admin', '2024-07-07 13:55:38.686000', b'0', NULL, NULL, '{\"callbackUrl\":\"https://buyer-api.pickmall.cn\",\"pc\":\"https://pc-b2b2c.pickmall.cn\",\"wap\":\"https://m-b2b2c.pickmall.cn\"}');
|
||||
UPDATE `lilishop`.`li_setting` SET `create_by` = 'admin', `create_time` = '2021-01-23 02:18:03.299000', `delete_flag` = b'0', `update_by` = 'admin', `update_time` = '2024-07-07 13:53:44.732000', `setting_value` = '{\"accessKeyId\":\"test\",\"tencentSdkAppId\":\"null\",\"registerTemplateCode\":\"SMS_205755298\",\"huaweiSender\":\"null\",\"signName\":\"lili\",\"tencentSecretId\":\"null\",\"huaweiAppKey\":\"null\",\"isTestModel\":\"true\",\"tencentSecretKey\":\"null\",\"type\":\"ALI\",\"accessSecret\":\"test\",\"tencentSignName\":\"null\",\"huaweiSignature\":\"null\",\"payPasswordTemplateCode\":\"SMS_205755301\",\"walletPasswordTemplateCode\":\"SMS_205755297\",\"findPasswordTemplateCode\":\"SMS_205755301\",\"huaweiAppSecret\":\"null\",\"loginTemplateCode\":\"SMS_205755300\"}' WHERE `id` = 'SMS_SETTING';
|
||||
49
README.md
49
README.md
@@ -1,23 +1,4 @@
|
||||
## Lilishop B2B2C商城系统
|
||||
|
||||
#### 欢迎交流需求,交流业务,交流技术(基础问题自行解决,其他问题先看文档后提问)
|
||||
|
||||
#### 不用削尖脑袋往老群里加,老群活跃度较低,很多潜水党,新群相对而言活跃一些 :tw-1f606: :tw-1f606: :tw-1f606: :tw-1f606: :tw-1f606: :tw-1f606:
|
||||
|
||||
#### PS: **演示站点所有环境均部署master分支。如果有演示站点问题,可以反馈,如果演示站点没问题本地运行有问题,需自行处理**
|
||||
|
||||
##### 交流 qq 1群 961316482(已满)
|
||||
##### 交流 qq 2群 875294241(已满)
|
||||
##### 交流 qq 3群 263785057(已满)
|
||||
##### 交流 qq 4群 674617534 (已满)
|
||||
##### 交流 qq 5群 594675235
|
||||
|
||||
##### 体验 公众号/小程序/APP 体验,扫描二维码
|
||||
|
||||

|
||||
|
||||
[](https://gitee.com/beijing_hongye_huicheng/lilishop/stargazers)
|
||||

|
||||
## Lilishop 商城系统
|
||||
|
||||
|
||||
### 商城介绍
|
||||
@@ -35,6 +16,32 @@ https://gitee.com/beijing_hongye_huicheng/lilishop-simplify
|
||||
|
||||
https://docs.pickmall.cn
|
||||
|
||||
|
||||
#### 欢迎交流需求,交流业务,交流技术(基础问题自行解决,其他问题先看文档后提问)
|
||||
|
||||
#### 不用削尖脑袋往老群里加,老群活跃度较低,很多潜水党,新群相对而言活跃一些 :tw-1f606: :tw-1f606: :tw-1f606: :tw-1f606: :tw-1f606: :tw-1f606:
|
||||
|
||||
#### 开发新手或者不熟悉的同学在群内提问或新开Issue提问前,请先阅读[【提问的智慧】](https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way/blob/master/README-zh_CN.md),并确保已查阅过 [【在线文档】](https://docs.pickmall.cn/) ,避免浪费大家的宝贵时间;
|
||||
|
||||
##### 交流 qq 1群 961316482(已满)
|
||||
##### 交流 qq 2群 875294241(已满)
|
||||
##### 交流 qq 3群 263785057(已满)
|
||||
##### 交流 qq 4群 674617534(已满)
|
||||
##### 交流 qq 5群 594675235(已满)
|
||||
##### 交流 qq 6群 917026848(已满)
|
||||
##### 交流 qq 7群 936344822
|
||||
|
||||
##### 体验 公众号/小程序/APP 体验,扫描二维码
|
||||
|
||||

|
||||
|
||||
[](https://gitee.com/beijing_hongye_huicheng/lilishop/stargazers)
|
||||

|
||||
|
||||
|
||||
#### PS: **演示站点所有环境均部署master分支。如果有演示站点问题,可以反馈,如果演示站点没问题本地运行有问题,需自行处理**
|
||||
|
||||
|
||||
### 项目地址
|
||||
|
||||
gitee : https://gitee.com/beijing_hongye_huicheng
|
||||
@@ -188,7 +195,7 @@ PS:手机验证码为 ‘111111’
|
||||
##### 交流 qq 2群 875294241(已满)
|
||||
##### 交流 qq 3群 263785057(已满)
|
||||
##### 交流 qq 4群 674617534(已满)
|
||||
##### 交流 qq 5群 594675235
|
||||
##### 交流 qq 5群 594675235(已满)
|
||||
|
||||
### 附录
|
||||
有人有自己的学习视频、学习记录文档、希望宣传关联开源项目等均可以私聊仓库所有者。
|
||||
|
||||
@@ -6,6 +6,7 @@ import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.goods.entity.dos.Goods;
|
||||
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
||||
import cn.lili.modules.goods.entity.dto.GoodsSearchParams;
|
||||
import cn.lili.modules.goods.entity.vos.GoodsVO;
|
||||
import cn.lili.modules.goods.service.GoodsService;
|
||||
@@ -101,6 +102,12 @@ public class GoodsBuyerController {
|
||||
return ResultUtil.data(goodsService.queryByParams(goodsSearchParams));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取商品sku列表")
|
||||
@GetMapping("/sku")
|
||||
public ResultMessage<List<GoodsSku>> getSkuByPage(GoodsSearchParams goodsSearchParams) {
|
||||
return ResultUtil.data(goodsSkuService.getGoodsSkuByList(goodsSearchParams));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "从ES中获取商品信息")
|
||||
@GetMapping("/es")
|
||||
public ResultMessage<Page<EsGoodsIndex>> getGoodsByPageFromEs(EsGoodsSearchDTO goodsSearchParams, PageVO pageVO) {
|
||||
|
||||
@@ -9,11 +9,14 @@ import cn.lili.common.security.OperationalJudgment;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.order.order.entity.dos.Order;
|
||||
import cn.lili.modules.order.order.entity.dos.OrderPackage;
|
||||
import cn.lili.modules.order.order.entity.dto.OrderSearchParams;
|
||||
import cn.lili.modules.order.order.entity.enums.OrderStatusEnum;
|
||||
import cn.lili.modules.order.order.entity.vo.OrderDetailVO;
|
||||
import cn.lili.modules.order.order.entity.vo.OrderSimpleVO;
|
||||
import cn.lili.modules.order.order.service.OrderPackageService;
|
||||
import cn.lili.modules.order.order.service.OrderService;
|
||||
import cn.lili.modules.system.entity.vo.Traces;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
@@ -44,6 +47,9 @@ public class OrderBuyerController {
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
|
||||
@Autowired
|
||||
private OrderPackageService orderPackageService;
|
||||
|
||||
@ApiOperation(value = "查询会员订单列表")
|
||||
@GetMapping
|
||||
public ResultMessage<IPage<OrderSimpleVO>> queryMineOrder(OrderSearchParams orderSearchParams) {
|
||||
@@ -138,4 +144,21 @@ public class OrderBuyerController {
|
||||
return ResultUtil.data(orderService.invoice(orderSn));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询物流踪迹")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "orderSn", value = "订单编号", required = true, dataType = "String", paramType = "path")
|
||||
})
|
||||
@GetMapping(value = "/getTracesList/{orderSn}")
|
||||
public ResultMessage<Object> getTracesList(@NotBlank(message = "订单编号不能为空") @PathVariable String orderSn) {
|
||||
return ResultUtil.data(orderPackageService.getOrderPackageVOList(orderSn));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查看包裹列表")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "orderSn", value = "订单编号", required = true, dataType = "String", paramType = "path")
|
||||
})
|
||||
@GetMapping(value = "/getPackage/{orderSn}")
|
||||
public ResultMessage<Object> getPackage(@NotBlank(message = "订单编号不能为空") @PathVariable String orderSn) {
|
||||
return ResultUtil.data(orderPackageService.getOrderPackageVOList(orderSn));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
package cn.lili.controller.other;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.common.aop.annotation.DemoSite;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.system.entity.dos.Setting;
|
||||
import cn.lili.modules.system.entity.dto.*;
|
||||
import cn.lili.modules.system.entity.dto.connect.ConnectSetting;
|
||||
import cn.lili.modules.system.entity.dto.connect.QQConnectSetting;
|
||||
import cn.lili.modules.system.entity.dto.connect.WechatConnectSetting;
|
||||
import cn.lili.modules.system.entity.dto.payment.AlipayPaymentSetting;
|
||||
import cn.lili.modules.system.entity.dto.payment.PaymentSupportSetting;
|
||||
import cn.lili.modules.system.entity.dto.payment.UnionPaymentSetting;
|
||||
import cn.lili.modules.system.entity.dto.payment.WechatPaymentSetting;
|
||||
import cn.lili.modules.system.entity.dto.payment.dto.PaymentSupportForm;
|
||||
import cn.lili.modules.system.entity.enums.SettingEnum;
|
||||
import cn.lili.modules.system.service.SettingService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author chc
|
||||
* @since 2022/6/2114:46
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "买家端,系统设置")
|
||||
@RequestMapping("/buyer/other/setting")
|
||||
public class SettingBuyerController {
|
||||
|
||||
@Autowired
|
||||
private SettingService settingService;
|
||||
/**
|
||||
* 缓存
|
||||
*/
|
||||
@Autowired
|
||||
private Cache<String> cache;
|
||||
|
||||
@DemoSite
|
||||
@ApiOperation(value = "查看配置")
|
||||
@GetMapping(value = "/get/{key}")
|
||||
@ApiImplicitParam(name = "key", value = "配置key", paramType = "path"
|
||||
, allowableValues = "BASE_SETTING,EMAIL_SETTING,GOODS_SETTING,KUAIDI_SETTING,ORDER_SETTING,OSS_SETTING,POINT_SETTING," +
|
||||
"WECHAT_PC_CONNECT,WECHAT_WAP_CONNECT,WECHAT_APP_CONNECT,WECHAT_MP_CONNECT," +
|
||||
"QQ_WEB_CONNECT,QQ_APP_CONNECT," +
|
||||
"QQ_WEB_CONNECT,QQ_APP_CONNECT,WEIBO_CONNECT,ALIPAY_CONNECT," +
|
||||
"PAYMENT_SUPPORT,ALIPAY_PAYMENT,WECHAT_PAYMENT,SECKILL_SETTING,EXPERIENCE_SETTING,IM"
|
||||
)
|
||||
public ResultMessage settingGet(@PathVariable String key) {
|
||||
return createSetting(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取表单
|
||||
* 这里主要包含一个配置对象为空,导致转换异常问题的处理,解决配置项增加减少,带来的系统异常,无法直接配置
|
||||
*
|
||||
* @param key
|
||||
* @return
|
||||
* @throws InstantiationException
|
||||
* @throws IllegalAccessException
|
||||
*/
|
||||
private ResultMessage createSetting(String key) {
|
||||
SettingEnum settingEnum = SettingEnum.valueOf(key);
|
||||
cache.remove(key);
|
||||
Setting setting = settingService.get(key);
|
||||
switch (settingEnum) {
|
||||
case BASE_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new BaseSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), BaseSetting.class));
|
||||
case WITHDRAWAL_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new WithdrawalSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), WithdrawalSetting.class));
|
||||
case DISTRIBUTION_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new DistributionSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), DistributionSetting.class));
|
||||
case EMAIL_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new EmailSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), EmailSetting.class));
|
||||
case GOODS_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new GoodsSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), GoodsSetting.class));
|
||||
case LOGISTICS_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new LogisticsSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), LogisticsSetting.class));
|
||||
case ORDER_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new OrderSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), OrderSetting.class));
|
||||
case OSS_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new OssSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), OssSetting.class));
|
||||
case SMS_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new SmsSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), SmsSetting.class));
|
||||
case POINT_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new PointSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), PointSetting.class));
|
||||
case QQ_CONNECT:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new QQConnectSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), QQConnectSetting.class));
|
||||
case CONNECT_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new ConnectSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), ConnectSetting.class));
|
||||
case PAYMENT_SUPPORT:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new PaymentSupportSetting(new PaymentSupportForm())) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), PaymentSupportSetting.class));
|
||||
case ALIPAY_PAYMENT:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new AlipayPaymentSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), AlipayPaymentSetting.class));
|
||||
case UNIONPAY_PAYMENT:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new UnionPaymentSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), UnionPaymentSetting.class));
|
||||
case WECHAT_CONNECT:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new WechatConnectSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), WechatConnectSetting.class));
|
||||
case WECHAT_PAYMENT:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new WechatPaymentSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), WechatPaymentSetting.class));
|
||||
case SECKILL_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new SeckillSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), SeckillSetting.class));
|
||||
case EXPERIENCE_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new ExperienceSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), ExperienceSetting.class));
|
||||
case IM_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new ImSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), ImSetting.class));
|
||||
case HOT_WORDS:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new HotWordsSetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), HotWordsSetting.class));
|
||||
case DELIVERY_SETTING:
|
||||
return setting == null ?
|
||||
ResultUtil.data(new DeliverySetting()) :
|
||||
ResultUtil.data(JSONUtil.toBean(setting.getSettingValue(), DeliverySetting.class));
|
||||
default:
|
||||
throw new ServiceException(ResultCode.SETTING_NOT_TO_SET);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,9 +28,8 @@ import org.springframework.web.context.request.async.DeferredResult;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* 买家端,会员接口
|
||||
@@ -74,6 +73,8 @@ public class MemberBuyerController {
|
||||
new ResponseEntity<>(ResultUtil.error(ResultCode.ERROR), HttpStatus.OK);
|
||||
int timeoutSecond = 20;
|
||||
DeferredResult<ResponseEntity<Object>> deferredResult = new DeferredResult<>(timeoutSecond * 1000L, timeoutResponseEntity);
|
||||
// 用于记录重试次数
|
||||
AtomicInteger retryCount = new AtomicInteger(0);
|
||||
CompletableFuture.runAsync(() -> {
|
||||
try {
|
||||
int i = 0;
|
||||
@@ -84,7 +85,16 @@ public class MemberBuyerController {
|
||||
&& (QRCodeLoginSessionStatusEnum.WAIT_SCANNING.getCode() == status
|
||||
|| QRCodeLoginSessionStatusEnum.SCANNING.getCode() == status)) {
|
||||
//睡眠一秒种,继续等待结果
|
||||
TimeUnit.SECONDS.sleep(1);
|
||||
//TimeUnit.SECONDS.sleep(1);
|
||||
|
||||
// 应用指数退避策略
|
||||
int baseSleepTime = 1000; // 基础退避时间(毫秒)
|
||||
int maxSleepTime = 10000; // 最大退避时间(毫秒)
|
||||
|
||||
int sleepTime = Math.min(maxSleepTime, baseSleepTime * (1 + retryCount.getAndIncrement()));
|
||||
int randomFactor = (int) (Math.random() * (sleepTime / 2)); // 随机化因子
|
||||
|
||||
TimeUnit.MILLISECONDS.sleep(sleepTime + randomFactor);
|
||||
} else {
|
||||
deferredResult.setResult(new ResponseEntity<>(ResultUtil.data(queryResult), HttpStatus.OK));
|
||||
break;
|
||||
@@ -96,7 +106,7 @@ public class MemberBuyerController {
|
||||
deferredResult.setResult(new ResponseEntity<>(ResultUtil.error(ResultCode.ERROR), HttpStatus.OK));
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
}, Executors.newCachedThreadPool());
|
||||
});
|
||||
return deferredResult;
|
||||
}
|
||||
|
||||
@@ -155,6 +165,32 @@ public class MemberBuyerController {
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "绑定手机号")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "username", value = "用户名", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "mobile", value = "手机号", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "code", value = "验证码", required = true, paramType = "query"),
|
||||
})
|
||||
@PostMapping("/bindMobile")
|
||||
public ResultMessage<Object> bindMobile(@NotNull(message = "用户名不能为空") @RequestParam String username,
|
||||
@NotNull(message = "手机号为空") @RequestParam String mobile,
|
||||
@NotNull(message = "验证码为空") @RequestParam String code,
|
||||
@RequestHeader String uuid) {
|
||||
if (smsUtil.verifyCode(mobile, VerificationEnums.BIND_MOBILE, uuid, code)) {
|
||||
Member member = memberService.findByUsername(username);
|
||||
Member memberByMobile = memberService.findByMobile(mobile);
|
||||
if (member == null) {
|
||||
throw new ServiceException(ResultCode.USER_NOT_EXIST);
|
||||
}
|
||||
if(memberByMobile != null){
|
||||
throw new ServiceException(ResultCode.USER_MOBILE_REPEATABLE_ERROR);
|
||||
}
|
||||
return ResultUtil.data(memberService.changeMobile(member.getId(), mobile));
|
||||
} else {
|
||||
throw new ServiceException(ResultCode.VERIFICATION_SMS_CHECKED_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@ApiOperation(value = "注册用户")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "username", value = "用户名", required = true, paramType = "query"),
|
||||
@@ -251,12 +287,9 @@ public class MemberBuyerController {
|
||||
}
|
||||
|
||||
@ApiOperation(value = "注销账号")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "password", value = "密码", required = true, paramType = "query")
|
||||
})
|
||||
@PutMapping("/cancellation")
|
||||
public ResultMessage<Member> cancellation(@NotNull(message = "密码不能为空") @RequestParam String password) {
|
||||
memberService.cancellation(password);
|
||||
public ResultMessage<Member> cancellation() {
|
||||
memberService.cancellation();
|
||||
return ResultUtil.success();
|
||||
}
|
||||
|
||||
|
||||
@@ -64,13 +64,22 @@ public class CouponBuyerController {
|
||||
@GetMapping("/activity")
|
||||
@ApiOperation(value = "自动领取优惠券")
|
||||
public ResultMessage<List<MemberCoupon>> activity() {
|
||||
return ResultUtil.data(couponActivityService.trigger(
|
||||
if (UserContext.getCurrentUser() == null) {
|
||||
return ResultUtil.success();
|
||||
}
|
||||
List<MemberCoupon> memberCouponList = couponActivityService.trigger(
|
||||
CouponActivityTrigger.builder()
|
||||
.couponActivityTypeEnum(CouponActivityTypeEnum.AUTO_COUPON)
|
||||
.nickName(UserContext.getCurrentUser().getNickName())
|
||||
.userId(UserContext.getCurrentUser().getId())
|
||||
.build())
|
||||
);
|
||||
.build());
|
||||
memberCouponList.addAll(couponActivityService.trigger(
|
||||
CouponActivityTrigger.builder()
|
||||
.couponActivityTypeEnum(CouponActivityTypeEnum.SPECIFY)
|
||||
.nickName(UserContext.getCurrentUser().getNickName())
|
||||
.userId(UserContext.getCurrentUser().getId())
|
||||
.build()));
|
||||
return ResultUtil.data(memberCouponList);
|
||||
}
|
||||
|
||||
@GetMapping
|
||||
|
||||
@@ -213,18 +213,6 @@ lili:
|
||||
lbs:
|
||||
key: 4BYBZ-7MT6S-PUAOA-6BNWL-FJUD7-UUFXT
|
||||
sk: zhNKVrJK6UPOhqIjn8AQvG37b9sz6
|
||||
#域名
|
||||
domain:
|
||||
pc: https://pc-b2b2c.pickmall.cn
|
||||
wap: https://m-b2b2c.pickmall.cn
|
||||
store: https://store-b2b2c.pickmall.cn
|
||||
admin: https://admin-b2b2c.pickmall.cn
|
||||
#api地址
|
||||
api:
|
||||
buyer: https://buyer-api.pickmall.cn
|
||||
common: https://common-api.pickmall.cn
|
||||
manager: https://admin-api.pickmall.cn
|
||||
store: https://store-api.pickmall.cn
|
||||
|
||||
# jwt 细节设定
|
||||
jwt-setting:
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package cn.lili.controller.common;
|
||||
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.common.context.ThreadContextHolder;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.utils.ResponseUtil;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.common.vo.SearchVO;
|
||||
import cn.lili.modules.file.entity.File;
|
||||
import cn.lili.modules.file.entity.dto.FileOwnerDTO;
|
||||
import cn.lili.modules.file.service.FileService;
|
||||
@@ -43,10 +43,14 @@ public class FileController {
|
||||
@ApiOperation(value = "获取自己的图片资源")
|
||||
@GetMapping
|
||||
@ApiImplicitParam(name = "title", value = "名称模糊匹配")
|
||||
public ResultMessage<IPage<File>> getFileList(@RequestHeader String accessToken, File file, SearchVO searchVO, PageVO pageVo) {
|
||||
public ResultMessage<IPage<File>> getFileList(@RequestHeader String accessToken, FileOwnerDTO fileOwnerDTO) {
|
||||
|
||||
AuthUser authUser = UserContext.getAuthUser(cache, accessToken);
|
||||
FileOwnerDTO fileOwnerDTO = new FileOwnerDTO();
|
||||
if (authUser == null) {
|
||||
ResponseUtil.output(ThreadContextHolder.getHttpResponse(), 403, ResponseUtil.resultMap(false,
|
||||
403, "登录已失效,请重新登录"));
|
||||
return null;
|
||||
}
|
||||
//只有买家才写入自己id
|
||||
if (authUser.getRole().equals(UserEnums.MEMBER)) {
|
||||
fileOwnerDTO.setOwnerId(authUser.getId());
|
||||
@@ -55,7 +59,7 @@ public class FileController {
|
||||
fileOwnerDTO.setOwnerId(authUser.getStoreId());
|
||||
}
|
||||
fileOwnerDTO.setUserEnums(authUser.getRole().name());
|
||||
return ResultUtil.data(fileService.customerPageOwner(fileOwnerDTO, file, searchVO, pageVo));
|
||||
return ResultUtil.data(fileService.customerPageOwner(fileOwnerDTO));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "文件重命名")
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
package cn.lili.controller.common;
|
||||
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.vo.ResultMessage;
|
||||
import cn.lili.modules.file.entity.FileDirectory;
|
||||
import cn.lili.modules.file.entity.dto.FileDirectoryDTO;
|
||||
import cn.lili.modules.file.service.FileDirectoryService;
|
||||
import cn.lili.modules.file.service.FileService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文件目录管理接口
|
||||
*
|
||||
* @author Chopper
|
||||
* @since 2020/11/26 15:41
|
||||
*/
|
||||
@RestController
|
||||
@Api(tags = "文件目录管理接口")
|
||||
@RequestMapping("/common/resource/fileDirectory")
|
||||
@RequiredArgsConstructor
|
||||
public class FileDirectoryController {
|
||||
|
||||
private final FileDirectoryService fileDirectoryService;
|
||||
private final FileService fileService;
|
||||
|
||||
@ApiOperation(value = "获取文件目录列表")
|
||||
@GetMapping
|
||||
public ResultMessage<List<FileDirectoryDTO>> getSceneFileList() {
|
||||
return ResultUtil.data(fileDirectoryService.getFileDirectoryList(UserContext.getCurrentUser().getId()));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "添加文件目录")
|
||||
@PostMapping
|
||||
public ResultMessage<FileDirectory> addSceneFileList(@RequestBody @Valid FileDirectory fileDirectory) {
|
||||
fileDirectory.setDirectoryType(UserContext.getCurrentUser().getRole().name());
|
||||
fileDirectory.setOwnerId(UserContext.getCurrentUser().getId());
|
||||
fileDirectoryService.save(fileDirectory);
|
||||
return ResultUtil.data(fileDirectory);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "修改文件目录")
|
||||
@PutMapping
|
||||
public ResultMessage<FileDirectory> editSceneFileList(@RequestBody @Valid FileDirectory fileDirectory) {
|
||||
fileDirectory.setDirectoryType(UserContext.getCurrentUser().getRole().name());
|
||||
fileDirectory.setOwnerId(UserContext.getCurrentUser().getId());
|
||||
fileDirectoryService.updateById(fileDirectory);
|
||||
return ResultUtil.data(fileDirectory);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "删除文件目录")
|
||||
@DeleteMapping("/{id}")
|
||||
public ResultMessage<Object> deleteSceneFileList(@PathVariable String id) {
|
||||
//检测文件夹下是否包含图片
|
||||
if(fileService.countByDirectory(id)){
|
||||
return ResultUtil.error(ResultCode.FILE_DIRECTORY_NOT_EMPTY);
|
||||
}
|
||||
//删除目录
|
||||
fileDirectoryService.removeById(id);
|
||||
return ResultUtil.success();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package cn.lili.controller.common;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.ResultUtil;
|
||||
@@ -21,10 +22,7 @@ import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.InputStream;
|
||||
@@ -55,8 +53,11 @@ public class UploadController {
|
||||
@PostMapping(value = "/file")
|
||||
public ResultMessage<Object> upload(MultipartFile file,
|
||||
String base64,
|
||||
@RequestHeader String accessToken) {
|
||||
@RequestHeader String accessToken, @RequestParam String directoryPath) {
|
||||
|
||||
if(StrUtil.isBlank(directoryPath)){
|
||||
directoryPath = "default";
|
||||
}
|
||||
|
||||
AuthUser authUser = UserContext.getAuthUser(cache, accessToken);
|
||||
//如果用户未登录,则无法上传图片
|
||||
@@ -89,6 +90,12 @@ public class UploadController {
|
||||
try {
|
||||
InputStream inputStream = file.getInputStream();
|
||||
//上传至第三方云服务或服务器
|
||||
String scene = UserContext.getCurrentUser().getRole().name();
|
||||
if (StrUtil.equalsAny(UserContext.getCurrentUser().getRole().name(), UserEnums.MEMBER.name(), UserEnums.STORE.name(), UserEnums.SEAT.name())) {
|
||||
scene = scene + "/" + authUser.getId();
|
||||
}
|
||||
fileKey = scene + "/" + directoryPath + "/" + fileKey;
|
||||
//上传至第三方云服务或服务器
|
||||
result = filePluginFactory.filePlugin().inputStreamUpload(inputStream, fileKey);
|
||||
//保存数据信息至数据库
|
||||
newFile.setName(file.getOriginalFilename());
|
||||
@@ -101,8 +108,19 @@ public class UploadController {
|
||||
//如果是店铺,则记录店铺id
|
||||
if (authUser.getRole().equals(UserEnums.STORE)) {
|
||||
newFile.setOwnerId(authUser.getStoreId());
|
||||
newFile.setOwnerName(authUser.getStoreName());
|
||||
} else {
|
||||
newFile.setOwnerId(authUser.getId());
|
||||
newFile.setOwnerName(authUser.getNickName());
|
||||
}
|
||||
|
||||
//存储文件目录
|
||||
if (StrUtil.isNotEmpty(directoryPath)) {
|
||||
if (directoryPath.indexOf("/") > 0) {
|
||||
newFile.setFileDirectoryId(directoryPath.substring(directoryPath.lastIndexOf("/") + 1));
|
||||
} else {
|
||||
newFile.setFileDirectoryId(directoryPath);
|
||||
}
|
||||
}
|
||||
fileService.save(newFile);
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -190,18 +190,6 @@ lili:
|
||||
interfereNum: 0
|
||||
#允许误差像素
|
||||
faultTolerant: 3
|
||||
#短信模版配置
|
||||
sms:
|
||||
#登录
|
||||
LOGIN: SMS_205755300
|
||||
#注册
|
||||
REGISTER: SMS_205755298
|
||||
#找回密码
|
||||
FIND_USER: SMS_205755301
|
||||
#设置密码
|
||||
UPDATE_PASSWORD: SMS_205755297
|
||||
#支付密码
|
||||
WALLET_PASSWORD: SMS_205755301
|
||||
system:
|
||||
isTestModel: true
|
||||
statistics:
|
||||
|
||||
@@ -24,12 +24,12 @@ spring:
|
||||
boot:
|
||||
admin:
|
||||
client:
|
||||
url: http://192.168.0.108:8000
|
||||
url: http://127.0.0.1:8000
|
||||
cache:
|
||||
type: redis
|
||||
# Redis
|
||||
redis:
|
||||
host: 192.168.31.108
|
||||
host: 192.168.31.100
|
||||
port: 30379
|
||||
password: lilishop
|
||||
lettuce:
|
||||
@@ -60,7 +60,7 @@ spring:
|
||||
default-datasource:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://192.168.31.108:30306/lilishop?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
url: jdbc:mysql://192.168.31.100:30306/lilishop?useUnicode=true&characterEncoding=utf-8&useSSL=false&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
username: root
|
||||
password: lilishop
|
||||
maxActive: 50
|
||||
@@ -209,21 +209,8 @@ lili:
|
||||
interfereNum: 1
|
||||
#允许误差像素
|
||||
faultTolerant: 3
|
||||
#短信模版配置
|
||||
sms:
|
||||
#登录
|
||||
LOGIN: SMS_205755300
|
||||
#注册
|
||||
REGISTER: SMS_205755298
|
||||
#找回密码
|
||||
FIND_USER: SMS_205755301
|
||||
#设置密码
|
||||
UPDATE_PASSWORD: SMS_205755297
|
||||
#支付密码
|
||||
WALLET_PASSWORD: SMS_205755301
|
||||
system:
|
||||
isDemoSite: false
|
||||
isTestModel: true
|
||||
# 脱敏级别:
|
||||
# 0:不做脱敏处理
|
||||
# 1:管理端用户手机号等信息脱敏
|
||||
@@ -241,16 +228,16 @@ lili:
|
||||
sk: zhNKVrJK6UPOhqIjn8AQvG37b9sz6
|
||||
#域名
|
||||
domain:
|
||||
pc: http://192.168.0.108:8888
|
||||
wap: http://192.168.0.108:8888
|
||||
seller: http://192.168.0.108:8888
|
||||
admin: http://192.168.0.108:8888
|
||||
pc: http://127.0.0.1:8888
|
||||
wap: http://127.0.0.1:8888
|
||||
seller: http://127.0.0.1:8888
|
||||
admin: http://127.0.0.1:8888
|
||||
#api地址
|
||||
api:
|
||||
buyer: https://z171l91606.51mypc.cn
|
||||
base: http://192.168.0.108:8888
|
||||
manager: http://192.168.0.108:8888
|
||||
seller: http://192.168.0.108:8888
|
||||
base: http://127.0.0.1:8888
|
||||
manager: http://127.0.0.1:8888
|
||||
seller: http://127.0.0.1:8888
|
||||
|
||||
# jwt 细节设定
|
||||
jwt-setting:
|
||||
@@ -269,7 +256,7 @@ lili:
|
||||
data:
|
||||
elasticsearch:
|
||||
cluster-name: elasticsearch
|
||||
cluster-nodes: 192.168.31.108:30920
|
||||
cluster-nodes: 192.168.31.100:30920
|
||||
index:
|
||||
number-of-replicas: 0
|
||||
number-of-shards: 3
|
||||
@@ -280,7 +267,7 @@ lili:
|
||||
# password: LiLiShopES
|
||||
|
||||
logstash:
|
||||
server: 127.0.0.1:4560
|
||||
server: 192.168.31.100:30560
|
||||
rocketmq:
|
||||
promotion-topic: shop_lili_promotion_topic
|
||||
promotion-group: shop_lili_promotion_group
|
||||
@@ -301,7 +288,7 @@ lili:
|
||||
after-sale-topic: shop_lili_after_sale_topic
|
||||
after-sale-group: shop_lili_after_sale_group
|
||||
rocketmq:
|
||||
name-server: 192.168.31.108:30876
|
||||
name-server: 192.168.31.100:9876
|
||||
isVIPChannel: false
|
||||
producer:
|
||||
group: lili_group
|
||||
@@ -310,7 +297,7 @@ rocketmq:
|
||||
xxl:
|
||||
job:
|
||||
admin:
|
||||
addresses: http://192.168.31.108:30001/xxl-job-admin
|
||||
addresses: http://192.168.31.100:30001/xxl-job-admin
|
||||
executor:
|
||||
appname: xxl-job-executor-lilishop
|
||||
address:
|
||||
|
||||
@@ -5,9 +5,7 @@ import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.event.AfterSaleStatusChangeEvent;
|
||||
import cn.lili.event.OrderStatusChangeEvent;
|
||||
import cn.lili.modules.distribution.entity.dos.DistributionOrder;
|
||||
import cn.lili.modules.distribution.entity.enums.DistributionOrderStatusEnum;
|
||||
import cn.lili.modules.distribution.mapper.DistributionOrderMapper;
|
||||
import cn.lili.modules.distribution.service.DistributionOrderService;
|
||||
import cn.lili.modules.order.aftersale.entity.dos.AfterSale;
|
||||
import cn.lili.modules.order.order.entity.dto.OrderMessage;
|
||||
@@ -17,13 +15,10 @@ import cn.lili.modules.system.entity.dto.DistributionSetting;
|
||||
import cn.lili.modules.system.entity.enums.SettingEnum;
|
||||
import cn.lili.modules.system.service.SettingService;
|
||||
import cn.lili.timetask.handler.EveryDayExecute;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 分销订单入库
|
||||
*
|
||||
@@ -32,7 +27,7 @@ import javax.annotation.Resource;
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DistributionOrderExecute implements OrderStatusChangeEvent, EveryDayExecute, AfterSaleStatusChangeEvent {
|
||||
public class DistributionOrderExecute implements OrderStatusChangeEvent, AfterSaleStatusChangeEvent {
|
||||
|
||||
/**
|
||||
* 分销订单
|
||||
@@ -40,10 +35,6 @@ public class DistributionOrderExecute implements OrderStatusChangeEvent, EveryDa
|
||||
@Autowired
|
||||
private DistributionOrderService distributionOrderService;
|
||||
|
||||
@Autowired
|
||||
private SettingService settingService;
|
||||
|
||||
|
||||
@Override
|
||||
public void orderChange(OrderMessage orderMessage) {
|
||||
|
||||
@@ -67,25 +58,10 @@ public class DistributionOrderExecute implements OrderStatusChangeEvent, EveryDa
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
log.info("分销订单定时开始执行");
|
||||
//设置结算天数(解冻日期)
|
||||
Setting setting = settingService.get(SettingEnum.DISTRIBUTION_SETTING.name());
|
||||
DistributionSetting distributionSetting = JSONUtil.toBean(setting.getSettingValue(), DistributionSetting.class);
|
||||
//解冻时间
|
||||
DateTime dateTime = new DateTime();
|
||||
//当前时间-结算天数=最终结算时间
|
||||
dateTime = dateTime.offsetNew(DateField.DAY_OF_MONTH, -distributionSetting.getCashDay());
|
||||
//分销人员订单结算
|
||||
distributionOrderService.updateRebate(dateTime,DistributionOrderStatusEnum.WAIT_BILL.name());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterSaleStatusChange(AfterSale afterSale) {
|
||||
if (afterSale.getServiceStatus().equals(AfterSaleStatusEnum.COMPLETE.name())) {
|
||||
distributionOrderService.refundOrder(afterSale.getSn());
|
||||
distributionOrderService.refundOrder(afterSale);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -104,7 +104,7 @@ public class FullDiscountExecute implements TradeEvent, OrderStatusChangeEvent {
|
||||
searchParams.setOrderPromotionType(OrderPromotionTypeEnum.GIFT.name());
|
||||
List<Order> orders = orderService.queryListByParams(searchParams);
|
||||
if (orders != null && !orders.isEmpty()) {
|
||||
orderService.systemCancel(orders.get(0).getSn(),"主订单取消,赠送订单字段自动取消");
|
||||
orderService.systemCancel(orders.get(0).getSn(),"主订单取消,赠送订单字段自动取消",true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import cn.lili.event.GoodsCommentCompleteEvent;
|
||||
import cn.lili.event.StoreSettingChangeEvent;
|
||||
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
||||
import cn.lili.modules.goods.entity.dto.GoodsSearchParams;
|
||||
import cn.lili.modules.goods.service.GoodsService;
|
||||
import cn.lili.modules.goods.service.GoodsSkuService;
|
||||
import cn.lili.modules.member.entity.dos.MemberEvaluation;
|
||||
import cn.lili.modules.store.entity.dos.Store;
|
||||
@@ -31,12 +32,15 @@ public class GoodsSkuExecute implements GoodsCommentCompleteEvent, StoreSettingC
|
||||
@Autowired
|
||||
private GoodsSkuService goodsSkuService;
|
||||
|
||||
@Autowired
|
||||
private GoodsService goodsService;
|
||||
|
||||
@Autowired
|
||||
private Cache cache;
|
||||
|
||||
@Override
|
||||
public void goodsComment(MemberEvaluation memberEvaluation) {
|
||||
goodsSkuService.updateGoodsSkuCommentNum(memberEvaluation.getSkuId());
|
||||
goodsService.updateGoodsCommentNum(memberEvaluation.getGoodsId(), memberEvaluation.getSkuId());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,7 @@ import cn.lili.modules.order.aftersale.entity.dos.AfterSale;
|
||||
import cn.lili.modules.order.order.entity.dos.Order;
|
||||
import cn.lili.modules.order.order.entity.dto.OrderMessage;
|
||||
import cn.lili.modules.order.order.entity.enums.OrderPromotionTypeEnum;
|
||||
import cn.lili.modules.order.order.entity.enums.OrderStatusEnum;
|
||||
import cn.lili.modules.order.order.entity.enums.PayStatusEnum;
|
||||
import cn.lili.modules.order.order.service.OrderService;
|
||||
import cn.lili.modules.order.trade.entity.enums.AfterSaleStatusEnum;
|
||||
@@ -134,12 +135,16 @@ public class MemberPointExecute implements MemberRegisterEvent, GoodsCommentComp
|
||||
@Override
|
||||
public void afterSaleStatusChange(AfterSale afterSale) {
|
||||
if (afterSale.getServiceStatus().equals(AfterSaleStatusEnum.COMPLETE.name())) {
|
||||
Order order = orderService.getBySn(afterSale.getOrderSn());
|
||||
//获取积分设置
|
||||
PointSetting pointSetting = getPointSetting();
|
||||
if (pointSetting.getConsumer() == 0 || !OrderStatusEnum.COMPLETED.name().equals(order.getOrderStatus())) {
|
||||
return;
|
||||
}
|
||||
//计算扣除积分数量
|
||||
Double point = CurrencyUtil.mul(pointSetting.getMoney(), afterSale.getActualRefundPrice(), 0);
|
||||
Double point = CurrencyUtil.mul(pointSetting.getConsumer(), afterSale.getActualRefundPrice(), 0);
|
||||
//扣除会员积分
|
||||
memberService.updateMemberPoint(point.longValue(), PointTypeEnum.REDUCE.name(), afterSale.getMemberId(), "会员退款,回退积分" + point + "分");
|
||||
memberService.updateMemberPoint(point.longValue(), PointTypeEnum.REDUCE.name(), afterSale.getMemberId(), "会员退款,回退消费赠送积分" + point + "分");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,23 @@
|
||||
package cn.lili.event.impl;
|
||||
|
||||
import cn.lili.common.utils.CurrencyUtil;
|
||||
import cn.lili.event.AfterSaleStatusChangeEvent;
|
||||
import cn.lili.event.TradeEvent;
|
||||
import cn.lili.modules.order.aftersale.entity.dos.AfterSale;
|
||||
import cn.lili.modules.order.cart.entity.dto.TradeDTO;
|
||||
import cn.lili.modules.order.order.entity.dos.Order;
|
||||
import cn.lili.modules.order.order.entity.dos.OrderItem;
|
||||
import cn.lili.modules.order.order.entity.enums.RefundStatusEnum;
|
||||
import cn.lili.modules.order.order.service.OrderItemService;
|
||||
import cn.lili.modules.order.order.service.OrderService;
|
||||
import cn.lili.modules.order.order.service.TradeService;
|
||||
import cn.lili.modules.order.trade.entity.enums.AfterSaleStatusEnum;
|
||||
import cn.lili.modules.payment.entity.enums.PaymentMethodEnum;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 订单状态处理类
|
||||
*
|
||||
@@ -14,11 +25,15 @@ import org.springframework.stereotype.Service;
|
||||
* @since 2020-07-03 11:20
|
||||
**/
|
||||
@Service
|
||||
public class OrderStatusHandlerExecute implements TradeEvent {
|
||||
public class OrderStatusHandlerExecute implements TradeEvent, AfterSaleStatusChangeEvent {
|
||||
|
||||
|
||||
@Autowired
|
||||
private TradeService tradeService;
|
||||
@Autowired
|
||||
private OrderItemService orderItemService;
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
|
||||
@Override
|
||||
public void orderCreate(TradeDTO tradeDTO) {
|
||||
@@ -28,4 +43,35 @@ public class OrderStatusHandlerExecute implements TradeEvent {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterSaleStatusChange(AfterSale afterSale) {
|
||||
Order order = orderService.getBySn(afterSale.getOrderSn());
|
||||
OrderItem orderItem = orderItemService.getBySn(afterSale.getOrderItemSn());
|
||||
|
||||
if (afterSale.getServiceStatus().equals(AfterSaleStatusEnum.COMPLETE.name())) {
|
||||
if (orderItem.getReturnGoodsNumber().equals(orderItem.getNum())) {
|
||||
orderItem.setIsRefund(RefundStatusEnum.ALL_REFUND.name());
|
||||
} else {
|
||||
orderItem.setIsRefund(RefundStatusEnum.PART_REFUND.name());
|
||||
}
|
||||
orderItem.setRefundPrice(CurrencyUtil.add(afterSale.getActualRefundPrice(), orderItem.getRefundPrice()));
|
||||
orderItemService.updateByAfterSale(orderItem);
|
||||
|
||||
//循环订单货物,判断是否已经全部售后
|
||||
List<OrderItem> orderItems = orderItemService.getByOrderSn(afterSale.getOrderSn());
|
||||
// 总退货数量
|
||||
int returnCount = 0;
|
||||
// 总购买数量
|
||||
int deliverCount = 0;
|
||||
for (OrderItem item : orderItems) {
|
||||
returnCount += item.getReturnGoodsNumber();
|
||||
deliverCount += item.getNum();
|
||||
}
|
||||
if (returnCount == deliverCount) {
|
||||
orderService.systemCancel(afterSale.getOrderSn(),"订单货物全部退款",false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import cn.lili.modules.order.order.entity.dto.OrderMessage;
|
||||
import cn.lili.modules.order.order.entity.enums.OrderStatusEnum;
|
||||
import cn.lili.modules.order.order.entity.enums.PayStatusEnum;
|
||||
import cn.lili.modules.order.order.service.OrderService;
|
||||
import cn.lili.modules.order.order.service.StoreFlowService;
|
||||
import cn.lili.modules.payment.entity.RefundLog;
|
||||
import cn.lili.modules.payment.kit.Payment;
|
||||
import cn.lili.modules.payment.entity.enums.PaymentMethodEnum;
|
||||
@@ -30,6 +31,8 @@ public class PaymentExecute implements OrderStatusChangeEvent {
|
||||
*/
|
||||
@Autowired
|
||||
private OrderService orderService;
|
||||
@Autowired
|
||||
private StoreFlowService storeFlowService;
|
||||
|
||||
@Override
|
||||
public void orderChange(OrderMessage orderMessage) {
|
||||
@@ -60,6 +63,8 @@ public class PaymentExecute implements OrderStatusChangeEvent {
|
||||
.refundReason("订单取消")
|
||||
.build();
|
||||
payment.refund(refundLog);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -95,7 +96,7 @@ public class StockUpdateExecute implements OrderStatusChangeEvent {
|
||||
keys.add(GoodsSkuService.getStockCacheKey(orderItem.getSkuId()));
|
||||
int i = -orderItem.getNum();
|
||||
values.add(Integer.toString(i));
|
||||
setPromotionStock(keys, values, orderItem);
|
||||
setPromotionStock(keys, values, orderItem, true);
|
||||
}
|
||||
|
||||
List<Integer> stocks = cache.multiGet(keys);
|
||||
@@ -133,6 +134,7 @@ public class StockUpdateExecute implements OrderStatusChangeEvent {
|
||||
keys.add(GoodsSkuService.getStockCacheKey(orderItem.getSkuId()));
|
||||
int i = orderItem.getNum();
|
||||
values.add(Integer.toString(i));
|
||||
setPromotionStock(keys, values, orderItem, false);
|
||||
}
|
||||
//批量脚本执行库存回退
|
||||
Boolean skuResult = stringRedisTemplate.execute(quantityScript, keys, values.toArray());
|
||||
@@ -189,28 +191,33 @@ public class StockUpdateExecute implements OrderStatusChangeEvent {
|
||||
//如果促销类型需要库存判定,则做对应处理
|
||||
orderItems.forEach(orderItem -> {
|
||||
if (orderItem.getPromotionType() != null) {
|
||||
//如果此促销有库存概念,则计入
|
||||
if (PromotionTypeEnum.haveStock(orderItem.getPromotionType())) {
|
||||
String[] skuPromotions = orderItem.getPromotionType().split(",");
|
||||
for (int i = 0; i < skuPromotions.length; i++) {
|
||||
int currentIndex = i;
|
||||
//如果此促销有库存概念,则计入
|
||||
Arrays.stream(PromotionTypeEnum.haveStockPromotion).filter(promotionTypeEnum -> promotionTypeEnum.name().equals(skuPromotions[currentIndex]))
|
||||
.findFirst()
|
||||
.ifPresent(promotionTypeEnum -> {
|
||||
String promotionId = orderItem.getPromotionId().split(",")[currentIndex];
|
||||
String cacheKey = PromotionGoodsService.getPromotionGoodsStockCacheKey(promotionTypeEnum, promotionId, orderItem.getSkuId());
|
||||
|
||||
PromotionTypeEnum promotionTypeEnum = PromotionTypeEnum.valueOf(orderItem.getPromotionType());
|
||||
|
||||
String cacheKey = PromotionGoodsService.getPromotionGoodsStockCacheKey(promotionTypeEnum, orderItem.getPromotionId(), orderItem.getSkuId());
|
||||
|
||||
switch (promotionTypeEnum) {
|
||||
case KANJIA:
|
||||
cache.put(cacheKey, kanjiaActivityGoodsService.getKanjiaGoodsBySkuId(orderItem.getSkuId()).getStock());
|
||||
return;
|
||||
case POINTS_GOODS:
|
||||
cache.put(cacheKey, pointsGoodsService.getPointsGoodsDetailBySkuId(orderItem.getSkuId()).getActiveStock());
|
||||
return;
|
||||
case SECKILL:
|
||||
case PINTUAN:
|
||||
cache.put(cacheKey, promotionGoodsService.getPromotionGoodsStock(promotionTypeEnum, orderItem.getPromotionId(), orderItem.getSkuId()));
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
switch (promotionTypeEnum) {
|
||||
case KANJIA:
|
||||
cache.put(cacheKey, kanjiaActivityGoodsService.getKanjiaGoodsBySkuId(orderItem.getSkuId()).getStock());
|
||||
return;
|
||||
case POINTS_GOODS:
|
||||
cache.put(cacheKey, pointsGoodsService.getPointsGoodsDetailBySkuId(orderItem.getSkuId()).getActiveStock());
|
||||
return;
|
||||
case SECKILL:
|
||||
case PINTUAN:
|
||||
cache.put(cacheKey, promotionGoodsService.getPromotionGoodsStock(promotionTypeEnum, promotionId, orderItem.getSkuId()));
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -222,7 +229,7 @@ public class StockUpdateExecute implements OrderStatusChangeEvent {
|
||||
* @param orderSn 失败入库订单信息
|
||||
*/
|
||||
private void errorOrder(String orderSn) {
|
||||
orderService.systemCancel(orderSn, outOfStockMessage);
|
||||
orderService.systemCancel(orderSn, outOfStockMessage, true);
|
||||
}
|
||||
|
||||
|
||||
@@ -233,16 +240,20 @@ public class StockUpdateExecute implements OrderStatusChangeEvent {
|
||||
* @param values 缓存value值
|
||||
* @param sku 购物车信息
|
||||
*/
|
||||
private void setPromotionStock(List<String> keys, List<String> values, OrderItem sku) {
|
||||
private void setPromotionStock(List<String> keys, List<String> values, OrderItem sku, boolean deduction) {
|
||||
if (sku.getPromotionType() != null) {
|
||||
//如果此促销有库存概念,则计入
|
||||
if (!PromotionTypeEnum.haveStock(sku.getPromotionType())) {
|
||||
return;
|
||||
String[] skuPromotions = sku.getPromotionType().split(",");
|
||||
for (int i = 0; i < skuPromotions.length; i++) {
|
||||
int currentIndex = i;
|
||||
Arrays.stream(PromotionTypeEnum.haveStockPromotion).filter(promotionTypeEnum -> promotionTypeEnum.name().equals(skuPromotions[currentIndex]))
|
||||
.findFirst()
|
||||
.ifPresent(promotionTypeEnum -> {
|
||||
keys.add(PromotionGoodsService.getPromotionGoodsStockCacheKey(promotionTypeEnum, sku.getPromotionId().split(",")[currentIndex], sku.getSkuId()));
|
||||
int num = deduction ? -sku.getNum() : sku.getNum();
|
||||
values.add(Integer.toString(num));
|
||||
});
|
||||
}
|
||||
PromotionTypeEnum promotionTypeEnum = PromotionTypeEnum.valueOf(sku.getPromotionType());
|
||||
keys.add(PromotionGoodsService.getPromotionGoodsStockCacheKey(promotionTypeEnum, sku.getPromotionId(), sku.getSkuId()));
|
||||
int i = -sku.getNum();
|
||||
values.add(Integer.toString(i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,41 +288,51 @@ public class StockUpdateExecute implements OrderStatusChangeEvent {
|
||||
goodsSku.setId(orderItem.getSkuId());
|
||||
goodsSku.setGoodsId(orderItem.getGoodsId());
|
||||
//如果有促销信息
|
||||
if (null != orderItem.getPromotionType() && null != orderItem.getPromotionId() && PromotionTypeEnum.haveStock(orderItem.getPromotionType())) {
|
||||
if (null != orderItem.getPromotionType() && null != orderItem.getPromotionId()) {
|
||||
//如果促销有库存信息
|
||||
PromotionTypeEnum promotionTypeEnum = PromotionTypeEnum.valueOf(orderItem.getPromotionType());
|
||||
String[] skuPromotions = orderItem.getPromotionType().split(",");
|
||||
for (int i = 0; i < skuPromotions.length; i++) {
|
||||
int currentIndex = i;
|
||||
Arrays.stream(PromotionTypeEnum.haveStockPromotion).filter(promotionTypeEnum -> promotionTypeEnum.name().equals(skuPromotions[currentIndex]))
|
||||
.findFirst()
|
||||
.ifPresent(promotionTypeEnum -> {
|
||||
//修改砍价商品库存
|
||||
String promotionId = orderItem.getPromotionId().split(",")[currentIndex];
|
||||
|
||||
//修改砍价商品库存
|
||||
if (promotionTypeEnum.equals(PromotionTypeEnum.KANJIA)) {
|
||||
KanjiaActivity kanjiaActivity = kanjiaActivityService.getById(orderItem.getPromotionId());
|
||||
KanjiaActivityGoodsDTO kanjiaActivityGoodsDTO = kanjiaActivityGoodsService.getKanjiaGoodsDetail(kanjiaActivity.getKanjiaActivityGoodsId());
|
||||
//修改砍价商品库存
|
||||
if (promotionTypeEnum.equals(PromotionTypeEnum.KANJIA)) {
|
||||
KanjiaActivity kanjiaActivity = kanjiaActivityService.getById(promotionId);
|
||||
KanjiaActivityGoodsDTO kanjiaActivityGoodsDTO = kanjiaActivityGoodsService.getKanjiaGoodsDetail(kanjiaActivity.getKanjiaActivityGoodsId());
|
||||
|
||||
Integer stock = Integer.parseInt(cache.get(PromotionGoodsService.getPromotionGoodsStockCacheKey(promotionTypeEnum, orderItem.getPromotionId(), orderItem.getSkuId())).toString());
|
||||
kanjiaActivityGoodsDTO.setStock(stock);
|
||||
Integer stock = Integer.parseInt(cache.get(PromotionGoodsService.getPromotionGoodsStockCacheKey(promotionTypeEnum, promotionId, orderItem.getSkuId())).toString());
|
||||
kanjiaActivityGoodsDTO.setStock(stock);
|
||||
|
||||
kanjiaActivityGoodsService.updateById(kanjiaActivityGoodsDTO);
|
||||
//修改积分商品库存
|
||||
} else if (promotionTypeEnum.equals(PromotionTypeEnum.POINTS_GOODS)) {
|
||||
PointsGoodsVO pointsGoodsVO = pointsGoodsService.getPointsGoodsDetail(orderItem.getPromotionId());
|
||||
Integer stock = Integer.parseInt(cache.get(PromotionGoodsService.getPromotionGoodsStockCacheKey(promotionTypeEnum, orderItem.getPromotionId(), orderItem.getSkuId())).toString());
|
||||
pointsGoodsVO.setActiveStock(stock);
|
||||
pointsGoodsService.updateById(pointsGoodsVO);
|
||||
} else {
|
||||
PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams();
|
||||
searchParams.setPromotionType(promotionTypeEnum.name());
|
||||
searchParams.setPromotionId(orderItem.getPromotionId());
|
||||
searchParams.setSkuId(orderItem.getSkuId());
|
||||
PromotionGoods pGoods = promotionGoodsService.getPromotionsGoods(searchParams);
|
||||
//记录需要更新的促销库存信息
|
||||
promotionKey.add(
|
||||
PromotionGoodsService.getPromotionGoodsStockCacheKey(
|
||||
promotionTypeEnum,
|
||||
orderItem.getPromotionId(), orderItem.getSkuId())
|
||||
);
|
||||
if (pGoods != null) {
|
||||
promotionGoods.add(pGoods);
|
||||
}
|
||||
kanjiaActivityGoodsService.updateById(kanjiaActivityGoodsDTO);
|
||||
//修改积分商品库存
|
||||
} else if (promotionTypeEnum.equals(PromotionTypeEnum.POINTS_GOODS)) {
|
||||
PointsGoodsVO pointsGoodsVO = pointsGoodsService.getPointsGoodsDetail(promotionId);
|
||||
Integer stock = Integer.parseInt(cache.get(PromotionGoodsService.getPromotionGoodsStockCacheKey(promotionTypeEnum, promotionId, orderItem.getSkuId())).toString());
|
||||
pointsGoodsVO.setActiveStock(stock);
|
||||
pointsGoodsService.updateById(pointsGoodsVO);
|
||||
} else {
|
||||
PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams();
|
||||
searchParams.setPromotionType(promotionTypeEnum.name());
|
||||
searchParams.setPromotionId(promotionId);
|
||||
searchParams.setSkuId(orderItem.getSkuId());
|
||||
PromotionGoods pGoods = promotionGoodsService.getPromotionsGoods(searchParams);
|
||||
//记录需要更新的促销库存信息
|
||||
promotionKey.add(
|
||||
PromotionGoodsService.getPromotionGoodsStockCacheKey(
|
||||
promotionTypeEnum,
|
||||
promotionId, orderItem.getSkuId())
|
||||
);
|
||||
if (pGoods != null) {
|
||||
promotionGoods.add(pGoods);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
goodsSkus.add(goodsSku);
|
||||
}
|
||||
@@ -322,8 +343,6 @@ public class StockUpdateExecute implements OrderStatusChangeEvent {
|
||||
for (int i = 0; i < skuStocks.size(); i++) {
|
||||
goodsSkus.get(i).setQuantity(Convert.toInt(skuStocks.get(i).toString()));
|
||||
}
|
||||
//批量修改商品库存
|
||||
goodsSkuService.updateBatchById(goodsSkus);
|
||||
|
||||
//促销库存处理
|
||||
if (!promotionKey.isEmpty()) {
|
||||
@@ -336,7 +355,7 @@ public class StockUpdateExecute implements OrderStatusChangeEvent {
|
||||
promotionGoodsService.updatePromotionGoodsStock(promotionGoods);
|
||||
}
|
||||
//商品库存,包含sku库存集合,批量更新商品库存相关
|
||||
goodsSkuService.updateGoodsStuck(goodsSkus);
|
||||
goodsSkuService.updateGoodsStock(goodsSkus);
|
||||
|
||||
log.info("订单确认,库存同步:商品信息--{};促销信息---{}", goodsSkus, promotionGoods);
|
||||
|
||||
@@ -353,6 +372,69 @@ public class StockUpdateExecute implements OrderStatusChangeEvent {
|
||||
List<GoodsSku> goodsSkus = new ArrayList<>();
|
||||
//sku库存key 集合
|
||||
List<String> skuKeys = new ArrayList<>();
|
||||
//促销商品
|
||||
List<PromotionGoods> promotionGoods = new ArrayList<>();
|
||||
//促销库存key 集合
|
||||
List<String> promotionKey = new ArrayList<>();
|
||||
|
||||
//循环订单
|
||||
for (OrderItem orderItem : order.getOrderItems()) {
|
||||
skuKeys.add(GoodsSkuService.getStockCacheKey(orderItem.getSkuId()));
|
||||
|
||||
GoodsSku goodsSku = new GoodsSku();
|
||||
goodsSku.setId(orderItem.getSkuId());
|
||||
goodsSku.setGoodsId(orderItem.getGoodsId());
|
||||
//如果有促销信息
|
||||
if (null != orderItem.getPromotionType() && null != orderItem.getPromotionId()) {
|
||||
|
||||
//如果促销有库存信息
|
||||
String[] skuPromotions = orderItem.getPromotionType().split(",");
|
||||
for (int i = 0; i < skuPromotions.length; i++) {
|
||||
int currentIndex = i;
|
||||
Arrays.stream(PromotionTypeEnum.haveStockPromotion).filter(promotionTypeEnum -> promotionTypeEnum.name().equals(skuPromotions[currentIndex]))
|
||||
.findFirst()
|
||||
.ifPresent(promotionTypeEnum -> {
|
||||
//修改砍价商品库存
|
||||
String promotionId = orderItem.getPromotionId().split(",")[currentIndex];
|
||||
//修改砍价商品库存
|
||||
if (promotionTypeEnum.equals(PromotionTypeEnum.KANJIA)) {
|
||||
KanjiaActivity kanjiaActivity = kanjiaActivityService.getById(promotionId);
|
||||
KanjiaActivityGoodsDTO kanjiaActivityGoodsDTO = kanjiaActivityGoodsService.getKanjiaGoodsDetail(kanjiaActivity.getKanjiaActivityGoodsId());
|
||||
|
||||
Integer stock = Integer.parseInt(cache.get(PromotionGoodsService.getPromotionGoodsStockCacheKey(promotionTypeEnum, promotionId, orderItem.getSkuId())).toString());
|
||||
kanjiaActivityGoodsDTO.setStock(stock);
|
||||
|
||||
kanjiaActivityGoodsService.updateById(kanjiaActivityGoodsDTO);
|
||||
//修改积分商品库存
|
||||
} else if (promotionTypeEnum.equals(PromotionTypeEnum.POINTS_GOODS)) {
|
||||
PointsGoodsVO pointsGoodsVO = pointsGoodsService.getPointsGoodsDetail(promotionId);
|
||||
Integer stock = Integer.parseInt(cache.get(PromotionGoodsService.getPromotionGoodsStockCacheKey(promotionTypeEnum, promotionId, orderItem.getSkuId())).toString());
|
||||
pointsGoodsVO.setActiveStock(stock);
|
||||
pointsGoodsService.updateById(pointsGoodsVO);
|
||||
} else {
|
||||
PromotionGoodsSearchParams searchParams = new PromotionGoodsSearchParams();
|
||||
searchParams.setPromotionType(promotionTypeEnum.name());
|
||||
searchParams.setPromotionId(promotionId);
|
||||
searchParams.setSkuId(orderItem.getSkuId());
|
||||
PromotionGoods pGoods = promotionGoodsService.getPromotionsGoods(searchParams);
|
||||
//记录需要更新的促销库存信息
|
||||
promotionKey.add(
|
||||
PromotionGoodsService.getPromotionGoodsStockCacheKey(
|
||||
promotionTypeEnum,
|
||||
promotionId, orderItem.getSkuId())
|
||||
);
|
||||
if (pGoods != null) {
|
||||
promotionGoods.add(pGoods);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
goodsSkus.add(goodsSku);
|
||||
}
|
||||
|
||||
//循环订单
|
||||
for (OrderItem orderItem : order.getOrderItems()) {
|
||||
skuKeys.add(GoodsSkuService.getStockCacheKey(orderItem.getSkuId()));
|
||||
@@ -367,10 +449,19 @@ public class StockUpdateExecute implements OrderStatusChangeEvent {
|
||||
for (int i = 0; i < skuStocks.size(); i++) {
|
||||
goodsSkus.get(i).setQuantity(Convert.toInt(skuStocks.get(i).toString()));
|
||||
}
|
||||
//促销库存处理
|
||||
if (!promotionKey.isEmpty()) {
|
||||
List promotionStocks = cache.multiGet(promotionKey);
|
||||
for (int i = 0; i < promotionKey.size(); i++) {
|
||||
promotionGoods.get(i).setQuantity(Convert.toInt(promotionStocks.get(i).toString()));
|
||||
Integer num = promotionGoods.get(i).getNum();
|
||||
promotionGoods.get(i).setNum((num != null ? num : 0) + order.getOrder().getGoodsNum());
|
||||
}
|
||||
promotionGoodsService.updatePromotionGoodsStock(promotionGoods);
|
||||
}
|
||||
log.info("订单取消,库存还原:{}", goodsSkus);
|
||||
//批量修改商品库存
|
||||
goodsSkuService.updateBatchById(goodsSkus);
|
||||
goodsSkuService.updateGoodsStuck(goodsSkus);
|
||||
goodsSkuService.updateGoodsStock(goodsSkus);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public class VerificationOrderExecute implements OrderStatusChangeEvent {
|
||||
//修改虚拟订单货物可以进行售后、投诉
|
||||
orderItemService.update(new LambdaUpdateWrapper<OrderItem>().eq(OrderItem::getOrderSn, orderMessage.getOrderSn())
|
||||
.set(OrderItem::getAfterSaleStatus, OrderItemAfterSaleStatusEnum.NOT_APPLIED)
|
||||
.set(OrderItem::getCommentStatus, OrderComplaintStatusEnum.NO_APPLY));
|
||||
.set(OrderItem::getComplainStatus, OrderComplaintStatusEnum.NO_APPLY));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package cn.lili.event.impl;
|
||||
|
||||
import cn.lili.event.OrderStatusChangeEvent;
|
||||
import cn.lili.modules.order.order.entity.dto.OrderMessage;
|
||||
import cn.lili.modules.wechat.service.WechatMPService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service ;
|
||||
|
||||
/**
|
||||
* 微信小程序执行器
|
||||
*
|
||||
* @author Chopper
|
||||
* @version v1.0 2021-04-19 14:25
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class WechatMPExecute implements OrderStatusChangeEvent {
|
||||
|
||||
@Autowired
|
||||
private WechatMPService wechatMPService;
|
||||
|
||||
|
||||
/**
|
||||
* 订单已发货、待提货、待核验状态 如果是微信小程序的订单则进行 订单发货信息录入
|
||||
*
|
||||
* @param orderMessage 订单消息
|
||||
*/
|
||||
@Override
|
||||
public void orderChange(OrderMessage orderMessage) {
|
||||
|
||||
switch (orderMessage.getNewStatus()) {
|
||||
case TAKE:
|
||||
case STAY_PICKED_UP:
|
||||
case DELIVERED:
|
||||
try {
|
||||
wechatMPService.uploadShippingInfo(orderMessage.getOrderSn());
|
||||
} catch (Exception e) {
|
||||
log.error("发货信息录入失败", e);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -292,6 +292,9 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
searchParams.setCategoryPath(promotions.getScopeId());
|
||||
searchParams.setPageNumber(i);
|
||||
searchParams.setPageSize(BATCH_SIZE);
|
||||
if (CharSequenceUtil.isNotEmpty(promotions.getStoreId()) && !"0".equals(promotions.getStoreId())){
|
||||
searchParams.setStoreId(promotions.getStoreId());
|
||||
}
|
||||
IPage<GoodsSku> goodsSkuByPage = this.goodsSkuService.getGoodsSkuByPage(searchParams);
|
||||
if (goodsSkuByPage == null || goodsSkuByPage.getRecords().isEmpty()) {
|
||||
break;
|
||||
@@ -492,7 +495,7 @@ public class GoodsMessageListener implements RocketMQListener<MessageExt> {
|
||||
}
|
||||
int buyCount = goodsSku.getBuyCount() + goodsCompleteMessage.getBuyNum();
|
||||
goodsSku.setBuyCount(buyCount);
|
||||
goodsSkuService.update(goodsSku);
|
||||
goodsSkuService.updateGoodsSkuBuyCount(goodsSku.getId(), buyCount);
|
||||
|
||||
this.goodsIndexService.updateIndex(MapUtil.builder(new HashMap<String, Object>()).put("id", goodsCompleteMessage.getSkuId()).build(), MapUtil.builder(new HashMap<String, Object>()).put("buyCount", buyCount).build());
|
||||
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
package cn.lili.timetask.handler.impl.bill;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.lili.modules.store.entity.dto.StoreSettlementDay;
|
||||
import cn.lili.modules.store.service.BillService;
|
||||
import cn.lili.modules.store.service.StoreDetailService;
|
||||
import cn.lili.timetask.handler.EveryDayExecute;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 店铺结算执行
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @since 2021/2/18 3:45 下午
|
||||
*/
|
||||
@Component
|
||||
public class BillExecute implements EveryDayExecute {
|
||||
|
||||
/**
|
||||
* 结算单
|
||||
*/
|
||||
@Autowired
|
||||
private BillService billService;
|
||||
/**
|
||||
* 店铺详情
|
||||
*/
|
||||
@Autowired
|
||||
private StoreDetailService storeDetailService;
|
||||
|
||||
/**
|
||||
* 1.查询今日待结算的商家
|
||||
* 2.查询商家上次结算日期,生成本次结算单
|
||||
* 3.记录商家结算日
|
||||
*/
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
//获取当前天数
|
||||
int day = DateUtil.date().dayOfMonth();
|
||||
|
||||
//获取待结算商家列表
|
||||
List<StoreSettlementDay> storeList = storeDetailService.getSettlementStore(day);
|
||||
|
||||
//获取当前时间
|
||||
DateTime endTime = DateUtil.date();
|
||||
//批量商家结算
|
||||
for (StoreSettlementDay storeSettlementDay : storeList) {
|
||||
|
||||
//生成结算单
|
||||
billService.createBill(storeSettlementDay.getStoreId(), storeSettlementDay.getSettlementDay(), endTime);
|
||||
|
||||
//修改店铺结算时间
|
||||
storeDetailService.updateSettlementDay(storeSettlementDay.getStoreId(), endTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,7 +54,7 @@ public class CancelOrderTaskExecute implements EveryMinuteExecute {
|
||||
List<Order> list = orderService.list(queryWrapper);
|
||||
List<String> cancelSnList = list.stream().map(Order::getSn).collect(Collectors.toList());
|
||||
for (String sn : cancelSnList) {
|
||||
orderService.systemCancel(sn, "超时未支付自动取消");
|
||||
orderService.systemCancel(sn, "超时未支付自动取消",false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,10 @@ import cn.lili.modules.order.order.entity.enums.OrderItemAfterSaleStatusEnum;
|
||||
import cn.lili.modules.order.order.entity.enums.OrderStatusEnum;
|
||||
import cn.lili.modules.order.order.service.OrderItemService;
|
||||
import cn.lili.modules.order.order.service.OrderService;
|
||||
import cn.lili.modules.order.order.service.StoreFlowService;
|
||||
import cn.lili.modules.store.entity.dto.StoreSettlementDay;
|
||||
import cn.lili.modules.store.service.BillService;
|
||||
import cn.lili.modules.store.service.StoreDetailService;
|
||||
import cn.lili.modules.system.entity.dos.Setting;
|
||||
import cn.lili.modules.system.entity.dto.OrderSetting;
|
||||
import cn.lili.modules.system.entity.enums.SettingEnum;
|
||||
@@ -25,12 +29,13 @@ import cn.lili.modules.system.service.SettingService;
|
||||
import cn.lili.timetask.handler.EveryDayExecute;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.messaging.handler.annotation.SendTo;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* @author paulG
|
||||
@@ -65,6 +70,20 @@ public class OrderEveryDayTaskExecute implements EveryDayExecute {
|
||||
@Autowired
|
||||
private DistributionOrderService distributionOrderService;
|
||||
|
||||
@Autowired
|
||||
private StoreFlowService storeFlowService;
|
||||
|
||||
/**
|
||||
* 结算单
|
||||
*/
|
||||
@Autowired
|
||||
private BillService billService;
|
||||
/**
|
||||
* 店铺详情
|
||||
*/
|
||||
@Autowired
|
||||
private StoreDetailService storeDetailService;
|
||||
|
||||
/**
|
||||
* 执行每日任务
|
||||
*/
|
||||
@@ -92,7 +111,7 @@ public class OrderEveryDayTaskExecute implements EveryDayExecute {
|
||||
}
|
||||
try {
|
||||
//关闭允许售后申请
|
||||
closeAfterSale(orderSetting);
|
||||
this.closeAfterSale(orderSetting);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
@@ -102,6 +121,22 @@ public class OrderEveryDayTaskExecute implements EveryDayExecute {
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
//修改分账状态
|
||||
try {
|
||||
storeFlowService.updateProfitSharingStatus();
|
||||
} catch (Exception e) {
|
||||
log.error("修改分账状态失败", e);
|
||||
}
|
||||
|
||||
//生成店铺结算单
|
||||
try {
|
||||
createBill();
|
||||
} catch (Exception e) {
|
||||
log.error("生成店铺结算单", e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,7 +146,6 @@ public class OrderEveryDayTaskExecute implements EveryDayExecute {
|
||||
*/
|
||||
private void completedOrder(OrderSetting orderSetting) {
|
||||
|
||||
|
||||
//订单自动收货时间 = 当前时间 - 自动收货时间天数
|
||||
DateTime receiveTime = DateUtil.offsetDay(DateUtil.date(), -orderSetting.getAutoReceive());
|
||||
LambdaQueryWrapper<Order> queryWrapper = new LambdaQueryWrapper<>();
|
||||
@@ -144,7 +178,9 @@ public class OrderEveryDayTaskExecute implements EveryDayExecute {
|
||||
DateTime receiveTime = DateUtil.offsetDay(DateUtil.date(), -orderSetting.getAutoEvaluation());
|
||||
|
||||
//订单完成时间 <= 订单自动好评时间
|
||||
OrderItemOperationDTO orderItemOperationDTO = OrderItemOperationDTO.builder().receiveTime(receiveTime).commentStatus(CommentStatusEnum.UNFINISHED.name()).build();
|
||||
OrderItemOperationDTO orderItemOperationDTO =
|
||||
OrderItemOperationDTO.builder().receiveTime(receiveTime).commentStatus(CommentStatusEnum.UNFINISHED.name())
|
||||
.build();
|
||||
List<OrderItem> orderItems = orderItemService.waitOperationOrderItem(orderItemOperationDTO);
|
||||
|
||||
//判断是否有符合条件的订单,进行自动评价处理
|
||||
@@ -170,45 +206,21 @@ public class OrderEveryDayTaskExecute implements EveryDayExecute {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 关闭允许售后申请
|
||||
*
|
||||
* @param orderSetting 订单设置
|
||||
*/
|
||||
private void closeAfterSale(OrderSetting orderSetting) {
|
||||
//为0则不限制
|
||||
if (orderSetting.getCloseAfterSale() == null || orderSetting.getCloseAfterSale() == 0) {
|
||||
return;
|
||||
}
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void closeAfterSale(OrderSetting orderSetting) {
|
||||
//订单关闭售后申请时间 = 当前时间 - 自动关闭售后申请天数
|
||||
DateTime receiveTime = DateUtil.offsetDay(DateUtil.date(), -orderSetting.getCloseAfterSale());
|
||||
|
||||
// OrderItemOperationDTO build = OrderItemOperationDTO.builder().receiveTime(receiveTime)
|
||||
// .afterSaleStatus(OrderItemAfterSaleStatusEnum.NOT_APPLIED.name()).build();
|
||||
// List<OrderItem> orderItems = orderItemService.waitOperationOrderItem(build);
|
||||
//关闭售后订单=未售后订单+小于订单关闭售后申请时间
|
||||
OrderItemOperationDTO build = OrderItemOperationDTO.builder().receiveTime(receiveTime).afterSaleStatus(OrderItemAfterSaleStatusEnum.NOT_APPLIED.name()).build();
|
||||
List<OrderItem> orderItems = orderItemService.waitOperationOrderItem(build);
|
||||
|
||||
//判断是否有符合条件的订单,关闭允许售后申请处理
|
||||
if (!orderItems.isEmpty()) {
|
||||
|
||||
//获取订单货物ID
|
||||
List<String> orderItemIdList = orderItems.stream().map(OrderItem::getId).collect(Collectors.toList());
|
||||
|
||||
//修改订单售后状态
|
||||
LambdaUpdateWrapper<OrderItem> lambdaUpdateWrapper = new LambdaUpdateWrapper<OrderItem>()
|
||||
.set(OrderItem::getAfterSaleStatus, OrderItemAfterSaleStatusEnum.EXPIRED.name())
|
||||
.in(OrderItem::getId, orderItemIdList);
|
||||
orderItemService.update(lambdaUpdateWrapper);
|
||||
//修改订售后状态
|
||||
List<OrderItem> orderItemsList = orderItems.stream()
|
||||
.map((orderItem) -> {
|
||||
orderItem.setAfterSaleStatus(OrderItemAfterSaleStatusEnum.EXPIRED.name());
|
||||
return orderItem;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
//修改对应分销订单状态
|
||||
distributionOrderService.updateDistributionOrderStatus(orderItemsList);
|
||||
}
|
||||
orderItemService.expiredAfterSaleStatus(receiveTime);
|
||||
|
||||
}
|
||||
|
||||
@@ -227,7 +239,8 @@ public class OrderEveryDayTaskExecute implements EveryDayExecute {
|
||||
DateTime receiveTime = DateUtil.offsetDay(DateUtil.date(), -orderSetting.getCloseComplaint());
|
||||
|
||||
//关闭售后订单=未售后订单+小于订单关闭售后申请时间
|
||||
OrderItemOperationDTO build = OrderItemOperationDTO.builder().receiveTime(receiveTime).complainStatus(OrderComplaintStatusEnum.NO_APPLY.name()).build();
|
||||
OrderItemOperationDTO build = OrderItemOperationDTO.builder().receiveTime(receiveTime)
|
||||
.complainStatus(OrderComplaintStatusEnum.NO_APPLY.name()).build();
|
||||
List<OrderItem> orderItems = orderItemService.waitOperationOrderItem(build);
|
||||
|
||||
//判断是否有符合条件的订单,关闭允许售后申请处理
|
||||
@@ -237,12 +250,37 @@ public class OrderEveryDayTaskExecute implements EveryDayExecute {
|
||||
List<String> orderItemIdList = orderItems.stream().map(OrderItem::getId).collect(Collectors.toList());
|
||||
|
||||
//修改订单投诉状态
|
||||
LambdaUpdateWrapper<OrderItem> lambdaUpdateWrapper = new LambdaUpdateWrapper<OrderItem>()
|
||||
.set(OrderItem::getComplainStatus, OrderItemAfterSaleStatusEnum.EXPIRED.name())
|
||||
.in(OrderItem::getId, orderItemIdList);
|
||||
LambdaUpdateWrapper<OrderItem> lambdaUpdateWrapper =
|
||||
new LambdaUpdateWrapper<OrderItem>().set(OrderItem::getComplainStatus,
|
||||
OrderItemAfterSaleStatusEnum.EXPIRED.name()).in(OrderItem::getId, orderItemIdList);
|
||||
orderItemService.update(lambdaUpdateWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 1.查询今日待结算的商家
|
||||
* 2.查询商家上次结算日期,生成本次结算单
|
||||
* 3.记录商家结算日
|
||||
*/
|
||||
private void createBill() {
|
||||
//获取当前天数
|
||||
int day = DateUtil.date().dayOfMonth();
|
||||
|
||||
//获取待结算商家列表
|
||||
List<StoreSettlementDay> storeList = storeDetailService.getSettlementStore(day);
|
||||
|
||||
//获取当前时间
|
||||
DateTime endTime = DateUtil.date();
|
||||
//批量商家结算
|
||||
for (StoreSettlementDay storeSettlementDay : storeList) {
|
||||
|
||||
//生成结算单
|
||||
billService.createBill(storeSettlementDay.getStoreId(), storeSettlementDay.getSettlementDay(), endTime);
|
||||
|
||||
//修改店铺结算时间
|
||||
storeDetailService.updateSettlementDay(storeSettlementDay.getStoreId(), endTime);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -72,6 +72,7 @@ public class PromotionEverydayExecute implements EveryDayExecute {
|
||||
log.info("生成秒杀活动设置:{}", seckillSetting);
|
||||
for (int i = 1; i <= SeckillService.PRE_CREATION; i++) {
|
||||
Seckill seckill = new Seckill(i, seckillSetting.getHours(), seckillSetting.getSeckillRule());
|
||||
seckill.setApplyEndTime(null);
|
||||
|
||||
//如果已经存在促销,则不再次保存
|
||||
if (seckillService.list(
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package cn.lili.trigger.executor;
|
||||
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.modules.promotion.service.CouponActivityService;
|
||||
import cn.lili.trigger.TimeTriggerExecutor;
|
||||
import cn.lili.trigger.message.CouponActivityMessage;
|
||||
import cn.lili.trigger.model.TimeExecuteConstant;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 优惠券活动精准发圈延时触发
|
||||
*
|
||||
* @author Bulbasaur
|
||||
* @since 2021/6/1 5:02 下午
|
||||
*/
|
||||
@Slf4j
|
||||
@Component(TimeExecuteConstant.COUPON_ACTIVITY_EXECUTOR)
|
||||
public class CouponActivityTriggerExecutor implements TimeTriggerExecutor {
|
||||
|
||||
|
||||
@Autowired
|
||||
private CouponActivityService couponActivityService;
|
||||
|
||||
@Override
|
||||
public void execute(Object object) {
|
||||
CouponActivityMessage couponActivityMessage = JSONUtil.toBean(JSONUtil.parseObj(object), CouponActivityMessage.class);
|
||||
couponActivityService.specifyCoupon(couponActivityMessage.getCouponActivityId());
|
||||
}
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
package cn.lili.buyer.test.cart;
|
||||
|
||||
import cn.lili.common.utils.DateUtil;
|
||||
import cn.lili.timetask.handler.impl.statistics.OnlineMemberStatistics;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Random;
|
||||
|
||||
/**
|
||||
* 订单库存扣减
|
||||
*/
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest
|
||||
class OnlineTest {
|
||||
|
||||
@Autowired
|
||||
private OnlineMemberStatistics onlineMemberStatistics;
|
||||
|
||||
//订单支付,库存扣减单元测试
|
||||
@Test
|
||||
void everyHour() {
|
||||
onlineMemberStatistics.execute();
|
||||
}
|
||||
|
||||
//订单支付,库存扣减单元测试
|
||||
@Test
|
||||
void customSetting() {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) - 48 );
|
||||
//循环填充数据
|
||||
for (int i = 0; i < 48; i++) {
|
||||
calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) + 1);
|
||||
System.out.println(DateUtil.toString(calendar.getTime(),""));
|
||||
Random random = new Random();
|
||||
onlineMemberStatistics.execute(calendar.getTime(), random.nextInt(1000000));
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
calendar.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) - 48 - 1);
|
||||
//循环填充数据
|
||||
for (int i = 0; i < 48; i++) {
|
||||
calendar.set(Calendar.HOUR_OF_DAY, calendar.get(Calendar.HOUR_OF_DAY) + 1);
|
||||
System.out.println(calendar.getTime().getTime());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,6 +1,11 @@
|
||||
package cn.lili.common.enums;
|
||||
|
||||
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.EnumSet;
|
||||
|
||||
/**
|
||||
* 促销分类枚举
|
||||
*
|
||||
@@ -23,7 +28,12 @@ public enum PromotionTypeEnum {
|
||||
/**
|
||||
* 有促销库存的活动类型
|
||||
*/
|
||||
static final PromotionTypeEnum[] haveStockPromotion = new PromotionTypeEnum[]{PINTUAN, SECKILL, KANJIA, POINTS_GOODS};
|
||||
public static final PromotionTypeEnum[] haveStockPromotion = new PromotionTypeEnum[]{PINTUAN, SECKILL, KANJIA, POINTS_GOODS};
|
||||
|
||||
/**
|
||||
* 有独立促销库存的活动类型
|
||||
*/
|
||||
public static final PromotionTypeEnum[] haveIndependanceStockPromotion = new PromotionTypeEnum[]{SECKILL};
|
||||
|
||||
private final String description;
|
||||
|
||||
@@ -47,4 +57,28 @@ public enum PromotionTypeEnum {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断促销类型是否有效
|
||||
* @param typeEnumValue
|
||||
* @return
|
||||
*/
|
||||
public static boolean isValid(String typeEnumValue) {
|
||||
if (StringUtils.isBlank(typeEnumValue)) {
|
||||
return false;
|
||||
}
|
||||
return Arrays.stream(PromotionTypeEnum.values()).anyMatch(c -> c.name().equals(typeEnumValue));
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断订单类型是否可售后
|
||||
* POINTS\KANJIA 两种促销类型的订单不可进行售后
|
||||
* @return true 可售后 false 不可售后
|
||||
*/
|
||||
public static boolean isCanAfterSale(String promotionType) {
|
||||
if (!isValid(promotionType)) {
|
||||
return true;
|
||||
}
|
||||
EnumSet<PromotionTypeEnum> noAfterSale = EnumSet.of(PromotionTypeEnum.KANJIA, PromotionTypeEnum.POINTS_GOODS);
|
||||
return !noAfterSale.contains(PromotionTypeEnum.valueOf(promotionType));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,6 +42,7 @@ public enum ResultCode {
|
||||
PLATFORM_NOT_SUPPORTED_IM(1006, "平台未开启IM"),
|
||||
STORE_NOT_SUPPORTED_IM(1007, "店铺未开启IM"),
|
||||
UNINITIALIZED_PASSWORD(1008, "非初始化密码,无法进行初始化设置"),
|
||||
FILE_DIRECTORY_NOT_EMPTY(1012, "文件夹下有文件,请删除所有文件后删除文件夹!"),
|
||||
/**
|
||||
* 分类
|
||||
*/
|
||||
@@ -89,6 +90,7 @@ public enum ResultCode {
|
||||
VIRTUAL_GOODS_NOT_NEED_TEMP(11015, "虚拟商品无需选择配送模板"),
|
||||
GOODS_NOT_EXIST_STORE(11017, "当前用户无权操作此商品"),
|
||||
GOODS_TYPE_ERROR(11016, "需选择商品类型"),
|
||||
GOODS_STOCK_IMPORT_ERROR(11018, "导入商品库存失败,请检查表格数据"),
|
||||
|
||||
/**
|
||||
* 参数
|
||||
@@ -150,6 +152,7 @@ public enum ResultCode {
|
||||
CLERK_DISABLED_ERROR(20031, "店员已禁用"),
|
||||
CLERK_CURRENT_SUPPER(20032, "无法删除当前登录店员"),
|
||||
CANT_EDIT_CLERK_SHOPKEEPER(20033, "无法在店员管理编辑店员信息"),
|
||||
USER_MOBILE_REPEATABLE_ERROR(20034, "该手机号已存在"),
|
||||
/**
|
||||
* 权限
|
||||
*/
|
||||
@@ -173,6 +176,7 @@ public enum ResultCode {
|
||||
DISTRIBUTION_RETREAT_ERROR(22004, "分销员清退失败"),
|
||||
DISTRIBUTION_CASH_NOT_EXIST(22005, "分销员提现记录不存在"),
|
||||
DISTRIBUTION_GOODS_DOUBLE(22006, "不能重复添加分销商品"),
|
||||
DISTRIBUTION_EDIT_ERROR(22007, "修改分销员失败"),
|
||||
|
||||
/**
|
||||
* 购物车
|
||||
@@ -205,6 +209,7 @@ public enum ResultCode {
|
||||
POINT_NOT_ENOUGH(31015, "当前会员积分不足购买当前积分商品!"),
|
||||
ORDER_LABEL_ORDER_ERROR(31016, "订单不能打印电子面单"),
|
||||
ORDER_PRICE_ERROR(31017,"订单金额不能小于等于0"),
|
||||
ORDER_PACKAGE_NOT_EXIST(31017, "当前订单包裹不存在!"),
|
||||
|
||||
|
||||
/**
|
||||
@@ -418,7 +423,7 @@ public enum ResultCode {
|
||||
STORE_CLOSE_ERROR(50006, "店铺关闭,请联系管理员"),
|
||||
STORE_DELIVER_GOODS_ADDRESS(50007,"请填写商家发货地址"),
|
||||
FREIGHT_TEMPLATE_NOT_EXIST(50010, "当前模版不存在"),
|
||||
STORE_STATUS_ERROR(50011, "店铺状态异常,无法申请"),
|
||||
STORE_STATUS_ERROR(50011, "店铺在申请中或审核中,请勿重复操作"),
|
||||
STORE_DELIVER_ADDRESS_EXIST(50012,"请填写发货地址"),
|
||||
|
||||
/**
|
||||
@@ -459,6 +464,7 @@ public enum ResultCode {
|
||||
ORDER_SETTING_ERROR(70006, "系统订单配置异常"),
|
||||
ALI_SMS_SETTING_ERROR(70007, "您还未配置阿里云短信"),
|
||||
SMS_SIGN_EXIST_ERROR(70008, "短信签名已存在"),
|
||||
DELIVERY_SETTING_ERROR(70009, "请配置发货参数"),
|
||||
|
||||
/**
|
||||
* 站内信
|
||||
@@ -495,6 +501,9 @@ public enum ResultCode {
|
||||
WECHAT_MP_MESSAGE_TMPL_ERROR(80306, "未能获取到微信模版消息id"),
|
||||
WECHAT_ERROR(80307, "微信接口异常"),
|
||||
APP_VERSION_EXIST(80307, "APP版本已存在"),
|
||||
APP_VERSION_PARAM_ERROR(80308, "添加APP版本参数异常"),
|
||||
// 未选择APP类型
|
||||
APP_VERSION_TYPE_ERROR(80308, "请选择有效的APP类型"),
|
||||
|
||||
/**
|
||||
* IM
|
||||
|
||||
@@ -14,23 +14,23 @@ import org.springframework.context.annotation.Configuration;
|
||||
public class ApiProperties {
|
||||
|
||||
|
||||
/**
|
||||
* 买家api
|
||||
*/
|
||||
private String buyer;
|
||||
// /**
|
||||
// * 买家api
|
||||
// */
|
||||
// private String buyer;
|
||||
|
||||
/**
|
||||
* 管理端域名
|
||||
*/
|
||||
private String store;
|
||||
|
||||
/**
|
||||
* 管理端域名
|
||||
*/
|
||||
private String manager;
|
||||
|
||||
/**
|
||||
* 管理端域名
|
||||
*/
|
||||
private String common;
|
||||
// /**
|
||||
// * 管理端域名
|
||||
// */
|
||||
// private String store;
|
||||
//
|
||||
// /**
|
||||
// * 管理端域名
|
||||
// */
|
||||
// private String manager;
|
||||
//
|
||||
// /**
|
||||
// * 管理端域名
|
||||
// */
|
||||
// private String common;
|
||||
}
|
||||
|
||||
@@ -34,4 +34,11 @@ public class CommonUtil {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取特定字符 + 6位随机数
|
||||
* @return
|
||||
*/
|
||||
public static String getSpecialStr(String value) {
|
||||
return value + getRandomNum();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,8 @@ public class ThreadPoolUtil {
|
||||
* 线程缓冲队列
|
||||
*/
|
||||
private static final BlockingQueue<Runnable> BQUEUE = new ArrayBlockingQueue<Runnable>(100);
|
||||
private static final ThreadPoolExecutor POOL = new ThreadPoolExecutor(SIZE_CORE_POOL, SIZE_MAX_POOL, ALIVE_TIME, TimeUnit.MILLISECONDS, BQUEUE, new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
private static final ThreadPoolExecutor POOL = new ThreadPoolExecutor(SIZE_CORE_POOL, SIZE_MAX_POOL, ALIVE_TIME, TimeUnit.MILLISECONDS, BQUEUE,
|
||||
new ThreadPoolExecutor.CallerRunsPolicy());
|
||||
/**
|
||||
* volatile禁止指令重排
|
||||
*/
|
||||
@@ -34,7 +35,7 @@ public class ThreadPoolUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 无返回值直接执行, 管他娘的
|
||||
* 执行方法
|
||||
*
|
||||
* @param runnable
|
||||
*/
|
||||
@@ -43,7 +44,7 @@ public class ThreadPoolUtil {
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回值直接执行, 管他娘的
|
||||
* 提交返回值
|
||||
*
|
||||
* @param callable
|
||||
*/
|
||||
|
||||
@@ -5,7 +5,6 @@ import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.cache.Cache;
|
||||
import cn.lili.cache.CachePrefix;
|
||||
import cn.lili.common.enums.ClientTypeEnum;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
@@ -125,24 +124,18 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
|
||||
@Transactional
|
||||
public Token miniProgramAutoLogin(WechatMPLoginParams params) {
|
||||
|
||||
Object cacheData = cache.get(CachePrefix.WECHAT_SESSION_PARAMS.getPrefix() + params.getUuid());
|
||||
Map<String, String> map = new HashMap<>(3);
|
||||
if (cacheData == null) {
|
||||
//得到微信小程序联合登陆信息
|
||||
JSONObject json = this.getConnect(params.getCode());
|
||||
//存储session key 后续登录用得到
|
||||
String sessionKey = json.getStr("session_key");
|
||||
String unionId = json.getStr("unionid");
|
||||
String openId = json.getStr("openid");
|
||||
map.put("sessionKey", sessionKey);
|
||||
map.put("unionId", unionId);
|
||||
map.put("openId", openId);
|
||||
cache.put(CachePrefix.WECHAT_SESSION_PARAMS.getPrefix() + params.getUuid(), map, 900L);
|
||||
} else {
|
||||
map = (Map<String, String>) cacheData;
|
||||
}
|
||||
//微信联合登陆参数
|
||||
//得到微信小程序联合登陆信息
|
||||
JSONObject json = this.getConnect(params.getCode());
|
||||
//存储session key 后续登录用得到
|
||||
String sessionKey = json.getStr("session_key");
|
||||
String unionId = json.getStr("unionid");
|
||||
String openId = json.getStr("openid");
|
||||
map.put("sessionKey", sessionKey);
|
||||
map.put("unionId", unionId);
|
||||
map.put("openId", openId);
|
||||
|
||||
//微信联合登陆参数
|
||||
return phoneMpBindAndLogin(map.get("sessionKey"), params, map.get("openId"), map.get("unionId"));
|
||||
}
|
||||
|
||||
@@ -217,7 +210,7 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
|
||||
connectQueryDTO.getUnionType())
|
||||
.eq(CharSequenceUtil.isNotEmpty(connectQueryDTO.getUnionId()), Connect::getUnionId,
|
||||
connectQueryDTO.getUnionId());
|
||||
return this.getOne(queryWrapper,false);
|
||||
return this.getOne(queryWrapper, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -267,13 +260,13 @@ public class ConnectServiceImpl extends ServiceImpl<ConnectMapper, Connect> impl
|
||||
private Token unionLoginCallback(ConnectAuthUser authUser, boolean longTerm) {
|
||||
|
||||
try {
|
||||
Member member =null;
|
||||
Member member = null;
|
||||
//判断是否传递手机号,如果传递手机号则使用手机号登录
|
||||
if(StrUtil.isNotBlank(authUser.getPhone())){
|
||||
if (StrUtil.isNotBlank(authUser.getPhone())) {
|
||||
member = memberService.findByMobile(authUser.getPhone());
|
||||
}
|
||||
//如果未查到手机号的会员则使用第三方登录
|
||||
if(member==null){
|
||||
if (member == null) {
|
||||
LambdaQueryWrapper<Connect> queryWrapper = new LambdaQueryWrapper<Connect>();
|
||||
//使用UnionId登录
|
||||
if (authUser.getToken() != null && StrUtil.isNotBlank(authUser.getToken().getUnionId())) {
|
||||
|
||||
@@ -23,6 +23,7 @@ import cn.lili.modules.connect.request.BaseAuthWeChatPCRequest;
|
||||
import cn.lili.modules.connect.request.BaseAuthWeChatRequest;
|
||||
import cn.lili.modules.connect.service.ConnectService;
|
||||
import cn.lili.modules.system.entity.dos.Setting;
|
||||
import cn.lili.modules.system.entity.dto.connect.ConnectSetting;
|
||||
import cn.lili.modules.system.entity.dto.connect.QQConnectSetting;
|
||||
import cn.lili.modules.system.entity.dto.connect.WechatConnectSetting;
|
||||
import cn.lili.modules.system.entity.dto.connect.dto.QQConnectSettingItem;
|
||||
@@ -70,8 +71,8 @@ public class ConnectUtil {
|
||||
* @param connectAuthEnum 用户枚举
|
||||
* @return 回调地址
|
||||
*/
|
||||
String getRedirectUri(ConnectAuthEnum connectAuthEnum) {
|
||||
return apiProperties.getBuyer() + prefix + connectAuthEnum.getName();
|
||||
String getRedirectUri(ConnectAuthEnum connectAuthEnum,String callbackUrl) {
|
||||
return callbackUrl + prefix + connectAuthEnum.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -106,10 +107,13 @@ public class ConnectUtil {
|
||||
//缓存写入登录结果,300秒有效
|
||||
cache.put(CachePrefix.CONNECT_RESULT.getPrefix() + callback.getCode(), resultMessage, 300L);
|
||||
|
||||
//登录设置
|
||||
ConnectSetting connectSetting = JSONUtil.toBean(settingService.get(SettingEnum.CONNECT_SETTING.name()).getSettingValue(), ConnectSetting.class);
|
||||
|
||||
//跳转地址
|
||||
String url = this.check(httpServletRequest.getHeader("user-agent")) ?
|
||||
domainProperties.getWap() + "/pages/passport/login?state=" + callback.getCode() :
|
||||
domainProperties.getPc() + "/login?state=" + callback.getCode();
|
||||
connectSetting.getWap() + "/pages/passport/login?state=" + callback.getCode() :
|
||||
connectSetting.getPc() + "/login?state=" + callback.getCode();
|
||||
|
||||
try {
|
||||
httpServletResponse.sendRedirect(url);
|
||||
@@ -151,13 +155,15 @@ public class ConnectUtil {
|
||||
//寻找配置
|
||||
Setting setting = settingService.get(SettingEnum.WECHAT_CONNECT.name());
|
||||
WechatConnectSetting wechatConnectSetting = JSONUtil.toBean(setting.getSettingValue(), WechatConnectSetting.class);
|
||||
//登录设置
|
||||
ConnectSetting connectSetting = JSONUtil.toBean(settingService.get(SettingEnum.CONNECT_SETTING.name()).getSettingValue(), ConnectSetting.class);
|
||||
|
||||
for (WechatConnectSettingItem wechatConnectSettingItem : wechatConnectSetting.getWechatConnectSettingItems()) {
|
||||
if (wechatConnectSettingItem.getClientType().equals(ClientTypeEnum.H5.name())) {
|
||||
authRequest = new BaseAuthWeChatRequest(AuthConfig.builder()
|
||||
.clientId(wechatConnectSettingItem.getAppId())
|
||||
.clientSecret(wechatConnectSettingItem.getAppSecret())
|
||||
.redirectUri(getRedirectUri(authInterface))
|
||||
.redirectUri(getRedirectUri(authInterface, connectSetting.getCallbackUrl()))
|
||||
.build(), cache);
|
||||
}
|
||||
}
|
||||
@@ -167,13 +173,14 @@ public class ConnectUtil {
|
||||
//寻找配置
|
||||
Setting setting = settingService.get(SettingEnum.WECHAT_CONNECT.name());
|
||||
WechatConnectSetting wechatConnectSetting = JSONUtil.toBean(setting.getSettingValue(), WechatConnectSetting.class);
|
||||
|
||||
//登录设置
|
||||
ConnectSetting connectSetting = JSONUtil.toBean(settingService.get(SettingEnum.CONNECT_SETTING.name()).getSettingValue(), ConnectSetting.class);
|
||||
for (WechatConnectSettingItem wechatConnectSettingItem : wechatConnectSetting.getWechatConnectSettingItems()) {
|
||||
if (wechatConnectSettingItem.getClientType().equals(ClientTypeEnum.PC.name())) {
|
||||
authRequest = new BaseAuthWeChatPCRequest(AuthConfig.builder()
|
||||
.clientId(wechatConnectSettingItem.getAppId())
|
||||
.clientSecret(wechatConnectSettingItem.getAppSecret())
|
||||
.redirectUri(getRedirectUri(authInterface))
|
||||
.redirectUri(getRedirectUri(authInterface, connectSetting.getCallbackUrl()))
|
||||
.build(), cache);
|
||||
}
|
||||
}
|
||||
@@ -184,13 +191,14 @@ public class ConnectUtil {
|
||||
//寻找配置
|
||||
Setting setting = settingService.get(SettingEnum.QQ_CONNECT.name());
|
||||
QQConnectSetting qqConnectSetting = JSONUtil.toBean(setting.getSettingValue(), QQConnectSetting.class);
|
||||
|
||||
//登录设置
|
||||
ConnectSetting connectSetting = JSONUtil.toBean(settingService.get(SettingEnum.CONNECT_SETTING.name()).getSettingValue(), ConnectSetting.class);
|
||||
for (QQConnectSettingItem qqConnectSettingItem : qqConnectSetting.getQqConnectSettingItemList()) {
|
||||
if (qqConnectSettingItem.getClientType().equals(ClientTypeEnum.PC.name())) {
|
||||
authRequest = new BaseAuthQQRequest(AuthConfig.builder()
|
||||
.clientId(qqConnectSettingItem.getAppId())
|
||||
.clientSecret(qqConnectSettingItem.getAppKey())
|
||||
.redirectUri(getRedirectUri(authInterface))
|
||||
.redirectUri(getRedirectUri(authInterface, connectSetting.getCallbackUrl()))
|
||||
//这里qq获取unionid 需要配置为true,详情可以查阅属性说明,内部有帮助文档
|
||||
.unionId(true)
|
||||
.build(), cache);
|
||||
|
||||
@@ -36,6 +36,7 @@ public class Distribution extends BaseEntity {
|
||||
this.rebateTotal=0D;
|
||||
this.canRebate=0D;
|
||||
this.commissionFrozen=0D;
|
||||
this.distributionOrderPrice=0D;
|
||||
this.distributionStatus = DistributionStatusEnum.APPLY.name();
|
||||
BeanUtil.copyProperties(distributionApplyDTO, this);
|
||||
}
|
||||
@@ -85,4 +86,7 @@ public class Distribution extends BaseEntity {
|
||||
@ApiModelProperty(value = "结算银行开户支行名称")
|
||||
private String settlementBankBranchName;
|
||||
|
||||
@ApiModelProperty(value = "分销订单金额")
|
||||
private Double distributionOrderPrice;
|
||||
|
||||
}
|
||||
@@ -9,9 +9,11 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.springframework.data.annotation.CreatedDate;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
@@ -51,11 +53,30 @@ public class DistributionCash extends BaseEntity {
|
||||
@ApiModelProperty(value = "状态")
|
||||
private String distributionCashStatus;
|
||||
|
||||
public DistributionCash(String sn, String distributionId, Double price, String memberName) {
|
||||
|
||||
|
||||
@ApiModelProperty(value = "会员姓名")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "身份证号")
|
||||
private String idNumber;
|
||||
@ApiModelProperty(value = "结算银行开户行名称")
|
||||
private String settlementBankAccountName;
|
||||
@ApiModelProperty(value = "结算银行开户账号")
|
||||
private String settlementBankAccountNum;
|
||||
@ApiModelProperty(value = "结算银行开户支行名称")
|
||||
private String settlementBankBranchName;
|
||||
|
||||
public DistributionCash(String sn,Double price, Distribution distribution) {
|
||||
this.sn = sn;
|
||||
this.distributionId = distributionId;
|
||||
this.distributionId = distribution.getId();
|
||||
this.price = price;
|
||||
this.distributionCashStatus = WithdrawStatusEnum.APPLY.name();
|
||||
this.distributionName = memberName;
|
||||
this.distributionName = distribution.getMemberName();
|
||||
|
||||
this.name = distribution.getName();
|
||||
this.idNumber = distribution.getIdNumber();
|
||||
this.settlementBankAccountName = distribution.getSettlementBankAccountName();
|
||||
this.settlementBankAccountNum = distribution.getSettlementBankAccountNum();
|
||||
this.settlementBankBranchName = distribution.getSettlementBankBranchName();
|
||||
}
|
||||
}
|
||||
@@ -79,6 +79,8 @@ public class DistributionOrder extends BaseIdEntity {
|
||||
private String image;
|
||||
@ApiModelProperty(value = "商品数量")
|
||||
private Integer num;
|
||||
@ApiModelProperty(value = "退款商品数量")
|
||||
private Integer refundNum;
|
||||
|
||||
public DistributionOrder(StoreFlow storeFlow) {
|
||||
distributionOrderStatus = DistributionOrderStatusEnum.NO_COMPLETED.name();
|
||||
@@ -95,6 +97,8 @@ public class DistributionOrder extends BaseIdEntity {
|
||||
specs = storeFlow.getSpecs();
|
||||
image = storeFlow.getImage();
|
||||
num = storeFlow.getNum();
|
||||
refundNum=0;
|
||||
sellBackRebate=0D;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,16 +6,10 @@ package cn.lili.modules.distribution.entity.enums;
|
||||
* @author pikachu
|
||||
*/
|
||||
public enum DistributionOrderStatusEnum {
|
||||
//未完成
|
||||
|
||||
NO_COMPLETED("未完成"),
|
||||
//待结算(冻结)
|
||||
WAIT_BILL("待结算"),
|
||||
//待提现
|
||||
WAIT_CASH("待提现"),
|
||||
//已提现
|
||||
COMPLETE_CASH("提现完成"),
|
||||
//订单取消
|
||||
CANCEL("订单取消"),
|
||||
//完成
|
||||
COMPLETE("完成"),
|
||||
//订单取消
|
||||
REFUND("退款");
|
||||
|
||||
|
||||
@@ -13,25 +13,32 @@ import org.apache.ibatis.annotations.Update;
|
||||
*/
|
||||
public interface DistributionMapper extends BaseMapper<Distribution> {
|
||||
|
||||
/**
|
||||
* 修改分销员可提现金额
|
||||
*
|
||||
* @param commissionFrozen 分销金额
|
||||
* @param distributionId 分销员ID
|
||||
*/
|
||||
@Update("UPDATE li_distribution set commission_frozen = (IFNULL(commission_frozen,0)+#{commissionFrozen}) " +
|
||||
", rebate_total=(IFNULL(rebate_total,0)+#{commissionFrozen}) WHERE id = #{distributionId}")
|
||||
void subCanRebate(Double commissionFrozen, String distributionId);
|
||||
@Update("UPDATE li_distribution set commission_frozen = (IFNULL(commission_frozen,0) - #{commissionFrozen}) " +
|
||||
", rebate_total=(IFNULL(rebate_total,0) - #{commissionFrozen}) " +
|
||||
", distribution_order_count=(IFNULL(distribution_order_count,0)-1) " +
|
||||
" WHERE id = #{distributionId}")
|
||||
void subRebate(Double commissionFrozen, String distributionId, Double distributionOrderPrice);
|
||||
|
||||
/**
|
||||
* 添加分销金额
|
||||
*
|
||||
* @param commissionFrozen 分销金额
|
||||
* @param distributionId 分销员ID
|
||||
*/
|
||||
@Update("UPDATE li_distribution set commission_frozen = (IFNULL(commission_frozen,0)+#{commissionFrozen}) " +
|
||||
", rebate_total=(IFNULL(rebate_total,0)+#{commissionFrozen}) " +
|
||||
", distribution_order_count=(IFNULL(distribution_order_count,0)+1) WHERE id = #{distributionId}")
|
||||
void addCanRebate(Double commissionFrozen, String distributionId);
|
||||
", distribution_order_price=(IFNULL(distribution_order_price,0)+#{distributionOrderPrice}) " +
|
||||
", distribution_order_count=(IFNULL(distribution_order_count,0)+1) " +
|
||||
" WHERE id = #{distributionId}")
|
||||
void addRebate(Double commissionFrozen, String distributionId, Double distributionOrderPrice);
|
||||
|
||||
|
||||
@Update("UPDATE li_distribution SET commission_frozen = (IFNULL(commission_frozen,0) - #{rebate}) " +
|
||||
",can_rebate=(IFNULL(can_rebate,0) + #{rebate}) " +
|
||||
" WHERE id = #{distributionId}")
|
||||
void addCanRebate(Double rebate, String distributionId);
|
||||
|
||||
@Update("UPDATE li_distribution SET can_rebate=(IFNULL(can_rebate,0) - #{rebate}),cash_rebate=(IFNULL(cash_rebate,0) + #{rebate}) " +
|
||||
" WHERE id = #{distributionId}")
|
||||
void addCashRebate(Double rebate, String distributionId);
|
||||
|
||||
|
||||
@Update("UPDATE li_distribution SET cash_rebate=(IFNULL(cash_rebate,0) - #{rebate}) " +
|
||||
" WHERE id = #{distributionId}")
|
||||
void subCashRebate(Double rebate, String distributionId);
|
||||
|
||||
}
|
||||
@@ -3,6 +3,9 @@ package cn.lili.modules.distribution.mapper;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.lili.modules.distribution.entity.dos.DistributionOrder;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
/**
|
||||
@@ -24,4 +27,15 @@ public interface DistributionOrderMapper extends BaseMapper<DistributionOrder> {
|
||||
",d.commission_frozen =(ifnull(d.commission_frozen,0) -(SELECT SUM( dorder.rebate ) FROM li_distribution_order AS dorder WHERE dorder.distribution_order_status = #{distributionOrderStatus} AND dorder.settle_cycle< #{settleCycle} AND dorder.distribution_id = d.id ) )")
|
||||
void rebate(String distributionOrderStatus, DateTime settleCycle);
|
||||
|
||||
/**
|
||||
* 查询待结算的分销订单
|
||||
* @return 待结算的分销订单
|
||||
*/
|
||||
@Select("UPDATE li_distribution_order distribution_order"
|
||||
+ " INNER JOIN li_order_item oi ON oi.sn = distribution_order.order_item_sn"
|
||||
+ " SET distribution_order.distribution_order_status = 'WAIT_BILL',"
|
||||
+ " distribution_order.settle_cycle = #{settleCycle} "
|
||||
+ " WHERE distribution_order.distribution_order_status = 'NO_COMPLETED'"
|
||||
+ " AND oi.after_sale_status = 'EXPIRED';")
|
||||
List<DistributionOrder> distributionSettlementOrder(Date settleCycle);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
/**
|
||||
* 分销佣金业务层
|
||||
*
|
||||
@@ -40,6 +42,9 @@ public interface DistributionCashService extends IService<DistributionCash> {
|
||||
*/
|
||||
IPage<DistributionCash> getDistributionCash(DistributionCashSearchParams distributionCashSearchParams);
|
||||
|
||||
|
||||
void queryExport(HttpServletResponse response,DistributionCashSearchParams distributionCashSearchParams);
|
||||
|
||||
/**
|
||||
* 审核分销提现申请
|
||||
*
|
||||
|
||||
@@ -3,7 +3,9 @@ package cn.lili.modules.distribution.service;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.lili.modules.distribution.entity.dos.DistributionOrder;
|
||||
import cn.lili.modules.distribution.entity.vos.DistributionOrderSearchParams;
|
||||
import cn.lili.modules.order.aftersale.entity.dos.AfterSale;
|
||||
import cn.lili.modules.order.order.entity.dos.OrderItem;
|
||||
import cn.lili.modules.order.order.entity.dos.StoreFlow;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
@@ -44,22 +46,12 @@ public interface DistributionOrderService extends IService<DistributionOrder> {
|
||||
/**
|
||||
* 订单退款
|
||||
* 记录分销订单
|
||||
*
|
||||
* @param afterSaleSn 售后单号
|
||||
*/
|
||||
void refundOrder(String afterSaleSn);
|
||||
void refundOrder(AfterSale afterSale);
|
||||
|
||||
/**
|
||||
* 分销订单状态修改
|
||||
*
|
||||
* @param orderItems
|
||||
* 分销订单完成
|
||||
*/
|
||||
void updateDistributionOrderStatus(List<OrderItem> orderItems);
|
||||
void completeOrder(StoreFlow storeFlow);
|
||||
|
||||
/**
|
||||
* 分销订单结算
|
||||
* @param dateTime
|
||||
* @param distributionOrderStatus
|
||||
*/
|
||||
void updateRebate(DateTime dateTime, String distributionOrderStatus);
|
||||
}
|
||||
@@ -78,18 +78,42 @@ public interface DistributionService extends IService<Distribution> {
|
||||
void checkDistributionSetting();
|
||||
|
||||
/**
|
||||
* 修改可提现金额
|
||||
*
|
||||
* @param canRebate 修改金额
|
||||
* @param distributionId 分销员ID
|
||||
*/
|
||||
void subCanRebate(Double canRebate, String distributionId);
|
||||
|
||||
/**
|
||||
* 添加分销金额
|
||||
* 添加分销冻结金额
|
||||
* 创建分销订单时进行调用
|
||||
*
|
||||
* @param rebate 金额
|
||||
* @param distributionId 分销员ID
|
||||
* @param distributionOrderPrice 分销订单金额
|
||||
*/
|
||||
void addRebate(Double rebate, String distributionId);
|
||||
void addRebate(Double rebate, String distributionId, Double distributionOrderPrice);
|
||||
|
||||
/**
|
||||
* 扣减分销冻结金额
|
||||
* 订单取消/退款时进行调用
|
||||
*
|
||||
* @param rebate 佣金
|
||||
* @param distributionId 分销员ID
|
||||
*/
|
||||
void subRebate(Double rebate, String distributionId, Double distributionOrderPrice);
|
||||
|
||||
/**
|
||||
* 添加分销可提现金额
|
||||
* 订单完成时进行调用
|
||||
* @param rebate 佣金
|
||||
* @param distributionId 分销员ID
|
||||
*/
|
||||
void addCanRebate(Double rebate, String distributionId);
|
||||
|
||||
/**
|
||||
* 添加提现金额
|
||||
* @param rebate
|
||||
* @param distributionId
|
||||
*/
|
||||
void addCashRebate(Double rebate, String distributionId);
|
||||
/**
|
||||
* 扣减提现金额
|
||||
* @param rebate
|
||||
* @param distributionId
|
||||
*/
|
||||
void subCashRebate(Double rebate, String distributionId);
|
||||
}
|
||||
@@ -1,5 +1,12 @@
|
||||
package cn.lili.modules.distribution.serviceimpl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.common.context.ThreadContextHolder;
|
||||
import cn.lili.common.enums.ClientTypeEnum;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.properties.RocketmqCustomProperties;
|
||||
@@ -13,6 +20,14 @@ import cn.lili.modules.distribution.entity.vos.DistributionCashSearchParams;
|
||||
import cn.lili.modules.distribution.mapper.DistributionCashMapper;
|
||||
import cn.lili.modules.distribution.service.DistributionCashService;
|
||||
import cn.lili.modules.distribution.service.DistributionService;
|
||||
import cn.lili.modules.order.order.entity.dto.OrderExportDTO;
|
||||
import cn.lili.modules.order.order.entity.dto.OrderExportDetailDTO;
|
||||
import cn.lili.modules.order.order.entity.dto.OrderSearchParams;
|
||||
import cn.lili.modules.order.order.entity.dto.PriceDetailDTO;
|
||||
import cn.lili.modules.order.order.entity.enums.OrderItemAfterSaleStatusEnum;
|
||||
import cn.lili.modules.order.order.entity.enums.OrderStatusEnum;
|
||||
import cn.lili.modules.order.order.entity.enums.OrderTypeEnum;
|
||||
import cn.lili.modules.payment.entity.enums.PaymentMethodEnum;
|
||||
import cn.lili.modules.wallet.entity.dto.MemberWalletUpdateDTO;
|
||||
import cn.lili.modules.wallet.entity.dto.MemberWithdrawalMessage;
|
||||
import cn.lili.modules.wallet.entity.enums.DepositServiceTypeEnum;
|
||||
@@ -25,12 +40,23 @@ import cn.lili.rocketmq.tags.MemberTagsEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.apache.poi.ss.usermodel.Cell;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@@ -76,7 +102,7 @@ public class DistributionCashServiceImpl extends ServiceImpl<DistributionCashMap
|
||||
distribution.setCommissionFrozen(CurrencyUtil.add(distribution.getCommissionFrozen(), applyMoney));
|
||||
distributionService.updateById(distribution);
|
||||
//提现申请记录
|
||||
DistributionCash distributionCash = new DistributionCash("D" + SnowFlake.getId(), distribution.getId(), applyMoney, distribution.getMemberName());
|
||||
DistributionCash distributionCash = new DistributionCash("D" + SnowFlake.getId(),applyMoney, distribution);
|
||||
boolean result = this.save(distributionCash);
|
||||
if (result) {
|
||||
//发送提现消息
|
||||
@@ -109,6 +135,28 @@ public class DistributionCashServiceImpl extends ServiceImpl<DistributionCashMap
|
||||
return this.page(PageUtil.initPage(distributionCashSearchParams), distributionCashSearchParams.queryWrapper());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void queryExport(HttpServletResponse response, DistributionCashSearchParams distributionCashSearchParams) {
|
||||
XSSFWorkbook workbook = initExportData(this.list(distributionCashSearchParams.queryWrapper()));
|
||||
try {
|
||||
// 设置响应头
|
||||
String fileName = URLEncoder.encode("分销提现列表", "UTF-8");
|
||||
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx");
|
||||
|
||||
ServletOutputStream out = response.getOutputStream();
|
||||
workbook.write(out);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
workbook.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public DistributionCash audit(String id, String result) {
|
||||
@@ -123,32 +171,21 @@ public class DistributionCashServiceImpl extends ServiceImpl<DistributionCashMap
|
||||
//获取分销员
|
||||
Distribution distribution = distributionService.getById(distributorCash.getDistributionId());
|
||||
if (distribution != null && distribution.getDistributionStatus().equals(DistributionStatusEnum.PASS.name())) {
|
||||
MemberWithdrawalMessage memberWithdrawalMessage = new MemberWithdrawalMessage();
|
||||
//审核通过
|
||||
if (result.equals(WithdrawStatusEnum.VIA_AUDITING.name())) {
|
||||
memberWithdrawalMessage.setStatus(WithdrawStatusEnum.VIA_AUDITING.name());
|
||||
//分销记录操作
|
||||
distributorCash.setDistributionCashStatus(WithdrawStatusEnum.VIA_AUDITING.name());
|
||||
distributorCash.setPayTime(new Date());
|
||||
//提现到余额
|
||||
memberWalletService.increase(new MemberWalletUpdateDTO(distributorCash.getPrice(), distribution.getMemberId(), "分销[" + distributorCash.getSn() + "]佣金提现到余额[" + distributorCash.getPrice() + "]", DepositServiceTypeEnum.WALLET_COMMISSION.name()));
|
||||
} else {
|
||||
memberWithdrawalMessage.setStatus(WithdrawStatusEnum.FAIL_AUDITING.name());
|
||||
//分销员可提现金额退回
|
||||
distribution.setCanRebate(CurrencyUtil.add(distribution.getCanRebate(), distributorCash.getPrice()));
|
||||
distributorCash.setDistributionCashStatus(WithdrawStatusEnum.FAIL_AUDITING.name());
|
||||
}
|
||||
distribution.setCommissionFrozen(CurrencyUtil.sub(distribution.getCommissionFrozen(), distributorCash.getPrice()));
|
||||
//分销员金额相关处理
|
||||
distributionService.updateById(distribution);
|
||||
//修改分销提现申请
|
||||
boolean bool = this.updateById(distributorCash);
|
||||
if (bool) {
|
||||
//组织会员提现审核消息
|
||||
memberWithdrawalMessage.setMemberId(distribution.getMemberId());
|
||||
memberWithdrawalMessage.setPrice(distributorCash.getPrice());
|
||||
String destination = rocketmqCustomProperties.getMemberTopic() + ":" + MemberTagsEnum.MEMBER_WITHDRAWAL.name();
|
||||
rocketMQTemplate.asyncSend(destination, memberWithdrawalMessage, RocketmqSendCallbackBuilder.commonCallback());
|
||||
}
|
||||
this.updateById(distributorCash);
|
||||
return distributorCash;
|
||||
}
|
||||
throw new ServiceException(ResultCode.DISTRIBUTION_NOT_EXIST);
|
||||
@@ -156,4 +193,38 @@ public class DistributionCashServiceImpl extends ServiceImpl<DistributionCashMap
|
||||
throw new ServiceException(ResultCode.DISTRIBUTION_CASH_NOT_EXIST);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化填充导出数据
|
||||
*
|
||||
* @param distributionCashList 导出的数据
|
||||
* @return 填充导出数据
|
||||
*/
|
||||
private XSSFWorkbook initExportData(List<DistributionCash> distributionCashList) {
|
||||
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
Sheet sheet = workbook.createSheet("订单列表");
|
||||
|
||||
// 创建表头
|
||||
Row header = sheet.createRow(0);
|
||||
String[] headers = {"编号", "姓名", "身份证号", "结算银行开户行名称", "结算银行开户账号", "结算银行开户支行名称"};
|
||||
|
||||
for (int i = 0; i < headers.length; i++) {
|
||||
Cell cell = header.createCell(i);
|
||||
cell.setCellValue(headers[i]);
|
||||
}
|
||||
// 填充数据
|
||||
for (int i = 0; i < distributionCashList.size(); i++) {
|
||||
DistributionCash distributionCash = distributionCashList.get(i);
|
||||
Row row = sheet.createRow(i + 1);
|
||||
row.createCell(0).setCellValue(distributionCash.getSn());
|
||||
row.createCell(1).setCellValue(distributionCash.getName());
|
||||
row.createCell(2).setCellValue(distributionCash.getIdNumber());
|
||||
row.createCell(3).setCellValue(distributionCash.getSettlementBankAccountName());
|
||||
row.createCell(4).setCellValue(distributionCash.getSettlementBankAccountNum());
|
||||
row.createCell(5).setCellValue(distributionCash.getSettlementBankBranchName());
|
||||
}
|
||||
return workbook;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,32 +1,23 @@
|
||||
package cn.lili.modules.distribution.serviceimpl;
|
||||
|
||||
import cn.hutool.core.collection.ListUtil;
|
||||
import cn.hutool.core.date.DateField;
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.common.utils.CurrencyUtil;
|
||||
import cn.lili.common.utils.SpringContextUtil;
|
||||
import cn.lili.modules.distribution.entity.dos.Distribution;
|
||||
import cn.lili.modules.distribution.entity.dos.DistributionOrder;
|
||||
import cn.lili.modules.distribution.entity.enums.DistributionOrderStatusEnum;
|
||||
import cn.lili.modules.distribution.entity.enums.DistributionStatusEnum;
|
||||
import cn.lili.modules.distribution.entity.vos.DistributionOrderSearchParams;
|
||||
import cn.lili.modules.distribution.mapper.DistributionOrderMapper;
|
||||
import cn.lili.modules.distribution.service.DistributionOrderService;
|
||||
import cn.lili.modules.distribution.service.DistributionService;
|
||||
import cn.lili.modules.order.aftersale.entity.dos.AfterSale;
|
||||
import cn.lili.modules.order.order.entity.dos.Order;
|
||||
import cn.lili.modules.order.order.entity.dos.OrderItem;
|
||||
import cn.lili.modules.order.order.entity.dos.StoreFlow;
|
||||
import cn.lili.modules.order.order.entity.dto.StoreFlowProfitSharingDTO;
|
||||
import cn.lili.modules.order.order.entity.dto.StoreFlowQueryDTO;
|
||||
import cn.lili.modules.order.order.entity.enums.OrderItemAfterSaleStatusEnum;
|
||||
import cn.lili.modules.order.order.entity.enums.FlowTypeEnum;
|
||||
import cn.lili.modules.order.order.entity.enums.PayStatusEnum;
|
||||
import cn.lili.modules.order.order.service.OrderService;
|
||||
import cn.lili.modules.order.order.service.StoreFlowService;
|
||||
import cn.lili.modules.system.entity.dos.Setting;
|
||||
import cn.lili.modules.system.entity.dto.DistributionSetting;
|
||||
import cn.lili.modules.system.entity.enums.SettingEnum;
|
||||
import cn.lili.modules.system.service.SettingService;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@@ -38,12 +29,8 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
* 分销订单接口实现
|
||||
@@ -53,7 +40,8 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DistributionOrderServiceImpl extends ServiceImpl<DistributionOrderMapper, DistributionOrder> implements DistributionOrderService {
|
||||
public class DistributionOrderServiceImpl extends ServiceImpl<DistributionOrderMapper, DistributionOrder>
|
||||
implements DistributionOrderService {
|
||||
|
||||
/**
|
||||
* 订单
|
||||
@@ -70,15 +58,12 @@ public class DistributionOrderServiceImpl extends ServiceImpl<DistributionOrderM
|
||||
*/
|
||||
@Autowired
|
||||
private DistributionService distributionService;
|
||||
/**
|
||||
* 系统设置
|
||||
*/
|
||||
@Autowired
|
||||
private SettingService settingService;
|
||||
|
||||
@Override
|
||||
public IPage<DistributionOrder> getDistributionOrderPage(DistributionOrderSearchParams distributionOrderSearchParams) {
|
||||
return this.page(PageUtil.initPage(distributionOrderSearchParams), distributionOrderSearchParams.queryWrapper());
|
||||
public IPage<DistributionOrder> getDistributionOrderPage(
|
||||
DistributionOrderSearchParams distributionOrderSearchParams) {
|
||||
return this.page(PageUtil.initPage(distributionOrderSearchParams),
|
||||
distributionOrderSearchParams.queryWrapper());
|
||||
|
||||
}
|
||||
|
||||
@@ -99,8 +84,8 @@ public class DistributionOrderServiceImpl extends ServiceImpl<DistributionOrderM
|
||||
//判断是否为分销订单,如果为分销订单则获取分销佣金
|
||||
if (order.getDistributionId() != null) {
|
||||
//根据订单编号获取有分销金额的店铺流水记录
|
||||
List<StoreFlow> storeFlowList = storeFlowService
|
||||
.listStoreFlow(StoreFlowQueryDTO.builder().justDistribution(true).orderSn(orderSn).build());
|
||||
List<StoreFlow> storeFlowList = storeFlowService.listStoreFlow(
|
||||
StoreFlowQueryDTO.builder().justDistribution(true).orderSn(orderSn).build());
|
||||
double rebate = 0.0;
|
||||
//循环店铺流水记录判断是否包含分销商品
|
||||
//包含分销商品则进行记录分销订单、计算分销总额
|
||||
@@ -115,39 +100,21 @@ public class DistributionOrderServiceImpl extends ServiceImpl<DistributionOrderM
|
||||
Distribution distribution = distributionService.getById(order.getDistributionId());
|
||||
distributionOrder.setDistributionName(distribution.getMemberName());
|
||||
|
||||
//设置结算天数(解冻日期)
|
||||
Setting setting = settingService.get(SettingEnum.DISTRIBUTION_SETTING.name());
|
||||
DistributionSetting distributionSetting = JSONUtil.toBean(setting.getSettingValue(), DistributionSetting.class);
|
||||
|
||||
|
||||
//添加分销订单
|
||||
this.save(distributionOrder);
|
||||
|
||||
//记录会员的分销总额
|
||||
if (rebate != 0.0) {
|
||||
distributionService.addRebate(rebate, order.getDistributionId());
|
||||
|
||||
//如果天数写0则立即进行结算
|
||||
if (distributionSetting.getCashDay().equals(0)) {
|
||||
DateTime dateTime = new DateTime();
|
||||
dateTime = dateTime.offsetNew(DateField.DAY_OF_MONTH, -distributionSetting.getCashDay());
|
||||
//防止事务失效,采用上下文获取bean
|
||||
DistributionOrderService bean = SpringContextUtil.getBean(DistributionOrderService.class);
|
||||
//分销订单结算
|
||||
bean.updateRebate(dateTime, DistributionOrderStatusEnum.WAIT_BILL.name());
|
||||
}
|
||||
distributionService.addRebate(rebate, order.getDistributionId(), storeFlow.getFinalPrice());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 1.获取订单判断是否为已付款的分销订单
|
||||
* 2.查看店铺流水记录分销佣金
|
||||
* 3.修改分销员的分销总金额、可提现金额
|
||||
* 1.获取订单判断是否为已付款的分销订单 2.查看店铺流水记录分销佣金 3.修改分销员的分销总金额、可提现金额
|
||||
*
|
||||
* @param orderSn 订单编号
|
||||
*/
|
||||
@@ -161,181 +128,77 @@ public class DistributionOrderServiceImpl extends ServiceImpl<DistributionOrderM
|
||||
if (order.getDistributionId() != null && order.getPayStatus().equals(PayStatusEnum.PAID.name())) {
|
||||
|
||||
//根据订单编号获取有分销金额的店铺流水记录
|
||||
List<DistributionOrder> distributionOrderList = this.list(new LambdaQueryWrapper<DistributionOrder>()
|
||||
.eq(DistributionOrder::getOrderSn, orderSn));
|
||||
List<DistributionOrder> distributionOrderList =
|
||||
this.list(new LambdaQueryWrapper<DistributionOrder>().eq(DistributionOrder::getOrderSn, orderSn));
|
||||
|
||||
//如果没有分销定单,则直接返回
|
||||
if (distributionOrderList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
//分销金额
|
||||
double rebate = 0.0;
|
||||
|
||||
//包含分销商品则进行记录分销订单、计算分销总额
|
||||
for (DistributionOrder distributionOrder : distributionOrderList) {
|
||||
rebate = CurrencyUtil.add(rebate, distributionOrder.getRebate());
|
||||
}
|
||||
|
||||
//如果包含分销商品则记录会员的分销总额
|
||||
if (rebate != 0.0) {
|
||||
distributionService.subCanRebate(CurrencyUtil.sub(0, rebate), order.getDistributionId());
|
||||
distributionService.subRebate(distributionOrder.getRebate(), order.getDistributionId(), distributionOrder.getSellBackRebate());
|
||||
}
|
||||
}
|
||||
|
||||
//修改分销订单的状态
|
||||
this.update(new LambdaUpdateWrapper<DistributionOrder>().eq(DistributionOrder::getOrderSn, orderSn)
|
||||
.set(DistributionOrder::getDistributionOrderStatus, DistributionOrderStatusEnum.CANCEL.name()));
|
||||
.set(DistributionOrder::getDistributionOrderStatus, DistributionOrderStatusEnum.REFUND.name()));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void refundOrder(String afterSaleSn) {
|
||||
public void refundOrder(AfterSale afterSale) {
|
||||
//判断是否为分销订单
|
||||
StoreFlow storeFlow = storeFlowService.queryOne(StoreFlowQueryDTO.builder().justDistribution(true).refundSn(afterSaleSn).build());
|
||||
if (storeFlow != null) {
|
||||
|
||||
StoreFlow refundStoreFlow = storeFlowService.queryOne(
|
||||
StoreFlowQueryDTO.builder().justDistribution(true).refundSn(afterSale.getSn()).build());
|
||||
if (refundStoreFlow != null) {
|
||||
//获取收款分销订单
|
||||
DistributionOrder distributionOrder = this.getOne(new LambdaQueryWrapper<DistributionOrder>()
|
||||
.eq(DistributionOrder::getOrderItemSn, storeFlow.getOrderItemSn()));
|
||||
DistributionOrder distributionOrder = this.getOne(
|
||||
new LambdaQueryWrapper<DistributionOrder>().eq(DistributionOrder::getOrderItemSn,
|
||||
afterSale.getOrderItemSn()));
|
||||
//分销订单不存在,则直接返回
|
||||
if (distributionOrder == null) {
|
||||
return;
|
||||
}
|
||||
if (distributionOrder.getDistributionOrderStatus().equals(DistributionOrderStatusEnum.WAIT_BILL.name())) {
|
||||
this.update(new LambdaUpdateWrapper<DistributionOrder>()
|
||||
.eq(DistributionOrder::getOrderItemSn, storeFlow.getOrderItemSn())
|
||||
.set(DistributionOrder::getDistributionOrderStatus, DistributionOrderStatusEnum.CANCEL.name()));
|
||||
if (distributionOrder.getSellBackRebate() == null) {
|
||||
distributionOrder.setSellBackRebate(refundStoreFlow.getDistributionRebate());
|
||||
} else {
|
||||
distributionOrder.setSellBackRebate(
|
||||
CurrencyUtil.add(distributionOrder.getSellBackRebate(), refundStoreFlow.getDistributionRebate()));
|
||||
}
|
||||
//如果已结算则创建退款分销订单
|
||||
else {
|
||||
//修改分销员提成金额
|
||||
distributionService.subCanRebate(CurrencyUtil.sub(0, storeFlow.getDistributionRebate()), distributionOrder.getDistributionId());
|
||||
|
||||
distributionOrder.setRebate(CurrencyUtil.sub(distributionOrder.getRebate(), refundStoreFlow.getDistributionRebate()));
|
||||
if (distributionOrder.getRebate() == 0) {
|
||||
distributionOrder.setDistributionOrderStatus(DistributionOrderStatusEnum.REFUND.name());
|
||||
}
|
||||
distributionOrder.setRefundNum(distributionOrder.getRefundNum() + afterSale.getNum());
|
||||
this.updateById(distributionOrder);
|
||||
|
||||
// 修改分销员提成金额
|
||||
if (refundStoreFlow.getDistributionRebate() != 0.0) {
|
||||
distributionService.subRebate(refundStoreFlow.getDistributionRebate(), distributionOrder.getDistributionId(), refundStoreFlow.getFinalPrice());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDistributionOrderStatus(List<OrderItem> orderItems) {
|
||||
if (orderItems.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
//获取未完成分销订单
|
||||
List<DistributionOrder> distributionOrderList = this.list(new LambdaQueryWrapper<DistributionOrder>()
|
||||
.eq(DistributionOrder::getDistributionOrderStatus, DistributionOrderStatusEnum.NO_COMPLETED.name()));
|
||||
|
||||
if (distributionOrderList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<DistributionOrder> list = ListUtil.list(false);
|
||||
|
||||
orderItems.stream().forEach(orderItem -> {
|
||||
//订单售后状态为已失效并且投诉状态为已失效
|
||||
if (StrUtil.equals(OrderItemAfterSaleStatusEnum.EXPIRED.name(), orderItem.getAfterSaleStatus())) {
|
||||
|
||||
|
||||
List<DistributionOrder> collect = distributionOrderList.stream()
|
||||
.filter(distributionOrder -> StrUtil.equals(distributionOrder.getOrderItemSn(), orderItem.getSn()))
|
||||
.map((distributionOrder) -> {
|
||||
distributionOrder.setDistributionOrderStatus(DistributionOrderStatusEnum.WAIT_BILL.name());
|
||||
distributionOrder.setSettleCycle(new Date());
|
||||
return distributionOrder;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
list.addAll(collect);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
if (!list.isEmpty()) {
|
||||
//批量修改分销订单结算状态
|
||||
this.updateBatchById(list);
|
||||
public void completeOrder(StoreFlow storeFlow) {
|
||||
if (storeFlow.getFlowType().equals(FlowTypeEnum.PAY.name())
|
||||
&&storeFlow.getDistributionRebate() != null
|
||||
&& storeFlow.getDistributionRebate() != 0) {
|
||||
//获取分账内容
|
||||
StoreFlowProfitSharingDTO storeFlowProfitSharingDTO = JSONUtil.toBean(storeFlow.getProfitSharing(), StoreFlowProfitSharingDTO.class);
|
||||
//获取分销订单
|
||||
DistributionOrder distributionOrder = this.getOne(new LambdaQueryWrapper<DistributionOrder>().eq(DistributionOrder::getOrderItemSn, storeFlow.getOrderItemSn()));
|
||||
//解冻分销金额
|
||||
distributionService.addCanRebate(storeFlowProfitSharingDTO.getDistributionPrice(), distributionOrder.getDistributionId());
|
||||
// 订单完成
|
||||
this.update(new LambdaUpdateWrapper<DistributionOrder>()
|
||||
.eq(DistributionOrder::getId, distributionOrder.getId())
|
||||
.set(DistributionOrder::getDistributionOrderStatus, DistributionOrderStatusEnum.COMPLETE.name()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateRebate(DateTime dateTime, String distributionOrderStatus) {
|
||||
//结算时间延后五分钟
|
||||
dateTime = dateTime.offsetNew(DateField.MINUTE, 5);
|
||||
//获取待结算订单
|
||||
List<DistributionOrder> distributionOrderList = this.list(new LambdaQueryWrapper<DistributionOrder>()
|
||||
.eq(DistributionOrder::getDistributionOrderStatus, distributionOrderStatus)
|
||||
.isNotNull(DistributionOrder::getSettleCycle)
|
||||
.le(DistributionOrder::getSettleCycle, dateTime));
|
||||
//校验待结算订单
|
||||
if (ObjectUtil.isNotNull(distributionOrderList) && distributionOrderList.size() > 0) {
|
||||
//结算分销人员信息列表
|
||||
List<Distribution> distributionUpdateList = new ArrayList<>();
|
||||
//获取分销员信息
|
||||
List<Distribution> distributionList = distributionService.list(new LambdaQueryWrapper<Distribution>()
|
||||
.eq(Distribution::getDistributionStatus, DistributionStatusEnum.PASS.name()));
|
||||
//根据销人员获取对应分销订单
|
||||
Map<String, List<DistributionOrder>> distributionOrderList1 = distributionOrderList.stream()
|
||||
.collect(Collectors.groupingBy(DistributionOrder::getDistributionId));
|
||||
|
||||
//校验分销订单不为空
|
||||
if (ObjectUtil.isNotNull(distributionOrderList1) && distributionOrderList1.size() > 0) {
|
||||
//遍历分销订单map
|
||||
distributionOrderList1.forEach((key, value) -> {
|
||||
//计算分销结算金额
|
||||
distributionUpdateList.add(checkDistribution(key, value, distributionList));
|
||||
});
|
||||
}
|
||||
|
||||
//校验分销信息列表不为空
|
||||
if (ObjectUtil.isNotNull(distributionUpdateList) && !distributionUpdateList.isEmpty()) {
|
||||
//修改分销员收益
|
||||
distributionService.updateBatchById(distributionUpdateList);
|
||||
distributionOrderList.stream().forEach(distributionOrder -> {
|
||||
//修改分销订单状态为待提现
|
||||
distributionOrder.setDistributionOrderStatus(DistributionOrderStatusEnum.WAIT_CASH.name());
|
||||
});
|
||||
}
|
||||
|
||||
//修改分销订单状态
|
||||
this.updateBatchById(distributionOrderList);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 计算分销结算金额
|
||||
*
|
||||
* @param distributionId 分销ID
|
||||
* @param list 分销订单
|
||||
* @param distributionList 分销列表
|
||||
* @return
|
||||
*/
|
||||
public Distribution checkDistribution(String distributionId, List<DistributionOrder> list, List<Distribution> distributionList) {
|
||||
//获取所有待结算订单分销人员信息
|
||||
Distribution distribution = distributionList.parallelStream().filter(a -> StrUtil.equals(a.getId(), distributionId)).collect(Collectors.toList()).get(0);
|
||||
|
||||
//获取分销订单总金额
|
||||
double rebate = list.stream().mapToDouble(DistributionOrder::getRebate).sum();
|
||||
|
||||
//检验单分销人员冻结金额为负数时.扣除负数冻结金额后再结算
|
||||
if (distribution.getCommissionFrozen() < 0) {
|
||||
rebate = CurrencyUtil.add(distribution.getCommissionFrozen() == null ? 0.0 : distribution.getCommissionFrozen(), rebate);
|
||||
}
|
||||
//结算订单总金额+分销可提现金额
|
||||
Double canRebate = CurrencyUtil.add(rebate, distribution.getCanRebate() == null ? 0.0 : distribution.getCanRebate());
|
||||
//结算金额小于0
|
||||
if (canRebate < 0) {
|
||||
//结算订单总金额+分销可提现金额
|
||||
distribution.setCanRebate(0.0);
|
||||
//冻结金额
|
||||
distribution.setCommissionFrozen(canRebate);
|
||||
} else {
|
||||
//结算订单总金额+分销可提现金额
|
||||
distribution.setCanRebate(canRebate);
|
||||
//冻结金额
|
||||
distribution.setCommissionFrozen(0.0);
|
||||
}
|
||||
|
||||
return distribution;
|
||||
}
|
||||
}
|
||||
@@ -80,23 +80,25 @@ public class DistributionServiceImpl extends ServiceImpl<DistributionMapper, Dis
|
||||
|
||||
//如果分销员非空并未审核则提示用户请等待,如果分销员为拒绝状态则重新提交申请
|
||||
if (Optional.ofNullable(distribution).isPresent()) {
|
||||
if (distribution.getDistributionStatus().equals(DistributionStatusEnum.APPLY.name())) {
|
||||
throw new ServiceException(ResultCode.DISTRIBUTION_IS_APPLY);
|
||||
} else if (distribution.getDistributionStatus().equals(DistributionStatusEnum.REFUSE.name())) {
|
||||
distribution.setDistributionStatus(DistributionStatusEnum.APPLY.name());
|
||||
BeanUtil.copyProperties(distributionApplyDTO, distribution);
|
||||
this.updateById(distribution);
|
||||
return distribution;
|
||||
switch (DistributionStatusEnum.valueOf(distribution.getDistributionStatus())) {
|
||||
case REFUSE:
|
||||
case RETREAT:
|
||||
distribution.setDistributionStatus(DistributionStatusEnum.APPLY.name());
|
||||
BeanUtil.copyProperties(distributionApplyDTO, distribution);
|
||||
this.updateById(distribution);
|
||||
return distribution;
|
||||
default:
|
||||
throw new ServiceException(ResultCode.DISTRIBUTION_IS_APPLY);
|
||||
}
|
||||
} else {
|
||||
//如果未申请分销员则新增进行申请
|
||||
//获取当前登录用户
|
||||
Member member = memberService.getUserInfo();
|
||||
//新建分销员
|
||||
distribution = new Distribution(member.getId(), member.getNickName(), distributionApplyDTO);
|
||||
//添加分销员
|
||||
this.save(distribution);
|
||||
}
|
||||
//如果未申请分销员则新增进行申请
|
||||
//获取当前登录用户
|
||||
Member member = memberService.getUserInfo();
|
||||
//新建分销员
|
||||
distribution = new Distribution(member.getId(), member.getNickName(), distributionApplyDTO);
|
||||
//添加分销员
|
||||
this.save(distribution);
|
||||
|
||||
return distribution;
|
||||
}
|
||||
|
||||
@@ -179,14 +181,30 @@ public class DistributionServiceImpl extends ServiceImpl<DistributionMapper, Dis
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void subCanRebate(Double canRebate, String distributionId) {
|
||||
this.baseMapper.subCanRebate(canRebate, distributionId);
|
||||
public void subRebate(Double canRebate, String distributionId, Double distributionOrderPrice) {
|
||||
this.baseMapper.subRebate(canRebate, distributionId, distributionOrderPrice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addRebate(Double rebate, String distributionId) {
|
||||
public void addRebate(Double rebate, String distributionId, Double distributionOrderPrice) {
|
||||
this.baseMapper.addRebate(rebate, distributionId, distributionOrderPrice);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCanRebate(Double rebate, String distributionId) {
|
||||
this.baseMapper.addCanRebate(rebate, distributionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCashRebate(Double rebate, String distributionId) {
|
||||
this.baseMapper.addCashRebate(rebate, distributionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subCashRebate(Double rebate, String distributionId) {
|
||||
this.baseMapper.subCashRebate(rebate, distributionId);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -41,6 +41,12 @@ public class File extends BaseEntity {
|
||||
@ApiModelProperty(value = "拥有者id")
|
||||
private String ownerId;
|
||||
|
||||
@ApiModelProperty(value = "拥有者名称")
|
||||
private String ownerName;
|
||||
|
||||
@ApiModelProperty(value = "用户类型")
|
||||
private String userEnums;
|
||||
|
||||
@ApiModelProperty(value = "文件夹ID")
|
||||
private String fileDirectoryId;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package cn.lili.modules.file.entity;
|
||||
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.mybatis.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Max;
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@Data
|
||||
@TableName("li_file_directory")
|
||||
@ApiModel(value = "文件目录")
|
||||
public class FileDirectory extends BaseEntity {
|
||||
|
||||
/**
|
||||
* @see UserEnums
|
||||
*/
|
||||
@ApiModelProperty(value = "文件目录类型")
|
||||
private String directoryType;
|
||||
@ApiModelProperty(value = "拥有者名称")
|
||||
private String directoryName;
|
||||
@ApiModelProperty(value = "拥有者id")
|
||||
private String ownerId;
|
||||
@ApiModelProperty(value = "父分类ID")
|
||||
private String parentId;
|
||||
|
||||
@ApiModelProperty(value = "层级")
|
||||
@NotNull(message = "层级不能为空")
|
||||
@Min(value = 0, message = "层级最小为0")
|
||||
@Max(value = 2, message = "层级最大为2")
|
||||
private Integer level;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.lili.modules.file.entity.dto;
|
||||
|
||||
import cn.lili.common.utils.BeanUtil;
|
||||
import cn.lili.modules.file.entity.FileDirectory;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class FileDirectoryDTO extends FileDirectory{
|
||||
|
||||
@ApiModelProperty(value = "文件目录列表")
|
||||
private List<FileDirectory> children= new ArrayList<>();
|
||||
|
||||
public FileDirectoryDTO(FileDirectory fileDirectory){
|
||||
BeanUtil.copyProperties(fileDirectory, this);
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,16 @@
|
||||
package cn.lili.modules.file.entity.dto;
|
||||
|
||||
import cn.lili.common.utils.DateUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import com.alipay.api.internal.util.StringUtils;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 文件查询所属者参数对象
|
||||
*
|
||||
@@ -14,12 +20,53 @@ import lombok.NoArgsConstructor;
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class FileOwnerDTO {
|
||||
public class FileOwnerDTO extends PageVO {
|
||||
|
||||
@ApiModelProperty(value = "拥有者id")
|
||||
private String ownerId;
|
||||
|
||||
@ApiModelProperty(value = "拥有者名称")
|
||||
private String ownerName;
|
||||
|
||||
@ApiModelProperty(value = "用户类型")
|
||||
private String userEnums;
|
||||
|
||||
@ApiModelProperty(value = "原文件名")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "存储文件名")
|
||||
private String fileKey;
|
||||
|
||||
@ApiModelProperty(value = "文件类型")
|
||||
private String fileType;
|
||||
|
||||
@ApiModelProperty(value = "文件夹ID")
|
||||
private String fileDirectoryId;
|
||||
|
||||
@ApiModelProperty(value = "起始日期")
|
||||
private String startDate;
|
||||
|
||||
@ApiModelProperty(value = "结束日期")
|
||||
private String endDate;
|
||||
|
||||
public Date getConvertStartDate() {
|
||||
if (StringUtils.isEmpty(startDate)) {
|
||||
return null;
|
||||
}
|
||||
return DateUtil.toDate(startDate, DateUtil.STANDARD_DATE_FORMAT);
|
||||
}
|
||||
|
||||
public Date getConvertEndDate() {
|
||||
if (StringUtils.isEmpty(endDate)) {
|
||||
return null;
|
||||
}
|
||||
//结束时间等于结束日期+1天 -1秒,
|
||||
Date date = DateUtil.toDate(endDate, DateUtil.STANDARD_DATE_FORMAT);
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
calendar.setTime(date);
|
||||
calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) + 1);
|
||||
calendar.set(Calendar.SECOND, -1);
|
||||
return calendar.getTime();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
package cn.lili.modules.file.entity.dto;
|
||||
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.SearchVO;
|
||||
import cn.lili.modules.file.entity.File;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class FileSearchParams extends PageVO {
|
||||
|
||||
@ApiModelProperty(value = "文件")
|
||||
private File file;
|
||||
@ApiModelProperty(value = "搜索VO")
|
||||
private SearchVO searchVO;
|
||||
@ApiModelProperty(value = "文件夹ID")
|
||||
private String fileDirectoryId;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package cn.lili.modules.file.mapper;
|
||||
|
||||
import cn.lili.modules.file.entity.FileDirectory;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* 文件管理数据处理层
|
||||
*
|
||||
* @author Chopper
|
||||
* @since 2021-02-22 17:20
|
||||
*/
|
||||
public interface FileDirectoryMapper extends BaseMapper<FileDirectory> {
|
||||
|
||||
}
|
||||
@@ -65,7 +65,7 @@ public class TencentFilePlugin implements FilePlugin {
|
||||
* @return
|
||||
*/
|
||||
private String getUrlPrefix() {
|
||||
return "https://" + ossSetting.getTencentCOSBucket() + ".cos" + ossSetting.getTencentCOSRegion() + ".myqcloud.com/";
|
||||
return "https://" + ossSetting.getTencentCOSBucket() + ".cos." + ossSetting.getTencentCOSRegion() + ".myqcloud.com/";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package cn.lili.modules.file.service;
|
||||
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.modules.file.entity.FileDirectory;
|
||||
import cn.lili.modules.file.entity.dto.FileDirectoryDTO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文件管理业务层
|
||||
*
|
||||
* @author Chopper
|
||||
*/
|
||||
public interface FileDirectoryService extends IService<FileDirectory> {
|
||||
|
||||
/**
|
||||
* 添加目录
|
||||
*
|
||||
* @param userEnum
|
||||
* @param id
|
||||
* @param ownerName
|
||||
*/
|
||||
void addFileDirectory(UserEnums userEnum, String id, String ownerName);
|
||||
|
||||
/**
|
||||
* 获取文件目录
|
||||
*
|
||||
* @param ownerId 拥有者
|
||||
* @return
|
||||
*/
|
||||
List<FileDirectoryDTO> getFileDirectoryList(String ownerId);
|
||||
}
|
||||
@@ -24,6 +24,19 @@ public interface FileService extends IService<File> {
|
||||
* @param ids
|
||||
*/
|
||||
void batchDelete(List<String> ids);
|
||||
/**
|
||||
* 根据文件夹ID批量删除
|
||||
*
|
||||
* @param directoryId 文件夹ID
|
||||
*/
|
||||
void batchDeleteByDirectory(String directoryId);
|
||||
|
||||
/**
|
||||
* 根据文件夹ID查看是否有文件
|
||||
* @param directoryId 文件夹ID
|
||||
* @return
|
||||
*/
|
||||
Boolean countByDirectory(String directoryId);
|
||||
|
||||
/**
|
||||
* 所有者批量删除
|
||||
@@ -37,22 +50,19 @@ public interface FileService extends IService<File> {
|
||||
/**
|
||||
* 自定义搜索分页
|
||||
*
|
||||
* @param file
|
||||
* @param searchVO
|
||||
* @param pageVo
|
||||
|
||||
* @param fileOwnerDTO 文件查询
|
||||
|
||||
* @return
|
||||
*/
|
||||
IPage<File> customerPage(File file, SearchVO searchVO, PageVO pageVo);
|
||||
IPage<File> customerPage(FileOwnerDTO fileOwnerDTO);
|
||||
|
||||
/**
|
||||
* 所属文件数据查询
|
||||
*
|
||||
* @param file
|
||||
* @param searchVO
|
||||
* @param pageVo
|
||||
* @param ownerDTO
|
||||
* @param ownerDTO 文件查询
|
||||
* @return
|
||||
*/
|
||||
IPage<File> customerPageOwner(FileOwnerDTO ownerDTO, File file, SearchVO searchVO, PageVO pageVo);
|
||||
IPage<File> customerPageOwner(FileOwnerDTO ownerDTO);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package cn.lili.modules.file.serviceimpl;
|
||||
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.modules.distribution.entity.dos.DistributionOrder;
|
||||
import cn.lili.modules.file.entity.FileDirectory;
|
||||
import cn.lili.modules.file.entity.dto.FileDirectoryDTO;
|
||||
import cn.lili.modules.file.mapper.FileDirectoryMapper;
|
||||
import cn.lili.modules.file.service.FileDirectoryService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 文件管理业务层实现
|
||||
*
|
||||
* @author Chopper
|
||||
* @since 2020/11/26 17:50
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class FileDirectoryServiceImpl extends ServiceImpl<FileDirectoryMapper, FileDirectory> implements FileDirectoryService {
|
||||
|
||||
|
||||
@Override
|
||||
public void addFileDirectory(UserEnums userEnum, String id, String ownerName) {
|
||||
FileDirectory fileDirectory = new FileDirectory();
|
||||
fileDirectory.setOwnerId(id);
|
||||
fileDirectory.setDirectoryName(ownerName);
|
||||
fileDirectory.setDirectoryType(userEnum.name());
|
||||
this.save(fileDirectory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<FileDirectoryDTO> getFileDirectoryList(String scene) {
|
||||
List<FileDirectory> fileDirectoryList = this.list(new LambdaQueryWrapper<FileDirectory>().eq(FileDirectory::getOwnerId, scene));
|
||||
List<FileDirectoryDTO> fileDirectoryDTOList = new ArrayList<>();
|
||||
|
||||
fileDirectoryList.forEach(item -> {
|
||||
if (item.getLevel() == 0) {
|
||||
FileDirectoryDTO fileDirectoryDTO = new FileDirectoryDTO(item);
|
||||
initChild(fileDirectoryDTO, fileDirectoryList);
|
||||
fileDirectoryDTOList.add(fileDirectoryDTO);
|
||||
}
|
||||
});
|
||||
|
||||
return fileDirectoryDTOList;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 递归初始化子树
|
||||
*/
|
||||
private void initChild(FileDirectoryDTO fileDirectoryDTO, List<FileDirectory> fileDirectoryList) {
|
||||
if (fileDirectoryList == null) {
|
||||
return;
|
||||
}
|
||||
fileDirectoryList.stream()
|
||||
.filter(item -> (item.getParentId().equals(fileDirectoryDTO.getId())))
|
||||
.forEach(child -> {
|
||||
FileDirectoryDTO childTree = new FileDirectoryDTO(child);
|
||||
initChild(childTree, fileDirectoryList);
|
||||
fileDirectoryDTO.getChildren().add(childTree);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -4,23 +4,19 @@ import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.common.vo.SearchVO;
|
||||
import cn.lili.modules.file.entity.File;
|
||||
import cn.lili.modules.file.entity.dto.FileOwnerDTO;
|
||||
import cn.lili.modules.file.mapper.FileMapper;
|
||||
import cn.lili.modules.file.plugin.FilePlugin;
|
||||
import cn.lili.modules.file.plugin.FilePluginFactory;
|
||||
import cn.lili.modules.file.service.FileService;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* 文件管理业务层实现
|
||||
@@ -43,10 +39,31 @@ public class FileServiceImpl extends ServiceImpl<FileMapper, File> implements Fi
|
||||
List<File> files = this.list(queryWrapper);
|
||||
List<String> keys = new ArrayList<>();
|
||||
files.forEach(item -> keys.add(item.getFileKey()));
|
||||
filePluginFactory.filePlugin().deleteFile(keys);
|
||||
if (!keys.isEmpty()) {
|
||||
filePluginFactory.filePlugin().deleteFile(keys);
|
||||
}
|
||||
this.remove(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchDeleteByDirectory(String directoryId) {
|
||||
LambdaQueryWrapper<File> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(File::getFileDirectoryId, directoryId);
|
||||
|
||||
List<File> files = this.list(queryWrapper);
|
||||
List<String> keys = new ArrayList<>();
|
||||
files.forEach(item -> keys.add(item.getFileKey()));
|
||||
if (!keys.isEmpty()) {
|
||||
filePluginFactory.filePlugin().deleteFile(keys);
|
||||
}
|
||||
this.remove(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean countByDirectory(String directoryId) {
|
||||
return this.count(new LambdaQueryWrapper<File>().eq(File::getFileDirectoryId, directoryId))>0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchDelete(List<String> ids, AuthUser authUser) {
|
||||
LambdaQueryWrapper<File> queryWrapper = new LambdaQueryWrapper<>();
|
||||
@@ -74,26 +91,36 @@ public class FileServiceImpl extends ServiceImpl<FileMapper, File> implements Fi
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<File> customerPage(File file, SearchVO searchVO, PageVO pageVo) {
|
||||
public IPage<File> customerPage(FileOwnerDTO fileOwnerDTO) {
|
||||
LambdaQueryWrapper<File> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.like(CharSequenceUtil.isNotEmpty(file.getName()), File::getName, file.getName())
|
||||
.like(CharSequenceUtil.isNotEmpty(file.getFileKey()), File::getFileKey, file.getFileKey())
|
||||
.like(CharSequenceUtil.isNotEmpty(file.getFileType()), File::getFileType, file.getFileType())
|
||||
.between(CharSequenceUtil.isNotEmpty(searchVO.getStartDate()) && CharSequenceUtil.isNotEmpty(searchVO.getEndDate()),
|
||||
File::getCreateTime, searchVO.getStartDate(), searchVO.getEndDate());
|
||||
return this.page(PageUtil.initPage(pageVo), queryWrapper);
|
||||
queryWrapper.like(CharSequenceUtil.isNotEmpty(fileOwnerDTO.getName()), File::getName, fileOwnerDTO.getName())
|
||||
.like(CharSequenceUtil.isNotEmpty(fileOwnerDTO.getOwnerName()), File::getOwnerName,
|
||||
fileOwnerDTO.getOwnerName())
|
||||
.eq(CharSequenceUtil.isNotEmpty(fileOwnerDTO.getFileDirectoryId()), File::getFileDirectoryId,
|
||||
fileOwnerDTO.getFileDirectoryId())
|
||||
.like(CharSequenceUtil.isNotEmpty(fileOwnerDTO.getFileKey()), File::getFileKey, fileOwnerDTO.getFileKey())
|
||||
.like(CharSequenceUtil.isNotEmpty(fileOwnerDTO.getFileType()), File::getFileType,
|
||||
fileOwnerDTO.getFileType()).between(
|
||||
CharSequenceUtil.isNotEmpty(fileOwnerDTO.getStartDate()) && CharSequenceUtil.isNotEmpty(
|
||||
fileOwnerDTO.getEndDate()), File::getCreateTime, fileOwnerDTO.getStartDate(),
|
||||
fileOwnerDTO.getEndDate());
|
||||
return this.page(PageUtil.initPage(fileOwnerDTO), queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<File> customerPageOwner(FileOwnerDTO ownerDTO, File file, SearchVO searchVO, PageVO pageVo) {
|
||||
public IPage<File> customerPageOwner(FileOwnerDTO fileOwnerDTO) {
|
||||
LambdaQueryWrapper<File> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(CharSequenceUtil.isNotEmpty(ownerDTO.getOwnerId()), File::getOwnerId, ownerDTO.getOwnerId())
|
||||
.eq(File::getUserEnums, ownerDTO.getUserEnums())
|
||||
.like(CharSequenceUtil.isNotEmpty(file.getName()), File::getName, file.getName())
|
||||
.like(CharSequenceUtil.isNotEmpty(file.getFileKey()), File::getFileKey, file.getFileKey())
|
||||
.like(CharSequenceUtil.isNotEmpty(file.getFileType()), File::getFileType, file.getFileType())
|
||||
.between(CharSequenceUtil.isNotEmpty(searchVO.getStartDate()) && CharSequenceUtil.isNotEmpty(searchVO.getEndDate()),
|
||||
File::getCreateTime, searchVO.getStartDate(), searchVO.getEndDate());
|
||||
return this.page(PageUtil.initPage(pageVo), queryWrapper);
|
||||
queryWrapper.eq(CharSequenceUtil.isNotEmpty(fileOwnerDTO.getOwnerId()), File::getOwnerId,
|
||||
fileOwnerDTO.getOwnerId()).eq(File::getUserEnums, fileOwnerDTO.getUserEnums())
|
||||
.eq(CharSequenceUtil.isNotEmpty(fileOwnerDTO.getFileDirectoryId()), File::getFileDirectoryId,
|
||||
fileOwnerDTO.getFileDirectoryId())
|
||||
.like(CharSequenceUtil.isNotEmpty(fileOwnerDTO.getName()), File::getName, fileOwnerDTO.getName())
|
||||
.like(CharSequenceUtil.isNotEmpty(fileOwnerDTO.getFileKey()), File::getFileKey, fileOwnerDTO.getFileKey())
|
||||
.like(CharSequenceUtil.isNotEmpty(fileOwnerDTO.getFileType()), File::getFileType,
|
||||
fileOwnerDTO.getFileType()).between(
|
||||
CharSequenceUtil.isNotEmpty(fileOwnerDTO.getStartDate()) && CharSequenceUtil.isNotEmpty(
|
||||
fileOwnerDTO.getEndDate()), File::getCreateTime, fileOwnerDTO.getStartDate(),
|
||||
fileOwnerDTO.getEndDate());
|
||||
return this.page(PageUtil.initPage(fileOwnerDTO), queryWrapper);
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -163,6 +164,9 @@ public class GoodsSku extends BaseEntity {
|
||||
@ApiModelProperty(value = "商品类型", required = true)
|
||||
private String goodsType;
|
||||
|
||||
@ApiModelProperty(value = "预警数量")
|
||||
private Integer alertQuantity;
|
||||
|
||||
public Double getWeight() {
|
||||
if (weight == null) {
|
||||
return 0d;
|
||||
@@ -170,6 +174,13 @@ public class GoodsSku extends BaseEntity {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public Integer getAlertQuantity() {
|
||||
if(alertQuantity == null){
|
||||
return 0;
|
||||
}
|
||||
return alertQuantity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getCreateTime() {
|
||||
if (super.getCreateTime() == null) {
|
||||
@@ -199,6 +210,7 @@ public class GoodsSku extends BaseEntity {
|
||||
this.mobileIntro = goods.getMobileIntro();
|
||||
this.goodsUnit = goods.getGoodsUnit();
|
||||
this.grade = 100D;
|
||||
this.alertQuantity = 0;
|
||||
//商品状态
|
||||
this.authFlag = goods.getAuthFlag();
|
||||
this.salesModel = goods.getSalesModel();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.lili.modules.goods.entity.dto;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -32,4 +33,18 @@ public class CategorySearchParams {
|
||||
@ApiModelProperty(value = "父节点名称")
|
||||
private String parentTitle;
|
||||
|
||||
@ApiModelProperty(value = "是否禁用")
|
||||
private Boolean deleteFlag;
|
||||
|
||||
public <T > QueryWrapper<T> queryWrapper() {
|
||||
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.like(name != null, "name", name);
|
||||
queryWrapper.like(parentTitle != null, "parent_title", parentTitle);
|
||||
queryWrapper.eq(parentId != null, "parent_id", parentId);
|
||||
queryWrapper.eq(level != null, "level", level);
|
||||
queryWrapper.eq(sortOrder != null, "sort_order", sortOrder);
|
||||
queryWrapper.eq(commissionRate != null, "commission_rate", commissionRate);
|
||||
queryWrapper.eq(deleteFlag != null, "delete_flag", deleteFlag);
|
||||
return queryWrapper;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 商品导入DTO
|
||||
@@ -36,7 +35,7 @@ public class GoodsImportDTO {
|
||||
private Boolean release;
|
||||
|
||||
@ApiModelProperty(value = "商品图片")
|
||||
private List<Map<String, String>> images;
|
||||
private List<String> images;
|
||||
private List<String> goodsGalleryList;
|
||||
|
||||
@ApiModelProperty(value = "成本价")
|
||||
|
||||
@@ -2,7 +2,6 @@ package cn.lili.modules.goods.entity.dto;
|
||||
|
||||
import cn.lili.common.validation.EnumValue;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsTypeEnum;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
@@ -96,7 +95,8 @@ public class GoodsOperationDTO implements Serializable {
|
||||
@ApiModelProperty(value = "是否有规格", hidden = true)
|
||||
private String haveSpec;
|
||||
|
||||
@ApiModelProperty(value = "销售模式", required = true)
|
||||
@ApiModelProperty(value = "商品单位", required = true)
|
||||
@NotEmpty(message = "商品单位不能为空")
|
||||
private String goodsUnit;
|
||||
|
||||
@ApiModelProperty(value = "商品描述")
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.lili.modules.goods.entity.dto;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
|
||||
@@ -9,6 +10,7 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品查询条件
|
||||
@@ -25,6 +27,7 @@ public class GoodsSearchParams extends PageVO {
|
||||
|
||||
private static final long serialVersionUID = 2544015852728566887L;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "商品编号")
|
||||
private String goodsId;
|
||||
|
||||
@@ -34,6 +37,9 @@ public class GoodsSearchParams extends PageVO {
|
||||
@ApiModelProperty(value = "商品编号")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "商品编号")
|
||||
private List<String> ids;
|
||||
|
||||
@ApiModelProperty(value = "商家ID")
|
||||
private String storeId;
|
||||
|
||||
@@ -85,6 +91,9 @@ public class GoodsSearchParams extends PageVO {
|
||||
@ApiModelProperty(value = "销售模式", required = true)
|
||||
private String salesModel;
|
||||
|
||||
@ApiModelProperty(value = "预警库存")
|
||||
private Boolean alertQuantity;
|
||||
|
||||
public <T> QueryWrapper<T> queryWrapper() {
|
||||
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
||||
if (CharSequenceUtil.isNotEmpty(goodsId)) {
|
||||
@@ -96,6 +105,9 @@ public class GoodsSearchParams extends PageVO {
|
||||
if (CharSequenceUtil.isNotEmpty(id)) {
|
||||
queryWrapper.in("id", Arrays.asList(id.split(",")));
|
||||
}
|
||||
if (CollUtil.isNotEmpty(ids)) {
|
||||
queryWrapper.in("id", ids);
|
||||
}
|
||||
if (CharSequenceUtil.isNotEmpty(storeId)) {
|
||||
queryWrapper.eq("store_id", storeId);
|
||||
}
|
||||
@@ -121,7 +133,7 @@ public class GoodsSearchParams extends PageVO {
|
||||
queryWrapper.le("quantity", leQuantity);
|
||||
}
|
||||
if (geQuantity != null) {
|
||||
queryWrapper.ge("quantity", geQuantity);
|
||||
queryWrapper.gt("quantity", geQuantity);
|
||||
}
|
||||
if (recommend != null) {
|
||||
queryWrapper.le("recommend", recommend);
|
||||
@@ -132,6 +144,11 @@ public class GoodsSearchParams extends PageVO {
|
||||
if (CharSequenceUtil.isNotEmpty(salesModel)) {
|
||||
queryWrapper.eq("sales_model", salesModel);
|
||||
}
|
||||
if(alertQuantity != null && alertQuantity){
|
||||
queryWrapper.apply("quantity <= alert_quantity");
|
||||
queryWrapper.ge("alert_quantity", 0);
|
||||
}
|
||||
queryWrapper.in(CollUtil.isNotEmpty(ids), "id", ids);
|
||||
|
||||
queryWrapper.eq("delete_flag", false);
|
||||
this.betweenWrapper(queryWrapper);
|
||||
|
||||
@@ -12,11 +12,30 @@ import lombok.Data;
|
||||
@Data
|
||||
public class GoodsSkuStockDTO {
|
||||
|
||||
@ApiModelProperty(value = "商品id")
|
||||
private String goodsId;
|
||||
|
||||
@ApiModelProperty(value = "商品skuId")
|
||||
private String skuId;
|
||||
|
||||
@ApiModelProperty(value = "库存")
|
||||
private Integer quantity;
|
||||
|
||||
@ApiModelProperty(value = "预警库存")
|
||||
private Integer alertQuantity;
|
||||
|
||||
@ApiModelProperty(value = "规格信息")
|
||||
private String simpleSpecs;
|
||||
|
||||
@ApiModelProperty(value = "商品编号")
|
||||
private String sn;
|
||||
|
||||
@ApiModelProperty(value = "商品名称")
|
||||
private String goodsName;
|
||||
|
||||
/**
|
||||
* @see cn.lili.modules.goods.entity.enums.GoodsStockTypeEnum
|
||||
*/
|
||||
@ApiModelProperty(value = "类型")
|
||||
private String type;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package cn.lili.modules.goods.entity.enums;
|
||||
|
||||
/**
|
||||
* 库存操作类型
|
||||
*/
|
||||
public enum GoodsStockTypeEnum {
|
||||
|
||||
|
||||
SUB("减"),
|
||||
|
||||
ADD("增");
|
||||
|
||||
private final String description;
|
||||
|
||||
GoodsStockTypeEnum(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
// 根据描述获取枚举实例
|
||||
public static GoodsStockTypeEnum fromDescription(String description) {
|
||||
for (GoodsStockTypeEnum type : GoodsStockTypeEnum.values()) {
|
||||
if (type.getDescription().equals(description)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
throw new IllegalArgumentException("No matching enum constant for description: " + description);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,18 +32,5 @@ public class SpecValueVO implements Serializable {
|
||||
* 规格图片
|
||||
*/
|
||||
@ApiModelProperty(value = "规格的图片")
|
||||
private List<SpecImages> specImage;
|
||||
|
||||
@Data
|
||||
public static class SpecImages implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1816357809660916086L;
|
||||
|
||||
private String url;
|
||||
|
||||
private String name;
|
||||
|
||||
private String status;
|
||||
|
||||
}
|
||||
private List<String> specImage;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,9 @@ package cn.lili.modules.goods.mapper;
|
||||
|
||||
import cn.lili.modules.goods.entity.dos.GoodsSku;
|
||||
import cn.lili.modules.goods.entity.dto.GoodsSkuDTO;
|
||||
import cn.lili.modules.goods.entity.dto.GoodsSkuStockDTO;
|
||||
import cn.lili.modules.order.order.entity.dto.OrderExportDTO;
|
||||
import cn.lili.modules.order.order.entity.vo.OrderSimpleVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
@@ -114,4 +117,7 @@ public interface GoodsSkuMapper extends BaseMapper<GoodsSku> {
|
||||
@Select("SELECT *,g.params as params FROM li_goods_sku gs inner join li_goods g on gs.goods_id = g.id ${ew.customSqlSegment}")
|
||||
IPage<GoodsSkuDTO> queryByParams(IPage<GoodsSkuDTO> page, @Param(Constants.WRAPPER) Wrapper<GoodsSkuDTO> queryWrapper);
|
||||
|
||||
@Select("SELECT id as sku_id, quantity, goods_id,simple_specs,sn,goods_name FROM li_goods_sku ${ew.customSqlSegment}")
|
||||
List<GoodsSkuStockDTO> queryStocks(@Param(Constants.WRAPPER) Wrapper<GoodsSku> queryWrapper);
|
||||
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package cn.lili.modules.goods.service;
|
||||
|
||||
|
||||
import cn.lili.modules.goods.entity.dos.Category;
|
||||
import cn.lili.modules.goods.entity.dto.CategorySearchParams;
|
||||
import cn.lili.modules.goods.entity.vos.CategoryVO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
@@ -69,9 +70,10 @@ public interface CategoryService extends IService<Category> {
|
||||
* 查询所有的分类,父子关系
|
||||
* 数据库获取
|
||||
*
|
||||
* @param categorySearchParams 查询参数
|
||||
* @return 所有的分类,父子关系
|
||||
*/
|
||||
List<CategoryVO> listAllChildren();
|
||||
List<CategoryVO> listAllChildren(CategorySearchParams categorySearchParams);
|
||||
|
||||
/**
|
||||
* 获取指定分类的分类名称
|
||||
|
||||
@@ -28,13 +28,6 @@ public interface GoodsService extends IService<Goods> {
|
||||
*/
|
||||
List<Goods> getByBrandIds(List<String> brandIds);
|
||||
|
||||
/**
|
||||
* 下架所有商家商品
|
||||
*
|
||||
* @param storeId 店铺ID
|
||||
*/
|
||||
void underStoreGoods(String storeId);
|
||||
|
||||
/**
|
||||
* 更新商品参数
|
||||
*
|
||||
@@ -113,16 +106,6 @@ public interface GoodsService extends IService<Goods> {
|
||||
Boolean updateGoodsMarketAble(List<String> goodsIds, GoodsStatusEnum goodsStatusEnum, String underReason);
|
||||
|
||||
|
||||
/**
|
||||
* 更新商品上架状态状态
|
||||
*
|
||||
* @param storeId 店铺ID
|
||||
* @param goodsStatusEnum 更新的商品状态
|
||||
* @param underReason 下架原因
|
||||
* @return 更新结果
|
||||
*/
|
||||
Boolean updateGoodsMarketAbleByStoreId(String storeId, GoodsStatusEnum goodsStatusEnum, String underReason);
|
||||
|
||||
/**
|
||||
* 更新商品上架状态状态
|
||||
*
|
||||
@@ -153,16 +136,16 @@ public interface GoodsService extends IService<Goods> {
|
||||
* 修改商品库存数量
|
||||
*
|
||||
* @param goodsId 商品ID
|
||||
* @param quantity 库存数量
|
||||
*/
|
||||
void updateStock(String goodsId, Integer quantity);
|
||||
void updateStock(String goodsId);
|
||||
|
||||
/**
|
||||
* 更新商品评价数量
|
||||
*
|
||||
* @param goodsId 商品ID
|
||||
* @param skuId skuID
|
||||
*/
|
||||
void updateGoodsCommentNum(String goodsId);
|
||||
void updateGoodsCommentNum(String goodsId, String skuId);
|
||||
|
||||
/**
|
||||
* 更新商品的购买数量
|
||||
@@ -177,12 +160,6 @@ public interface GoodsService extends IService<Goods> {
|
||||
* @param store
|
||||
*/
|
||||
void updateStoreDetail(Store store);
|
||||
/**
|
||||
* 统计店铺的商品数量
|
||||
* @param storeId 店铺id
|
||||
* @return
|
||||
*/
|
||||
long countStoreGoodsNum(String storeId);
|
||||
|
||||
/**
|
||||
* 同步商品分类名称
|
||||
|
||||
@@ -12,7 +12,9 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -146,7 +148,20 @@ public interface GoodsSkuService extends IService<GoodsSku> {
|
||||
* @return 商品sku信息
|
||||
*/
|
||||
IPage<GoodsSku> getGoodsSkuByPage(GoodsSearchParams searchParams);
|
||||
/**
|
||||
* 查询导出商品库存
|
||||
*
|
||||
* @param searchParams 查询参数
|
||||
* @return 导出商品库存
|
||||
*/
|
||||
void queryExportStock(HttpServletResponse response, GoodsSearchParams searchParams);
|
||||
|
||||
/**
|
||||
* 导入商品库存
|
||||
* @param storeId 店铺ID
|
||||
* @param files 文件
|
||||
*/
|
||||
void importStock(String storeId, MultipartFile files);
|
||||
|
||||
/**
|
||||
* 分页查询商品sku信息
|
||||
@@ -187,6 +202,19 @@ public interface GoodsSkuService extends IService<GoodsSku> {
|
||||
* @param goodsSkuStockDTOS sku库存修改实体
|
||||
*/
|
||||
void updateStocks(List<GoodsSkuStockDTO> goodsSkuStockDTOS);
|
||||
void updateStocksByType(List<GoodsSkuStockDTO> goodsSkuStockDTOS);
|
||||
|
||||
/**
|
||||
* 更新SKU预警库存
|
||||
* @param goodsSkuStockDTOS sku库存修改实体
|
||||
*/
|
||||
void batchUpdateAlertQuantity(List<GoodsSkuStockDTO> goodsSkuStockDTOS);
|
||||
|
||||
/**
|
||||
* 更新SKU预警库存
|
||||
* @param goodsSkuStockDTO sku库存修改实体
|
||||
*/
|
||||
void updateAlertQuantity(GoodsSkuStockDTO goodsSkuStockDTO);
|
||||
|
||||
/**
|
||||
* 更新SKU库存
|
||||
@@ -195,6 +223,7 @@ public interface GoodsSkuService extends IService<GoodsSku> {
|
||||
* @param quantity 设置的库存数量
|
||||
*/
|
||||
void updateStock(String skuId, Integer quantity);
|
||||
void updateStock(String skuId, Integer quantity,String type);
|
||||
|
||||
/**
|
||||
* 获取商品sku库存
|
||||
@@ -209,14 +238,7 @@ public interface GoodsSkuService extends IService<GoodsSku> {
|
||||
*
|
||||
* @param goodsSkus
|
||||
*/
|
||||
void updateGoodsStuck(List<GoodsSku> goodsSkus);
|
||||
|
||||
/**
|
||||
* 更新SKU评价数量
|
||||
*
|
||||
* @param skuId SKUId
|
||||
*/
|
||||
void updateGoodsSkuCommentNum(String skuId);
|
||||
void updateGoodsStock(List<GoodsSku> goodsSkus);
|
||||
|
||||
/**
|
||||
* 根据商品id获取全部skuId的集合
|
||||
@@ -249,4 +271,38 @@ public interface GoodsSkuService extends IService<GoodsSku> {
|
||||
* @param goodsOperationDTO 商品操作信息
|
||||
*/
|
||||
void renderGoodsSkuList(List<GoodsSku> goodsSkuList, GoodsOperationDTO goodsOperationDTO);
|
||||
|
||||
/**
|
||||
* 更新商品sku购买数量
|
||||
*
|
||||
* @param skuId skuId
|
||||
* @param buyCount 购买数量
|
||||
*/
|
||||
void updateGoodsSkuBuyCount(String skuId, int buyCount);
|
||||
|
||||
/**
|
||||
* 更新商品sku评分
|
||||
*
|
||||
* @param goodsId goodsId
|
||||
* @param grade 评分
|
||||
* @param commentNum 评论数量
|
||||
*/
|
||||
void updateGoodsSkuGrade(String goodsId, double grade,int commentNum);
|
||||
|
||||
/**
|
||||
* 获取最新商品库存
|
||||
*
|
||||
* @param goodsId 商品ID
|
||||
* @return 库存数量
|
||||
*/
|
||||
Integer getGoodsStock(String goodsId);
|
||||
|
||||
/**
|
||||
* 更新sku运费模版
|
||||
*
|
||||
* @param goodsId 商品id
|
||||
* @param templateId 运费模版id
|
||||
* @return 操作结果
|
||||
*/
|
||||
Boolean freight(List<String> goodsId, String templateId);
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import cn.lili.common.event.TransactionCommitSendMQEvent;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.properties.RocketmqCustomProperties;
|
||||
import cn.lili.modules.goods.entity.dos.Category;
|
||||
import cn.lili.modules.goods.entity.dto.CategorySearchParams;
|
||||
import cn.lili.modules.goods.entity.vos.CategoryVO;
|
||||
import cn.lili.modules.goods.mapper.CategoryMapper;
|
||||
import cn.lili.modules.goods.service.CategoryBrandService;
|
||||
@@ -106,10 +107,10 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
|
||||
|
||||
@Override
|
||||
public List<CategoryVO> categoryTree() {
|
||||
// List<CategoryVO> categoryVOList = (List<CategoryVO>) cache.get(CachePrefix.CATEGORY.getPrefix());
|
||||
// if (categoryVOList != null) {
|
||||
// return categoryVOList;
|
||||
// }
|
||||
List<CategoryVO> categoryVOList = (List<CategoryVO>) cache.get(CachePrefix.CATEGORY.getPrefix());
|
||||
if (categoryVOList != null) {
|
||||
return categoryVOList;
|
||||
}
|
||||
|
||||
//获取全部分类
|
||||
LambdaQueryWrapper<Category> queryWrapper = new LambdaQueryWrapper<>();
|
||||
@@ -117,7 +118,7 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
|
||||
List<Category> list = this.list(queryWrapper);
|
||||
|
||||
//构造分类树
|
||||
List<CategoryVO> categoryVOList = new ArrayList<>();
|
||||
categoryVOList = new ArrayList<>();
|
||||
for (Category category : list) {
|
||||
if ("0".equals(category.getParentId())) {
|
||||
CategoryVO categoryVO = new CategoryVO(category);
|
||||
@@ -165,10 +166,10 @@ public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CategoryVO> listAllChildren() {
|
||||
public List<CategoryVO> listAllChildren(CategorySearchParams categorySearchParams) {
|
||||
|
||||
//获取全部分类
|
||||
List<Category> list = this.list();
|
||||
List<Category> list = this.list(categorySearchParams.queryWrapper());
|
||||
|
||||
//构造分类树
|
||||
List<CategoryVO> categoryVOList = new ArrayList<>();
|
||||
|
||||
@@ -101,7 +101,7 @@ public class GoodsGalleryServiceImpl extends ServiceImpl<GoodsGalleryMapper, Goo
|
||||
switch (OssEnum.valueOf(ossSetting.getType())) {
|
||||
case MINIO:
|
||||
//缩略图全路径
|
||||
return url + "?x-oss-process=style/" + width + "X" + height;
|
||||
return url;
|
||||
case ALI_OSS:
|
||||
//缩略图全路径
|
||||
return url + "?x-oss-process=style/" + width + "X" + height;
|
||||
|
||||
@@ -33,7 +33,9 @@ import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@Slf4j
|
||||
@Service
|
||||
@@ -112,7 +114,7 @@ public class GoodsImportServiceImpl implements GoodsImportService {
|
||||
|
||||
List<String> freightTemplateNameList = new ArrayList<>();
|
||||
//循环列表,存放ID-运费模板名称
|
||||
for (FreightTemplateVO freightTemplateVO : freightTemplateService.getFreightTemplateList(storeId)) {
|
||||
for (FreightTemplateVO freightTemplateVO : freightTemplateService.getFreightTemplateList()) {
|
||||
freightTemplateNameList.add(freightTemplateVO.getId() + "-" + freightTemplateVO.getName());
|
||||
}
|
||||
|
||||
@@ -203,15 +205,11 @@ public class GoodsImportServiceImpl implements GoodsImportService {
|
||||
goodsImportDTO.setCategory(category);
|
||||
goodsImportDTO.setTemplate(templateId);
|
||||
goodsImportDTO.setGoodsUnit(objects.get(4).toString().substring(objects.get(4).toString().indexOf("-") + 1));
|
||||
goodsImportDTO.setRelease(objects.get(5).toString().equals("上架") ? true : false);
|
||||
goodsImportDTO.setRelease(objects.get(5).toString().equals("上架"));
|
||||
|
||||
List<Map<String, String>> images = new ArrayList<>();
|
||||
List<String> goodsGalleryList = new ArrayList<>();
|
||||
Map<String, String> map = new HashMap<>();
|
||||
map.put("url", objects.get(6).toString());
|
||||
images.add(map);
|
||||
goodsGalleryList.add(objects.get(6).toString());
|
||||
goodsImportDTO.setImages(images);
|
||||
goodsImportDTO.setImages(goodsGalleryList);
|
||||
goodsImportDTO.setGoodsGalleryList(goodsGalleryList);
|
||||
|
||||
goodsImportDTO.setCost(Convert.toDouble(objects.get(7)));
|
||||
@@ -241,7 +239,7 @@ public class GoodsImportServiceImpl implements GoodsImportService {
|
||||
|
||||
//获取父
|
||||
Category parentCategory = categoryService.getCategoryById(goodsImportDTO.getCategory().getParentId());
|
||||
goodsOperationDTO.setCategoryPath(parentCategory.getParentId() + "," + parentCategory.getId() + "," + goodsImportDTO.getCategory().getParentId());
|
||||
goodsOperationDTO.setCategoryPath(parentCategory.getParentId() + "," + parentCategory.getId() + "," + goodsImportDTO.getCategory().getId());
|
||||
//添加商品
|
||||
goodsService.addGoods(goodsOperationDTO);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cn.lili.modules.goods.serviceimpl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
@@ -13,10 +14,7 @@ import cn.lili.common.properties.RocketmqCustomProperties;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.modules.goods.entity.dos.Category;
|
||||
import cn.lili.modules.goods.entity.dos.Goods;
|
||||
import cn.lili.modules.goods.entity.dos.GoodsGallery;
|
||||
import cn.lili.modules.goods.entity.dos.Wholesale;
|
||||
import cn.lili.modules.goods.entity.dos.*;
|
||||
import cn.lili.modules.goods.entity.dto.GoodsOperationDTO;
|
||||
import cn.lili.modules.goods.entity.dto.GoodsParamsDTO;
|
||||
import cn.lili.modules.goods.entity.dto.GoodsSearchParams;
|
||||
@@ -26,15 +24,18 @@ import cn.lili.modules.goods.entity.vos.GoodsSkuVO;
|
||||
import cn.lili.modules.goods.entity.vos.GoodsVO;
|
||||
import cn.lili.modules.goods.mapper.GoodsMapper;
|
||||
import cn.lili.modules.goods.service.*;
|
||||
import cn.lili.modules.member.entity.dos.MemberEvaluation;
|
||||
import cn.lili.modules.member.entity.dto.EvaluationQueryParams;
|
||||
import cn.lili.modules.member.entity.enums.EvaluationGradeEnum;
|
||||
import cn.lili.modules.member.service.MemberEvaluationService;
|
||||
import cn.lili.modules.search.utils.EsIndexUtil;
|
||||
import cn.lili.modules.store.entity.dos.FreightTemplate;
|
||||
import cn.lili.modules.store.entity.dos.Store;
|
||||
import cn.lili.modules.store.entity.vos.StoreVO;
|
||||
import cn.lili.modules.store.service.FreightTemplateService;
|
||||
import cn.lili.modules.store.service.StoreService;
|
||||
import cn.lili.modules.system.aspect.annotation.SystemLogPoint;
|
||||
import cn.lili.modules.system.entity.dos.Setting;
|
||||
import cn.lili.modules.system.entity.dto.BaseSetting;
|
||||
import cn.lili.modules.system.entity.dto.GoodsSetting;
|
||||
import cn.lili.modules.system.entity.enums.SettingEnum;
|
||||
import cn.lili.modules.system.service.SettingService;
|
||||
@@ -56,6 +57,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 商品业务层实现
|
||||
@@ -127,19 +129,6 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
return list(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void underStoreGoods(String storeId) {
|
||||
//获取商品ID列表
|
||||
List<String> list = this.baseMapper.getGoodsIdByStoreId(storeId);
|
||||
//下架店铺下的商品
|
||||
this.updateGoodsMarketAbleByStoreId(storeId, GoodsStatusEnum.DOWN, "店铺关闭");
|
||||
|
||||
applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("下架商品",
|
||||
rocketmqCustomProperties.getGoodsTopic(), GoodsTagsEnum.DOWN.name(), JSONUtil.toJsonStr(list)));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品参数
|
||||
*
|
||||
@@ -165,6 +154,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@SystemLogPoint(description = "添加商品", customerLog = "'新增商品名称:['+#goodsOperationDTO.goodsName+']'")
|
||||
public void addGoods(GoodsOperationDTO goodsOperationDTO) {
|
||||
Goods goods = new Goods(goodsOperationDTO);
|
||||
//检查商品
|
||||
@@ -192,6 +182,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@SystemLogPoint(description = "修改商品", customerLog = "'操作的商品ID:['+#goodsId+']'")
|
||||
public void editGoods(GoodsOperationDTO goodsOperationDTO, String goodsId) {
|
||||
Goods goods = new Goods(goodsOperationDTO);
|
||||
goods.setId(goodsId);
|
||||
@@ -290,6 +281,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
@SystemLogPoint(description = "审核商品", customerLog = "'操作的商品ID:['+#goodsIds+'],操作后商品状态:['+#goodsAuthEnum+']'")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean auditGoods(List<String> goodsIds, GoodsAuthEnum goodsAuthEnum) {
|
||||
List<String> goodsCacheKeys = new ArrayList<>();
|
||||
@@ -312,6 +304,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@SystemLogPoint(description = "商品状态操作", customerLog = "'操作类型:['+#goodsStatusEnum+'],操作对象:['+#goodsIds+'],操作原因:['+#underReason+']'")
|
||||
public Boolean updateGoodsMarketAble(List<String> goodsIds, GoodsStatusEnum goodsStatusEnum, String underReason) {
|
||||
boolean result;
|
||||
|
||||
@@ -334,31 +327,11 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新商品上架状态状态
|
||||
*
|
||||
* @param storeId 店铺ID
|
||||
* @param goodsStatusEnum 更新的商品状态
|
||||
* @param underReason 下架原因
|
||||
* @return 更新结果
|
||||
*/
|
||||
@Override
|
||||
public Boolean updateGoodsMarketAbleByStoreId(String storeId, GoodsStatusEnum goodsStatusEnum, String underReason) {
|
||||
|
||||
|
||||
LambdaUpdateWrapper<Goods> updateWrapper = this.getUpdateWrapperByStoreAuthority();
|
||||
updateWrapper.set(Goods::getMarketEnable, goodsStatusEnum.name());
|
||||
updateWrapper.set(Goods::getUnderMessage, underReason);
|
||||
updateWrapper.eq(Goods::getStoreId, storeId);
|
||||
boolean result = this.update(updateWrapper);
|
||||
|
||||
//修改规格商品
|
||||
this.goodsSkuService.updateGoodsSkuStatusByStoreId(storeId, goodsStatusEnum.name(), null);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SystemLogPoint(description = "管理员关闭下架商品", customerLog = "'操作类型:['+#goodsStatusEnum+'],操作对象:['+#goodsIds+'],操作原因:['+#underReason+']'")
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
|
||||
public Boolean managerUpdateGoodsMarketAble(List<String> goodsIds, GoodsStatusEnum goodsStatusEnum, String underReason) {
|
||||
boolean result;
|
||||
|
||||
@@ -386,6 +359,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@SystemLogPoint(description = "删除商品", customerLog = "'操作对象:['+#goodsIds+']'")
|
||||
public Boolean deleteGoods(List<String> goodsIds) {
|
||||
|
||||
LambdaUpdateWrapper<Goods> updateWrapper = this.getUpdateWrapperByStoreAuthority();
|
||||
@@ -420,43 +394,67 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
if (freightTemplate == null) {
|
||||
throw new ServiceException(ResultCode.FREIGHT_TEMPLATE_NOT_EXIST);
|
||||
}
|
||||
if (authUser != null && !freightTemplate.getStoreId().equals(authUser.getStoreId())) {
|
||||
if (authUser != null) {
|
||||
throw new ServiceException(ResultCode.USER_AUTHORITY_ERROR);
|
||||
}
|
||||
LambdaUpdateWrapper<Goods> lambdaUpdateWrapper = Wrappers.lambdaUpdate();
|
||||
lambdaUpdateWrapper.set(Goods::getTemplateId, templateId);
|
||||
lambdaUpdateWrapper.in(Goods::getId, goodsIds);
|
||||
cache.multiDel(goodsIds);
|
||||
List<String> goodsCache = goodsIds.stream().map(item -> CachePrefix.GOODS.getPrefix() + item).collect(Collectors.toList());
|
||||
cache.multiDel(goodsCache);
|
||||
goodsSkuService.freight(goodsIds, templateId);
|
||||
return this.update(lambdaUpdateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateStock(String goodsId, Integer quantity) {
|
||||
@SystemLogPoint(description = "同步商品库存", customerLog = "'同步商品商品ID的库存:['+#goodsId+']'")
|
||||
public void updateStock(String goodsId) {
|
||||
LambdaUpdateWrapper<Goods> lambdaUpdateWrapper = Wrappers.lambdaUpdate();
|
||||
lambdaUpdateWrapper.set(Goods::getQuantity, quantity);
|
||||
Integer stock = goodsSkuService.getGoodsStock(goodsId);
|
||||
lambdaUpdateWrapper.set(Goods::getQuantity, stock);
|
||||
lambdaUpdateWrapper.eq(Goods::getId, goodsId);
|
||||
cache.remove(CachePrefix.GOODS.getPrefix() + goodsId);
|
||||
this.update(lambdaUpdateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateGoodsCommentNum(String goodsId) {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateGoodsCommentNum(String goodsId, String skuId) {
|
||||
GoodsSku goodsSku = goodsSkuService.getGoodsSkuByIdFromCache(skuId);
|
||||
if (goodsSku == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
//获取商品信息
|
||||
Goods goods = this.getById(goodsId);
|
||||
//修改商品评价数量
|
||||
goods.setCommentNum(goods.getCommentNum() + 1);
|
||||
|
||||
//修改商品好评率
|
||||
LambdaQueryWrapper<MemberEvaluation> goodEvaluationQueryWrapper = new LambdaQueryWrapper<>();
|
||||
goodEvaluationQueryWrapper.eq(MemberEvaluation::getId, goodsId);
|
||||
goodEvaluationQueryWrapper.eq(MemberEvaluation::getGrade, EvaluationGradeEnum.GOOD.name());
|
||||
if (goods == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
//修改商品评价数量
|
||||
long commentNum = memberEvaluationService.getEvaluationCount(EvaluationQueryParams.builder().goodsId(goodsId).status("OPEN").build());
|
||||
goods.setCommentNum((int) (commentNum));
|
||||
|
||||
//好评数量
|
||||
long highPraiseNum = memberEvaluationService.count(goodEvaluationQueryWrapper);
|
||||
long highPraiseNum = memberEvaluationService.getEvaluationCount(EvaluationQueryParams.builder().goodsId(goodsId).status("OPEN").grade(EvaluationGradeEnum.GOOD.name()).build());
|
||||
//好评率
|
||||
double grade = NumberUtil.mul(NumberUtil.div(highPraiseNum, goods.getCommentNum().doubleValue(), 2), 100);
|
||||
goods.setGrade(grade);
|
||||
this.updateById(goods);
|
||||
LambdaUpdateWrapper<Goods> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(Goods::getId, goodsId);
|
||||
updateWrapper.set(Goods::getCommentNum, goods.getCommentNum());
|
||||
updateWrapper.set(Goods::getGrade, goods.getGrade());
|
||||
this.update(updateWrapper);
|
||||
|
||||
cache.remove(CachePrefix.GOODS.getPrefix() + goodsId);
|
||||
|
||||
|
||||
// 修改商品sku评价数量
|
||||
this.goodsSkuService.updateGoodsSkuGrade(goodsId, grade, goods.getCommentNum());
|
||||
|
||||
Map<String, Object> updateIndexFieldsMap = EsIndexUtil.getUpdateIndexFieldsMap(MapUtil.builder(new HashMap<String, Object>()).put("goodsId", goodsId).build(), MapUtil.builder(new HashMap<String, Object>()).put("commentNum", goods.getCommentNum()).put("highPraiseNum", highPraiseNum).put("grade", grade).build());
|
||||
applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("更新商品索引信息", rocketmqCustomProperties.getGoodsTopic(), GoodsTagsEnum.UPDATE_GOODS_INDEX_FIELD.name(), JSONUtil.toJsonStr(updateIndexFieldsMap)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -483,16 +481,6 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
goodsSkuService.update(updateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long countStoreGoodsNum(String storeId) {
|
||||
return this.count(
|
||||
new LambdaQueryWrapper<Goods>()
|
||||
.eq(Goods::getStoreId, storeId)
|
||||
.eq(Goods::getDeleteFlag, Boolean.FALSE)
|
||||
.eq(Goods::getAuthFlag, GoodsAuthEnum.PASS.name())
|
||||
.eq(Goods::getMarketEnable, GoodsStatusEnum.UPPER.name()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void categoryGoodsName(String categoryId) {
|
||||
//获取分类下的商品
|
||||
@@ -548,7 +536,8 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
if (!GoodsStatusEnum.UPPER.name().equals(goods.getMarketEnable()) || !GoodsAuthEnum.PASS.name().equals(goods.getAuthFlag())) {
|
||||
return;
|
||||
}
|
||||
applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("生成商品", rocketmqCustomProperties.getGoodsTopic(), GoodsTagsEnum.GENERATOR_GOODS_INDEX.name(), goods.getId()));
|
||||
applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("生成商品", rocketmqCustomProperties.getGoodsTopic(),
|
||||
GoodsTagsEnum.GENERATOR_GOODS_INDEX.name(), goods.getId()));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -558,7 +547,8 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
*/
|
||||
@Transactional
|
||||
public void updateEsGoods(List<String> goodsIds) {
|
||||
applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("更新商品", rocketmqCustomProperties.getGoodsTopic(), GoodsTagsEnum.UPDATE_GOODS_INDEX.name(), goodsIds));
|
||||
applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("更新商品", rocketmqCustomProperties.getGoodsTopic(),
|
||||
GoodsTagsEnum.UPDATE_GOODS_INDEX.name(), goodsIds));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -568,7 +558,8 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
*/
|
||||
@Transactional
|
||||
public void deleteEsGoods(List<String> goodsIds) {
|
||||
applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("删除商品", rocketmqCustomProperties.getGoodsTopic(), GoodsTagsEnum.GOODS_DELETE.name(), JSONUtil.toJsonStr(goodsIds)));
|
||||
applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("删除商品", rocketmqCustomProperties.getGoodsTopic(),
|
||||
GoodsTagsEnum.GOODS_DELETE.name(), JSONUtil.toJsonStr(goodsIds)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -627,20 +618,14 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
//获取商品系统配置决定是否审核
|
||||
Setting setting = settingService.get(SettingEnum.GOODS_SETTING.name());
|
||||
GoodsSetting goodsSetting = JSONUtil.toBean(setting.getSettingValue(), GoodsSetting.class);
|
||||
Setting baseSetting = settingService.get(SettingEnum.BASE_SETTING.name());
|
||||
BaseSetting baseSettingValue = JSONUtil.toBean(baseSetting.getSettingValue(), BaseSetting.class);
|
||||
//是否需要审核
|
||||
goods.setAuthFlag(Boolean.TRUE.equals(goodsSetting.getGoodsCheck()) ? GoodsAuthEnum.TOBEAUDITED.name() : GoodsAuthEnum.PASS.name());
|
||||
//判断当前用户是否为店铺
|
||||
if (Objects.requireNonNull(UserContext.getCurrentUser()).getRole().equals(UserEnums.STORE)) {
|
||||
StoreVO storeDetail = this.storeService.getStoreDetail();
|
||||
if (storeDetail.getSelfOperated() != null) {
|
||||
goods.setSelfOperated(storeDetail.getSelfOperated());
|
||||
}
|
||||
goods.setStoreId(storeDetail.getId());
|
||||
goods.setStoreName(storeDetail.getStoreName());
|
||||
goods.setSelfOperated(storeDetail.getSelfOperated());
|
||||
} else {
|
||||
throw new ServiceException(ResultCode.STORE_NOT_LOGIN_ERROR);
|
||||
}
|
||||
//平台商品,默认处理
|
||||
goods.setStoreId("-1");
|
||||
goods.setStoreName(baseSettingValue.getSiteName());
|
||||
goods.setSelfOperated(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -668,7 +653,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
LambdaUpdateWrapper<Goods> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
AuthUser authUser = this.checkStoreAuthority();
|
||||
if (authUser != null) {
|
||||
updateWrapper.eq(Goods::getStoreId, authUser.getStoreId());
|
||||
updateWrapper.eq(Goods::getStoreId, "-1");
|
||||
}
|
||||
return updateWrapper;
|
||||
}
|
||||
@@ -682,7 +667,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
private AuthUser checkStoreAuthority() {
|
||||
AuthUser currentUser = UserContext.getCurrentUser();
|
||||
//如果当前会员不为空,且为店铺角色
|
||||
if (currentUser != null && (currentUser.getRole().equals(UserEnums.STORE) && currentUser.getStoreId() != null)) {
|
||||
if (currentUser != null) {
|
||||
return currentUser;
|
||||
}
|
||||
return null;
|
||||
@@ -712,7 +697,7 @@ public class GoodsServiceImpl extends ServiceImpl<GoodsMapper, Goods> implements
|
||||
LambdaQueryWrapper<Goods> queryWrapper = new LambdaQueryWrapper<>();
|
||||
AuthUser authUser = this.checkStoreAuthority();
|
||||
if (authUser != null) {
|
||||
queryWrapper.eq(Goods::getStoreId, authUser.getStoreId());
|
||||
queryWrapper.eq(Goods::getStoreId, "-1");
|
||||
}
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package cn.lili.modules.goods.serviceimpl;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.cache.Cache;
|
||||
@@ -26,6 +25,7 @@ import cn.lili.modules.goods.entity.dto.GoodsSkuStockDTO;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsStockTypeEnum;
|
||||
import cn.lili.modules.goods.entity.vos.GoodsSkuSpecVO;
|
||||
import cn.lili.modules.goods.entity.vos.GoodsSkuVO;
|
||||
import cn.lili.modules.goods.entity.vos.GoodsVO;
|
||||
@@ -38,9 +38,6 @@ import cn.lili.modules.goods.service.WholesaleService;
|
||||
import cn.lili.modules.goods.sku.GoodsSkuBuilder;
|
||||
import cn.lili.modules.goods.sku.render.SalesModelRender;
|
||||
import cn.lili.modules.member.entity.dos.FootPrint;
|
||||
import cn.lili.modules.member.entity.dto.EvaluationQueryParams;
|
||||
import cn.lili.modules.member.entity.enums.EvaluationGradeEnum;
|
||||
import cn.lili.modules.member.service.MemberEvaluationService;
|
||||
import cn.lili.modules.promotion.entity.dos.Coupon;
|
||||
import cn.lili.modules.promotion.entity.dos.PromotionGoods;
|
||||
import cn.lili.modules.promotion.entity.dto.search.PromotionGoodsSearchParams;
|
||||
@@ -50,7 +47,6 @@ import cn.lili.modules.promotion.service.MemberCouponService;
|
||||
import cn.lili.modules.promotion.service.PromotionGoodsService;
|
||||
import cn.lili.modules.search.entity.dos.EsGoodsIndex;
|
||||
import cn.lili.modules.search.service.EsGoodsIndexService;
|
||||
import cn.lili.modules.search.utils.EsIndexUtil;
|
||||
import cn.lili.mybatis.BaseEntity;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
|
||||
@@ -61,12 +57,22 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.poi.ss.usermodel.*;
|
||||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.ss.util.CellRangeAddressList;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -104,11 +110,6 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
*/
|
||||
@Autowired
|
||||
private RocketmqCustomProperties rocketmqCustomProperties;
|
||||
/**
|
||||
* 会员评价
|
||||
*/
|
||||
@Autowired
|
||||
private MemberEvaluationService memberEvaluationService;
|
||||
/**
|
||||
* 商品
|
||||
*/
|
||||
@@ -148,7 +149,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
|
||||
if (!goodsSkus.isEmpty()) {
|
||||
this.saveOrUpdateBatch(goodsSkus);
|
||||
this.updateStock(goodsSkus);
|
||||
this.updateGoodsStock(goodsSkus);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,7 +200,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
skuList.stream().map(BaseEntity::getId).collect(Collectors.toList()));
|
||||
this.remove(unnecessarySkuIdsQuery);
|
||||
this.saveOrUpdateBatch(skuList);
|
||||
this.updateStock(skuList);
|
||||
this.updateGoodsStock(skuList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,6 +341,11 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
}
|
||||
|
||||
}
|
||||
if (goodsSkuDetail.getGoodsGalleryList() == null || goodsSkuDetail.getGoodsGalleryList().isEmpty()) {
|
||||
goodsSkuDetail.setGoodsGalleryList(goodsVO.getGoodsGalleryList());
|
||||
} else {
|
||||
goodsSkuDetail.getGoodsGalleryList().addAll(goodsVO.getGoodsGalleryList());
|
||||
}
|
||||
map.put("data", goodsSkuDetail);
|
||||
|
||||
//获取分类
|
||||
@@ -385,7 +391,9 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
List<GoodsSku> goodsSkus = this.getGoodsSkuListByGoodsId(goods.getId());
|
||||
for (GoodsSku sku : goodsSkus) {
|
||||
cache.remove(GoodsSkuService.getCacheKeys(sku.getId()));
|
||||
cache.put(GoodsSkuService.getCacheKeys(sku.getId()), sku);
|
||||
if (GoodsStatusEnum.UPPER.name().equals(goods.getMarketEnable()) && GoodsAuthEnum.PASS.name().equals(goods.getAuthFlag())) {
|
||||
cache.put(GoodsSkuService.getCacheKeys(sku.getId()), sku);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -478,13 +486,10 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
SpecValueVO specValueVO = new SpecValueVO();
|
||||
if ("images".equals(entry.getKey())) {
|
||||
specValueVO.setSpecName(entry.getKey());
|
||||
if (entry.getValue().toString().contains("url")) {
|
||||
List<SpecValueVO.SpecImages> specImages = JSONUtil.toList(JSONUtil.parseArray(entry.getValue()),
|
||||
SpecValueVO.SpecImages.class);
|
||||
specValueVO.setSpecImage(specImages);
|
||||
goodsGalleryList =
|
||||
specImages.stream().map(SpecValueVO.SpecImages::getUrl).collect(Collectors.toList());
|
||||
}
|
||||
List<String> specImages = JSONUtil.toList(JSONUtil.parseArray(entry.getValue()),
|
||||
String.class);
|
||||
specValueVO.setSpecImage(specImages);
|
||||
goodsGalleryList = new ArrayList<>(specImages);
|
||||
} else {
|
||||
specValueVO.setSpecName(entry.getKey());
|
||||
specValueVO.setSpecValue(entry.getValue().toString());
|
||||
@@ -501,6 +506,115 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
return this.page(PageUtil.initPage(searchParams), searchParams.queryWrapper());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void queryExportStock(HttpServletResponse response, GoodsSearchParams searchParams) {
|
||||
List<GoodsSkuStockDTO> goodsSkuStockDTOList = this.baseMapper.queryStocks(searchParams.queryWrapper());
|
||||
XSSFWorkbook workbook = initStockExportData(goodsSkuStockDTOList);
|
||||
try {
|
||||
// 设置响应头
|
||||
String fileName = URLEncoder.encode("商品库存", "UTF-8");
|
||||
response.setContentType("application/vnd.ms-excel;charset=UTF-8");
|
||||
response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx");
|
||||
|
||||
ServletOutputStream out = response.getOutputStream();
|
||||
workbook.write(out);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
workbook.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importStock(String storeId, MultipartFile file) {
|
||||
List<GoodsSkuStockDTO> goodsSkuStockDTOList = new ArrayList<>();
|
||||
try (InputStream inputStream = file.getInputStream()) {
|
||||
// 使用 WorkbookFactory.create 方法读取 Excel 文件
|
||||
Workbook workbook = WorkbookFactory.create(inputStream);
|
||||
Sheet sheet = workbook.getSheetAt(0); // 我们只读取第一个sheet
|
||||
|
||||
// 检查第一个sheet的行数是否超过10002行
|
||||
if (sheet.getPhysicalNumberOfRows() > 10002) {
|
||||
throw new ServiceException(ResultCode.GOODS_STOCK_IMPORT_ERROR, "Excel行数超过10002行");
|
||||
}
|
||||
// 遍历行和单元格
|
||||
Iterator<Row> rowIterator = sheet.rowIterator();
|
||||
int rowIndex = 0;
|
||||
while (rowIterator.hasNext()) {
|
||||
Row row = rowIterator.next();
|
||||
rowIndex++;
|
||||
|
||||
// 跳过表头
|
||||
if (rowIndex < 3) {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<Object> objects = new ArrayList<>();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
objects.add(getCellValue(row.getCell(i)));
|
||||
}
|
||||
log.error(getCellValue(row.getCell(2)));
|
||||
log.error(getCellValue(row.getCell(3)));
|
||||
// 判断数据格式
|
||||
if (!"增".equals(getCellValue(row.getCell(2))) && !"减".equals(getCellValue(row.getCell(2)))) {
|
||||
throw new ServiceException(ResultCode.GOODS_STOCK_IMPORT_ERROR, "库存修改方向列数据必须是“增”或“减”");
|
||||
} else if (!NumberUtil.isInteger(getCellValue(row.getCell(3))) || Integer.parseInt(getCellValue(row.getCell(3))) < 0) {
|
||||
throw new ServiceException(ResultCode.GOODS_STOCK_IMPORT_ERROR, "库存必须是正整数");
|
||||
} else if (this.count(new LambdaQueryWrapper<GoodsSku>()
|
||||
.eq(GoodsSku::getGoodsId, getCellValue(row.getCell(0)))
|
||||
.eq(GoodsSku::getId, getCellValue(row.getCell(1)))
|
||||
.eq(GoodsSku::getStoreId, storeId)) == 0) {
|
||||
throw new ServiceException(ResultCode.GOODS_STOCK_IMPORT_ERROR, "第" + rowIndex + "行商品不存在");
|
||||
}
|
||||
GoodsSkuStockDTO goodsSkuStockDTO = new GoodsSkuStockDTO();
|
||||
goodsSkuStockDTO.setGoodsId(getCellValue(row.getCell(0)));
|
||||
goodsSkuStockDTO.setSkuId(getCellValue(row.getCell(1)));
|
||||
goodsSkuStockDTO.setType(GoodsStockTypeEnum.fromDescription(getCellValue(row.getCell(2))).name());
|
||||
goodsSkuStockDTO.setQuantity(Integer.parseInt(getCellValue(row.getCell(3))));
|
||||
goodsSkuStockDTOList.add(goodsSkuStockDTO);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
log.error("IOException occurred while processing the Excel file.", e);
|
||||
throw new ServiceException(ResultCode.GOODS_STOCK_IMPORT_ERROR, e.getMessage());
|
||||
}
|
||||
|
||||
// 批量修改商品库存
|
||||
this.updateStocksByType(goodsSkuStockDTOList);
|
||||
}
|
||||
|
||||
private String getCellValue(Cell cell) {
|
||||
if (cell == null) {
|
||||
return "";
|
||||
}
|
||||
switch (cell.getCellType()) {
|
||||
case STRING:
|
||||
return cell.getStringCellValue();
|
||||
case NUMERIC:
|
||||
if (DateUtil.isCellDateFormatted(cell)) {
|
||||
return cell.getDateCellValue().toString();
|
||||
} else {
|
||||
// 将数值转换为整数以去掉小数点
|
||||
double numericValue = cell.getNumericCellValue();
|
||||
if (numericValue == (long) numericValue) {
|
||||
return String.valueOf((long) numericValue);
|
||||
} else {
|
||||
return String.valueOf(numericValue);
|
||||
}
|
||||
}
|
||||
case BOOLEAN:
|
||||
return String.valueOf(cell.getBooleanCellValue());
|
||||
case FORMULA:
|
||||
return cell.getCellFormula();
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IPage<GoodsSkuDTO> getGoodsSkuDTOByPage(Page<GoodsSkuDTO> page, Wrapper<GoodsSkuDTO> queryWrapper) {
|
||||
return this.baseMapper.queryByParams(page, queryWrapper);
|
||||
@@ -520,42 +634,140 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateStocks(List<GoodsSkuStockDTO> goodsSkuStockDTOS) {
|
||||
for (GoodsSkuStockDTO goodsSkuStockDTO : goodsSkuStockDTOS) {
|
||||
this.updateStock(goodsSkuStockDTO.getSkuId(), goodsSkuStockDTO.getQuantity());
|
||||
List<String> skuIds = goodsSkuStockDTOS.stream().map(GoodsSkuStockDTO::getSkuId).collect(Collectors.toList());
|
||||
List<GoodsSkuStockDTO> goodsSkuStockList = this.baseMapper.queryStocks(GoodsSearchParams.builder().ids(skuIds).build().queryWrapper());
|
||||
Map<String, List<GoodsSkuStockDTO>> groupByGoodsIds = goodsSkuStockList.stream().collect(Collectors.groupingBy(GoodsSkuStockDTO::getGoodsId));
|
||||
|
||||
//统计每个商品的库存
|
||||
for (Map.Entry<String, List<GoodsSkuStockDTO>> entry : groupByGoodsIds.entrySet()) {
|
||||
//库存
|
||||
for (GoodsSkuStockDTO goodsSku : entry.getValue()) {
|
||||
goodsSkuStockDTOS.stream().filter(i -> i.getSkuId().equals(goodsSku.getSkuId())).findFirst().ifPresent(i -> goodsSku.setQuantity(i.getQuantity()));
|
||||
|
||||
this.updateStock(goodsSku.getSkuId(), goodsSku.getQuantity());
|
||||
}
|
||||
//保存商品库存结果
|
||||
goodsService.updateStock(entry.getKey());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateStocksByType(List<GoodsSkuStockDTO> goodsSkuStockDTOS) {
|
||||
|
||||
// 获取所有的goodsID,并去除相同的goodsID
|
||||
List<String> goodsIds = goodsSkuStockDTOS.stream()
|
||||
.map(GoodsSkuStockDTO::getGoodsId)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
//更新SKU库存
|
||||
for (GoodsSkuStockDTO goodsSkuStockDTO : goodsSkuStockDTOS) {
|
||||
this.updateStock(goodsSkuStockDTO.getSkuId(), goodsSkuStockDTO.getQuantity(), goodsSkuStockDTO.getType());
|
||||
}
|
||||
//更新SPU库存
|
||||
for (String goodsId : goodsIds) {
|
||||
goodsService.updateStock(goodsId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateAlertQuantity(GoodsSkuStockDTO goodsSkuStockDTO) {
|
||||
GoodsSku goodsSku = this.getById(goodsSkuStockDTO.getSkuId());
|
||||
goodsSku.setAlertQuantity(goodsSkuStockDTO.getAlertQuantity());
|
||||
//清除缓存,防止修改预警后直接修改商品导致预警数值错误
|
||||
cache.remove(CachePrefix.GOODS.getPrefix() + goodsSku.getGoodsId());
|
||||
this.update(goodsSku);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void batchUpdateAlertQuantity(List<GoodsSkuStockDTO> goodsSkuStockDTOS) {
|
||||
List<GoodsSku> goodsSkuList = new ArrayList<>();
|
||||
List<String> skuIds = goodsSkuStockDTOS.stream().map(GoodsSkuStockDTO::getSkuId).collect(Collectors.toList());
|
||||
List<GoodsSkuStockDTO> goodsSkuStockList = this.baseMapper.queryStocks(GoodsSearchParams.builder().ids(skuIds).build().queryWrapper());
|
||||
List<String> goodsIdList = goodsSkuStockList.stream().map(GoodsSkuStockDTO::getGoodsId).collect(Collectors.toList());
|
||||
HashSet<String> uniqueSet = new HashSet<>(goodsIdList);
|
||||
// 将去重后的元素转回列表
|
||||
List<String> uniqueGoodsIdList = new ArrayList<>(uniqueSet);
|
||||
for (String goodsId : uniqueGoodsIdList) {
|
||||
cache.remove(CachePrefix.GOODS.getPrefix() + goodsId);
|
||||
}
|
||||
//修改预警库存
|
||||
for (GoodsSkuStockDTO goodsSkuStockDTO : goodsSkuStockDTOS) {
|
||||
GoodsSku goodsSku = this.getById(goodsSkuStockDTO.getSkuId());
|
||||
goodsSku.setAlertQuantity(goodsSkuStockDTO.getAlertQuantity());
|
||||
goodsSkuList.add(goodsSku);
|
||||
}
|
||||
this.updateBatchById(goodsSkuList);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateStock(String skuId, Integer quantity) {
|
||||
GoodsSku goodsSku = getGoodsSkuByIdFromCache(skuId);
|
||||
if (goodsSku != null) {
|
||||
//判断商品sku是否已经下架(修改商品库存为0时 会自动下架商品),再次更新商品库存时 需更新商品索引
|
||||
Boolean isFlag = goodsSku.getQuantity()<= 0;
|
||||
boolean isFlag = goodsSku.getQuantity() <= 0;
|
||||
|
||||
goodsSku.setQuantity(quantity);
|
||||
boolean update =
|
||||
this.update(new LambdaUpdateWrapper<GoodsSku>().eq(GoodsSku::getId, skuId).set(GoodsSku::getQuantity, quantity));
|
||||
boolean update = this.update(new LambdaUpdateWrapper<GoodsSku>().eq(GoodsSku::getId, skuId).set(GoodsSku::getQuantity, quantity));
|
||||
if (update) {
|
||||
cache.remove(CachePrefix.GOODS.getPrefix() + goodsSku.getGoodsId());
|
||||
}
|
||||
cache.put(GoodsSkuService.getCacheKeys(skuId), goodsSku);
|
||||
cache.put(GoodsSkuService.getStockCacheKey(skuId), quantity);
|
||||
|
||||
//更新商品库存
|
||||
List<GoodsSku> goodsSkus = new ArrayList<>();
|
||||
goodsSkus.add(goodsSku);
|
||||
this.updateGoodsStuck(goodsSkus);
|
||||
this.promotionGoodsService.updatePromotionGoodsStock(goodsSku.getId(), quantity);
|
||||
//商品库存为0是删除商品索引
|
||||
if (quantity <= 0) {
|
||||
goodsIndexService.deleteIndexById(goodsSku.getId());
|
||||
}
|
||||
//商品SKU库存为0并且商品sku状态为上架时更新商品库存
|
||||
if(isFlag && StrUtil.equals(goodsSku.getMarketEnable(),GoodsStatusEnum.UPPER.name())) {
|
||||
if (isFlag && CharSequenceUtil.equals(goodsSku.getMarketEnable(), GoodsStatusEnum.UPPER.name())) {
|
||||
List<String> goodsIds = new ArrayList<>();
|
||||
goodsIds.add(goodsSku.getGoodsId());
|
||||
applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("更新商品", rocketmqCustomProperties.getGoodsTopic(), GoodsTagsEnum.UPDATE_GOODS_INDEX.name(), goodsIds));
|
||||
applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("更新商品", rocketmqCustomProperties.getGoodsTopic(),
|
||||
GoodsTagsEnum.UPDATE_GOODS_INDEX.name(), goodsIds));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateStock(String skuId, Integer quantity, String type) {
|
||||
GoodsSku goodsSku = getGoodsSkuByIdFromCache(skuId);
|
||||
if (goodsSku != null) {
|
||||
|
||||
//计算修改库存
|
||||
if (type.equals(GoodsStockTypeEnum.ADD.name())) {
|
||||
quantity = Convert.toInt(NumberUtil.add(goodsSku.getQuantity(), quantity));
|
||||
} else {
|
||||
quantity = Convert.toInt(NumberUtil.sub(goodsSku.getQuantity(), quantity));
|
||||
}
|
||||
goodsSku.setQuantity(quantity);
|
||||
|
||||
//判断商品sku是否已经下架(修改商品库存为0时 会自动下架商品),再次更新商品库存时 需更新商品索引
|
||||
boolean isFlag = goodsSku.getQuantity() <= 0;
|
||||
|
||||
boolean update = this.update(new LambdaUpdateWrapper<GoodsSku>().eq(GoodsSku::getId, skuId).set(GoodsSku::getQuantity, quantity));
|
||||
if (update) {
|
||||
cache.remove(CachePrefix.GOODS.getPrefix() + goodsSku.getGoodsId());
|
||||
}
|
||||
cache.put(GoodsSkuService.getCacheKeys(skuId), goodsSku);
|
||||
cache.put(GoodsSkuService.getStockCacheKey(skuId), quantity);
|
||||
|
||||
this.promotionGoodsService.updatePromotionGoodsStock(goodsSku.getId(), quantity);
|
||||
//商品库存为0是删除商品索引
|
||||
if (quantity <= 0) {
|
||||
goodsIndexService.deleteIndexById(goodsSku.getId());
|
||||
}
|
||||
//商品SKU库存为0并且商品sku状态为上架时更新商品库存
|
||||
if (isFlag && CharSequenceUtil.equals(goodsSku.getMarketEnable(), GoodsStatusEnum.UPPER.name())) {
|
||||
List<String> goodsIds = new ArrayList<>();
|
||||
goodsIds.add(goodsSku.getGoodsId());
|
||||
applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("更新商品", rocketmqCustomProperties.getGoodsTopic(),
|
||||
GoodsTagsEnum.UPDATE_GOODS_INDEX.name(), goodsIds));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -575,66 +787,26 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateGoodsStuck(List<GoodsSku> goodsSkus) {
|
||||
Map<String, List<GoodsSku>> groupByGoodsIds =
|
||||
goodsSkus.stream().collect(Collectors.groupingBy(GoodsSku::getGoodsId));
|
||||
//获取相关的sku集合
|
||||
LambdaQueryWrapper<GoodsSku> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.in(GoodsSku::getGoodsId, groupByGoodsIds.keySet());
|
||||
List<GoodsSku> goodsSkuList = this.list(lambdaQueryWrapper);
|
||||
public void updateGoodsStock(List<GoodsSku> goodsSkus) {
|
||||
Map<String, List<GoodsSku>> groupByGoodsIds = goodsSkus.stream().collect(Collectors.groupingBy(GoodsSku::getGoodsId));
|
||||
|
||||
//统计每个商品的库存
|
||||
for (String goodsId : groupByGoodsIds.keySet()) {
|
||||
//库存
|
||||
Integer quantity = 0;
|
||||
for (GoodsSku goodsSku : goodsSkuList) {
|
||||
for (GoodsSku goodsSku : goodsSkus) {
|
||||
if (goodsId.equals(goodsSku.getGoodsId())) {
|
||||
quantity += goodsSku.getQuantity();
|
||||
}
|
||||
this.updateStock(goodsSku.getId(), goodsSku.getQuantity());
|
||||
}
|
||||
//保存商品库存结果
|
||||
goodsService.updateStock(goodsId, quantity);
|
||||
goodsService.updateStock(goodsId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateGoodsSkuCommentNum(String skuId) {
|
||||
//获取商品信息
|
||||
GoodsSku goodsSku = this.getGoodsSkuByIdFromCache(skuId);
|
||||
|
||||
EvaluationQueryParams queryParams = new EvaluationQueryParams();
|
||||
queryParams.setGrade(EvaluationGradeEnum.GOOD.name());
|
||||
queryParams.setSkuId(goodsSku.getId());
|
||||
//好评数量
|
||||
long highPraiseNum = memberEvaluationService.getEvaluationCount(queryParams);
|
||||
|
||||
//更新商品评价数量
|
||||
goodsSku.setCommentNum(goodsSku.getCommentNum() != null ? goodsSku.getCommentNum() + 1 : 1);
|
||||
|
||||
//好评率
|
||||
double grade = NumberUtil.mul(NumberUtil.div(highPraiseNum, goodsSku.getCommentNum().doubleValue(), 2), 100);
|
||||
goodsSku.setGrade(grade);
|
||||
//修改规格
|
||||
this.update(goodsSku);
|
||||
|
||||
|
||||
//修改规格索引,发送mq消息
|
||||
Map<String, Object> updateIndexFieldsMap =
|
||||
EsIndexUtil.getUpdateIndexFieldsMap(MapUtil.builder(new HashMap<String, Object>()).put("id",
|
||||
goodsSku.getId()).build(), MapUtil.builder(new HashMap<String, Object>()).put("commentNum",
|
||||
goodsSku.getCommentNum()).put("highPraiseNum", highPraiseNum).put("grade", grade).build());
|
||||
String destination =
|
||||
rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.UPDATE_GOODS_INDEX_FIELD.name();
|
||||
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(updateIndexFieldsMap),
|
||||
RocketmqSendCallbackBuilder.commonCallback());
|
||||
|
||||
//修改商品的评价数量
|
||||
goodsService.updateGoodsCommentNum(goodsSku.getGoodsId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据商品id获取全部skuId的集合
|
||||
*
|
||||
@@ -663,26 +835,11 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
public Long countSkuNum(String storeId) {
|
||||
LambdaQueryWrapper<GoodsSku> queryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
queryWrapper.eq(GoodsSku::getStoreId, storeId).eq(GoodsSku::getDeleteFlag, Boolean.FALSE).eq(GoodsSku::getAuthFlag, GoodsAuthEnum.PASS.name()).eq(GoodsSku::getMarketEnable, GoodsStatusEnum.UPPER.name());
|
||||
queryWrapper.eq(GoodsSku::getStoreId, storeId).eq(GoodsSku::getDeleteFlag, Boolean.FALSE).eq(GoodsSku::getAuthFlag,
|
||||
GoodsAuthEnum.PASS.name()).eq(GoodsSku::getMarketEnable, GoodsStatusEnum.UPPER.name());
|
||||
return this.count(queryWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改库存
|
||||
*
|
||||
* @param goodsSkus 商品SKU
|
||||
*/
|
||||
private void updateStock(List<GoodsSku> goodsSkus) {
|
||||
//总库存数量
|
||||
Integer quantity = 0;
|
||||
for (GoodsSku sku : goodsSkus) {
|
||||
this.updateStock(sku.getId(), sku.getQuantity());
|
||||
quantity += sku.getQuantity();
|
||||
}
|
||||
//修改商品库存
|
||||
goodsService.updateStock(goodsSkus.get(0).getGoodsId(), quantity);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量渲染商品sku
|
||||
@@ -696,10 +853,52 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
salesModelRenders.stream().filter(i -> i.getSalesMode().equals(goodsOperationDTO.getSalesModel())).findFirst().ifPresent(i -> i.renderBatch(goodsSkuList, goodsOperationDTO));
|
||||
for (GoodsSku goodsSku : goodsSkuList) {
|
||||
extendOldSkuValue(goodsSku);
|
||||
this.renderImages(goodsSku);
|
||||
this.renderImages(goodsSku, goodsOperationDTO.getGoodsGalleryList());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateGoodsSkuBuyCount(String skuId, int buyCount) {
|
||||
LambdaUpdateWrapper<GoodsSku> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(GoodsSku::getId, skuId);
|
||||
updateWrapper.set(GoodsSku::getBuyCount, buyCount);
|
||||
this.update(updateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateGoodsSkuGrade(String goodsId, double grade, int commentNum) {
|
||||
LambdaUpdateWrapper<GoodsSku> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(GoodsSku::getGoodsId, goodsId);
|
||||
updateWrapper.set(GoodsSku::getGrade, grade);
|
||||
updateWrapper.set(GoodsSku::getCommentNum, commentNum);
|
||||
this.update(updateWrapper);
|
||||
this.getSkuIdsByGoodsId(goodsId).forEach(this::clearCache);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getGoodsStock(String goodsId) {
|
||||
List<String> skuIds = this.getSkuIdsByGoodsId(goodsId);
|
||||
|
||||
Integer stock = 0;
|
||||
|
||||
for (String skuId : skuIds) {
|
||||
stock += this.getStock(skuId);
|
||||
}
|
||||
return stock;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean freight(List<String> goodsId, String templateId) {
|
||||
LambdaUpdateWrapper<GoodsSku> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.in(GoodsSku::getGoodsId, goodsId);
|
||||
updateWrapper.set(GoodsSku::getFreightTemplateId, templateId);
|
||||
updateWrapper.set(GoodsSku::getUpdateTime, new Date());
|
||||
List<String> skuIds = this.list(updateWrapper).stream().map(GoodsSku::getId).collect(Collectors.toList());
|
||||
skuIds.forEach(this::clearCache);
|
||||
return this.update(updateWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染商品sku
|
||||
*
|
||||
@@ -710,7 +909,7 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
extendOldSkuValue(goodsSku);
|
||||
// 商品销售模式渲染器
|
||||
salesModelRenders.stream().filter(i -> i.getSalesMode().equals(goodsOperationDTO.getSalesModel())).findFirst().ifPresent(i -> i.renderSingle(goodsSku, goodsOperationDTO));
|
||||
this.renderImages(goodsSku);
|
||||
this.renderImages(goodsSku, goodsOperationDTO.getGoodsGalleryList());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -735,16 +934,23 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
*
|
||||
* @param goodsSku sku
|
||||
*/
|
||||
void renderImages(GoodsSku goodsSku) {
|
||||
JSONObject jsonObject = JSONUtil.parseObj(goodsSku.getSpecs());
|
||||
List<Map<String, String>> images = jsonObject.get("images", List.class);
|
||||
if (images != null && !images.isEmpty()) {
|
||||
GoodsGallery goodsGallery = goodsGalleryService.getGoodsGallery(images.get(0).get("url"));
|
||||
goodsSku.setBig(goodsGallery.getOriginal());
|
||||
goodsSku.setOriginal(goodsGallery.getOriginal());
|
||||
goodsSku.setThumbnail(goodsGallery.getThumbnail());
|
||||
goodsSku.setSmall(goodsGallery.getSmall());
|
||||
void renderImages(GoodsSku goodsSku, List<String> goodsImages) {
|
||||
if (goodsImages == null || goodsImages.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
JSONObject jsonObject = JSONUtil.parseObj(goodsSku.getSpecs());
|
||||
List<String> images = jsonObject.getBeanList("images", String.class);
|
||||
GoodsGallery goodsGallery;
|
||||
if (images != null && !images.isEmpty()) {
|
||||
goodsGallery = goodsGalleryService.getGoodsGallery(images.get(0));
|
||||
} else {
|
||||
goodsGallery = goodsGalleryService.getGoodsGallery(goodsImages.get(0));
|
||||
}
|
||||
|
||||
goodsSku.setBig(goodsGallery.getOriginal());
|
||||
goodsSku.setOriginal(goodsGallery.getOriginal());
|
||||
goodsSku.setThumbnail(goodsGallery.getThumbnail());
|
||||
goodsSku.setSmall(goodsGallery.getSmall());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -766,4 +972,150 @@ public class GoodsSkuServiceImpl extends ServiceImpl<GoodsSkuMapper, GoodsSku> i
|
||||
return skuSpecVOList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化填充商品库存导出数据
|
||||
*
|
||||
* @param goodsSkuStockDTOList 导出的库存数据
|
||||
* @return 商品库存导出列表
|
||||
*/
|
||||
private XSSFWorkbook initStockExportData(List<GoodsSkuStockDTO> goodsSkuStockDTOList) {
|
||||
|
||||
XSSFWorkbook workbook = new XSSFWorkbook();
|
||||
// 创建模板
|
||||
this.createTemplate(workbook);
|
||||
// 创建sku库存列表
|
||||
this.skuStockList(workbook, goodsSkuStockDTOList);
|
||||
// 创建sku库存列表
|
||||
this.skuList(workbook, goodsSkuStockDTOList);
|
||||
return workbook;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建模板
|
||||
*
|
||||
* @param workbook
|
||||
*/
|
||||
private void createTemplate(XSSFWorkbook workbook) {
|
||||
Sheet templateSheet = workbook.createSheet("商品库存编辑模板");
|
||||
|
||||
// 创建表头
|
||||
Row description = templateSheet.createRow(0);
|
||||
description.setHeightInPoints(90);
|
||||
Cell descriptionCell = description.createCell(0);
|
||||
descriptionCell.setCellValue("填写说明(请勿删除本说明):\n" +
|
||||
"1.可批量设置多个商品的库存,一次最多10000行\n" +
|
||||
"2.库存修改方向:选择库存方向后,会在原先库存基础上进行增加或者减少\n" +
|
||||
"3.库存变更数量:需要为整数,不能填写0和负数");
|
||||
// 合并描述行的单元格
|
||||
templateSheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 3));
|
||||
|
||||
// 设置描述行单元格样式(例如,自动换行)
|
||||
CellStyle descriptionStyle = workbook.createCellStyle();
|
||||
descriptionStyle.setWrapText(true);
|
||||
descriptionStyle.setAlignment(HorizontalAlignment.LEFT);
|
||||
descriptionStyle.setVerticalAlignment(VerticalAlignment.CENTER);
|
||||
descriptionCell.setCellStyle(descriptionStyle);
|
||||
|
||||
// 创建表头
|
||||
Row header = templateSheet.createRow(1);
|
||||
|
||||
String[] headers = {"商品ID(必填)", "skuID(必填)", "库存修改方向(必填,填 增 或者 减)", "库存变更数量(必填)"};
|
||||
|
||||
CellStyle headerStyle = workbook.createCellStyle();
|
||||
Font headerFont = workbook.createFont();
|
||||
headerFont.setBold(true);
|
||||
headerStyle.setFont(headerFont);
|
||||
for (int i = 0; i < headers.length; i++) {
|
||||
Cell cell = header.createCell(i);
|
||||
cell.setCellValue(headers[i]);
|
||||
cell.setCellStyle(headerStyle);
|
||||
}
|
||||
//修改列宽
|
||||
templateSheet.setColumnWidth(0, 30 * 256);
|
||||
templateSheet.setColumnWidth(1, 30 * 256);
|
||||
templateSheet.setColumnWidth(2, 40 * 256);
|
||||
templateSheet.setColumnWidth(3, 25 * 256);
|
||||
|
||||
// 设置下拉列表数据验证
|
||||
DataValidationHelper validationHelper = templateSheet.getDataValidationHelper();
|
||||
DataValidationConstraint constraint = validationHelper.createExplicitListConstraint(new String[]{"增", "减"});
|
||||
CellRangeAddressList addressList = new CellRangeAddressList(2, 10001, 2, 2); // 从第3行到第10002行,第3列
|
||||
DataValidation validation = validationHelper.createValidation(constraint, addressList);
|
||||
validation.setSuppressDropDownArrow(true);
|
||||
validation.setShowErrorBox(true);
|
||||
templateSheet.addValidationData(validation);
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建sku库存列表
|
||||
*
|
||||
* @param workbook
|
||||
*/
|
||||
private void skuStockList(XSSFWorkbook workbook, List<GoodsSkuStockDTO> goodsSkuStockDTOList) {
|
||||
Sheet skuListSheet = workbook.createSheet("商品库存信息");
|
||||
|
||||
// 创建表头
|
||||
Row header = skuListSheet.createRow(0);
|
||||
|
||||
String[] headers = {"商品ID", "商品名称", "规格ID(SKUID)", "规格名称", "货号", "当前库存数量"};
|
||||
|
||||
for (int i = 0; i < headers.length; i++) {
|
||||
Cell cell = header.createCell(i);
|
||||
cell.setCellValue(headers[i]);
|
||||
}
|
||||
|
||||
|
||||
// 填充数据
|
||||
for (int i = 0; i < goodsSkuStockDTOList.size(); i++) {
|
||||
GoodsSkuStockDTO dto = goodsSkuStockDTOList.get(i);
|
||||
Row row = skuListSheet.createRow(i + 1);
|
||||
row.createCell(0).setCellValue(dto.getGoodsId());
|
||||
row.createCell(1).setCellValue(dto.getGoodsName());
|
||||
row.createCell(2).setCellValue(dto.getSkuId());
|
||||
row.createCell(3).setCellValue(dto.getSimpleSpecs());
|
||||
row.createCell(4).setCellValue(dto.getSn());
|
||||
row.createCell(5).setCellValue(dto.getQuantity());
|
||||
}
|
||||
|
||||
//修改列宽
|
||||
skuListSheet.setColumnWidth(0, 30 * 256);
|
||||
skuListSheet.setColumnWidth(1, 30 * 256);
|
||||
skuListSheet.setColumnWidth(2, 30 * 256);
|
||||
skuListSheet.setColumnWidth(3, 30 * 256);
|
||||
skuListSheet.setColumnWidth(4, 30 * 256);
|
||||
skuListSheet.setColumnWidth(5, 15 * 256);
|
||||
}
|
||||
|
||||
private void skuList(XSSFWorkbook workbook, List<GoodsSkuStockDTO> goodsSkuStockDTOList) {
|
||||
Sheet skuListSheet = workbook.createSheet("商品规格");
|
||||
|
||||
// 创建表头
|
||||
Row header = skuListSheet.createRow(0);
|
||||
|
||||
String[] headers = {"商品ID", "商品名称", "规格ID(SKUID)", "规格名称", "货号"};
|
||||
|
||||
for (int i = 0; i < headers.length; i++) {
|
||||
Cell cell = header.createCell(i);
|
||||
cell.setCellValue(headers[i]);
|
||||
}
|
||||
|
||||
// 填充数据
|
||||
for (int i = 0; i < goodsSkuStockDTOList.size(); i++) {
|
||||
GoodsSkuStockDTO dto = goodsSkuStockDTOList.get(i);
|
||||
Row row = skuListSheet.createRow(i + 1);
|
||||
row.createCell(0).setCellValue(dto.getGoodsId());
|
||||
row.createCell(1).setCellValue(dto.getGoodsName());
|
||||
row.createCell(2).setCellValue(dto.getSkuId());
|
||||
row.createCell(3).setCellValue(dto.getSimpleSpecs());
|
||||
row.createCell(4).setCellValue(dto.getSn());
|
||||
}
|
||||
|
||||
//修改列宽
|
||||
skuListSheet.setColumnWidth(0, 30 * 256);
|
||||
skuListSheet.setColumnWidth(1, 30 * 256);
|
||||
skuListSheet.setColumnWidth(2, 30 * 256);
|
||||
skuListSheet.setColumnWidth(3, 30 * 256);
|
||||
skuListSheet.setColumnWidth(4, 30 * 256);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public class GoodsSkuBuilder {
|
||||
Map<String, Object> specMap = new LinkedHashMap<>();
|
||||
|
||||
// 原始规格项
|
||||
String[] ignoreOriginKeys = {"id", "sn", "cost", "price", "quantity", "weight"};
|
||||
String[] ignoreOriginKeys = {"id", "sn", "cost", "price", "quantity", "weight", "alertQuantity"};
|
||||
//获取规格信息
|
||||
for (Map.Entry<String, Object> spec : skuInfo.entrySet()) {
|
||||
//保存新增规格信息
|
||||
@@ -91,6 +91,7 @@ public class GoodsSkuBuilder {
|
||||
goodsSku.setQuantity(Convert.toInt(skuInfo.get("quantity"), 0));
|
||||
goodsSku.setSpecs(JSONUtil.toJsonStr(specMap));
|
||||
goodsSku.setSimpleSpecs(simpleSpecs.toString());
|
||||
goodsSku.setAlertQuantity(Convert.toInt(skuInfo.get("alertQuantity"), 0));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package cn.lili.modules.im.entity.dto;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.modules.im.entity.dos.ImTalk;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* @author paulG
|
||||
* @since 2023/2/6
|
||||
**/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class IMTalkQueryParams {
|
||||
|
||||
@ApiModelProperty("用户1 id")
|
||||
private String userId1;
|
||||
|
||||
@ApiModelProperty("用户2 id")
|
||||
private String userId2;
|
||||
|
||||
@ApiModelProperty("用户1 name")
|
||||
private String name1;
|
||||
|
||||
@ApiModelProperty("用户2 name")
|
||||
private String name2;
|
||||
|
||||
@ApiModelProperty("关键字")
|
||||
private String userName;
|
||||
|
||||
|
||||
public QueryWrapper<ImTalk> queryWrapper() {
|
||||
QueryWrapper<ImTalk> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq(CharSequenceUtil.isNotEmpty(userId1), "user_id1", this.userId1);
|
||||
queryWrapper.eq(CharSequenceUtil.isNotEmpty(userId2), "user_id2", this.userId2);
|
||||
queryWrapper.eq(CharSequenceUtil.isNotEmpty(name1), "name1", this.name1);
|
||||
queryWrapper.eq(CharSequenceUtil.isNotEmpty(name2), "name2", this.name2);
|
||||
queryWrapper.nested(CharSequenceUtil.isNotEmpty(userName), i -> i.like("name1", userName).or().like("name2", userName));
|
||||
return queryWrapper;
|
||||
}
|
||||
}
|
||||
@@ -6,15 +6,19 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author chc
|
||||
* @since 2022/6/2114:46
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@ApiModel
|
||||
public class ImQueryParams extends PageVO {
|
||||
|
||||
private static final long serialVersionUID = 5792718094087541134L;
|
||||
|
||||
@ApiModelProperty("用户Id")
|
||||
private String memberId;
|
||||
|
||||
@@ -29,7 +33,7 @@ public class ImQueryParams extends PageVO {
|
||||
if (CharSequenceUtil.isNotEmpty(storeId)) {
|
||||
queryWrapper.eq("store_id", storeId);
|
||||
}
|
||||
queryWrapper.eq("delete_flag",false);
|
||||
queryWrapper.eq("delete_flag", false);
|
||||
queryWrapper.orderByDesc("create_time");
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
package cn.lili.modules.im.entity.dto;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.utils.StringUtils;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.im.entity.dos.ImMessage;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* MessageQueryParams
|
||||
@@ -15,8 +16,12 @@ import lombok.Data;
|
||||
* @version v1.0
|
||||
* 2022-01-20 17:16
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class MessageQueryParams extends PageVO {
|
||||
|
||||
private static final long serialVersionUID = 3504156704697214077L;
|
||||
|
||||
/**
|
||||
* 聊天窗口
|
||||
*/
|
||||
@@ -31,7 +36,7 @@ public class MessageQueryParams extends PageVO {
|
||||
private Integer num;
|
||||
|
||||
public LambdaQueryWrapper<ImMessage> initQueryWrapper() {
|
||||
if (StringUtils.isEmpty(talkId)) {
|
||||
if (CharSequenceUtil.isEmpty(talkId)) {
|
||||
throw new ServiceException(ResultCode.ERROR);
|
||||
}
|
||||
if (num == null || num > 50) {
|
||||
@@ -40,7 +45,7 @@ public class MessageQueryParams extends PageVO {
|
||||
|
||||
LambdaQueryWrapper<ImMessage> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(ImMessage::getTalkId, talkId);
|
||||
if (StringUtils.isNotEmpty(lastMessageId)) {
|
||||
if (CharSequenceUtil.isNotEmpty(lastMessageId)) {
|
||||
lambdaQueryWrapper.lt(ImMessage::getId, lastMessageId);
|
||||
}
|
||||
lambdaQueryWrapper.orderByDesc(ImMessage::getCreateTime);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cn.lili.modules.im.service;
|
||||
|
||||
import cn.lili.modules.im.entity.dos.ImTalk;
|
||||
import cn.lili.modules.im.entity.dto.IMTalkQueryParams;
|
||||
import cn.lili.modules.im.entity.vo.ImTalkVO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
@@ -45,13 +46,13 @@ public interface ImTalkService extends IService<ImTalk> {
|
||||
|
||||
/**
|
||||
* 获取用户聊天列表
|
||||
* @return
|
||||
* @return 用户聊天列表
|
||||
*/
|
||||
List<ImTalkVO> getUserTalkList();
|
||||
List<ImTalkVO> getUserTalkList(IMTalkQueryParams imTalkQueryParams);
|
||||
|
||||
/**
|
||||
* 获取商家聊天列表
|
||||
* @return
|
||||
* @return 商家聊天列表
|
||||
*/
|
||||
List<ImTalkVO> getStoreTalkList();
|
||||
List<ImTalkVO> getStoreTalkList(IMTalkQueryParams imTalkQueryParams);
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.lili.modules.im.serviceimpl;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
@@ -7,6 +8,7 @@ import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.modules.im.entity.dos.ImMessage;
|
||||
import cn.lili.modules.im.entity.dos.ImTalk;
|
||||
import cn.lili.modules.im.entity.dto.IMTalkQueryParams;
|
||||
import cn.lili.modules.im.entity.vo.ImTalkVO;
|
||||
import cn.lili.modules.im.mapper.ImTalkMapper;
|
||||
import cn.lili.modules.im.service.ImMessageService;
|
||||
@@ -51,35 +53,35 @@ public class ImTalkServiceImpl extends ServiceImpl<ImTalkMapper, ImTalk> impleme
|
||||
//登录用户的Id
|
||||
String selfId = "";
|
||||
//查看当前用户角色对Id进行赋值
|
||||
if(UserEnums.STORE.equals(currentUser.getRole())){
|
||||
if (UserEnums.STORE.equals(currentUser.getRole())) {
|
||||
selfId = currentUser.getStoreId();
|
||||
}else if(UserEnums.MEMBER.equals(currentUser.getRole())){
|
||||
} else if (UserEnums.MEMBER.equals(currentUser.getRole())) {
|
||||
selfId = currentUser.getId();
|
||||
}
|
||||
//小数在前保证永远是同一个对话
|
||||
String finalSelfId = selfId;
|
||||
queryWrapper.and(wq-> wq.eq(ImTalk::getUserId2, userId).eq(ImTalk::getUserId1, finalSelfId).or().eq(ImTalk::getUserId2, finalSelfId).eq(ImTalk::getUserId1, userId));
|
||||
queryWrapper.and(wq -> wq.eq(ImTalk::getUserId2, userId).eq(ImTalk::getUserId1, finalSelfId).or().eq(ImTalk::getUserId2, finalSelfId).eq(ImTalk::getUserId1, userId));
|
||||
ImTalk imTalk = this.getOne(queryWrapper);
|
||||
//如果没有聊天,则创建聊天
|
||||
if (imTalk == null) {
|
||||
//当自己为店铺时
|
||||
if(UserEnums.STORE.equals(currentUser.getRole())){
|
||||
if (UserEnums.STORE.equals(currentUser.getRole())) {
|
||||
Store selfStore = storeService.getById(selfId);
|
||||
//没有这个用户信息
|
||||
Member other = memberService.getById(userId);
|
||||
if(other == null){
|
||||
if (other == null) {
|
||||
return null;
|
||||
}
|
||||
//自己为店铺其他人必定为用户
|
||||
imTalk = new ImTalk(other,selfStore);
|
||||
}else if(UserEnums.MEMBER.equals(currentUser.getRole())){
|
||||
imTalk = new ImTalk(other, selfStore);
|
||||
} else if (UserEnums.MEMBER.equals(currentUser.getRole())) {
|
||||
//没有这个店铺信息
|
||||
Member self = memberService.getById(selfId);
|
||||
Member otherMember = memberService.getById(userId);
|
||||
Store otherStore = storeService.getById(userId);
|
||||
if(otherStore != null){
|
||||
if (otherStore != null) {
|
||||
imTalk = new ImTalk(self, otherStore);
|
||||
}else if (otherMember != null){
|
||||
} else if (otherMember != null) {
|
||||
imTalk = new ImTalk(self, otherMember);
|
||||
}
|
||||
}
|
||||
@@ -95,41 +97,41 @@ public class ImTalkServiceImpl extends ServiceImpl<ImTalkMapper, ImTalk> impleme
|
||||
//登录用户的Id
|
||||
String selfId = "";
|
||||
//查看当前用户角色对Id进行赋值
|
||||
if(UserEnums.STORE.equals(currentUser.getRole())){
|
||||
if (UserEnums.STORE.equals(currentUser.getRole())) {
|
||||
selfId = currentUser.getStoreId();
|
||||
}else if(UserEnums.MEMBER.equals(currentUser.getRole())){
|
||||
} else if (UserEnums.MEMBER.equals(currentUser.getRole())) {
|
||||
selfId = currentUser.getId();
|
||||
}
|
||||
//小数在前保证永远是同一个对话
|
||||
String finalSelfId = selfId;
|
||||
queryWrapper.and(wq-> wq.eq(ImTalk::getUserId2, userId).eq(ImTalk::getUserId1, finalSelfId).or().eq(ImTalk::getUserId2, finalSelfId).eq(ImTalk::getUserId1, userId));
|
||||
queryWrapper.and(wq -> wq.eq(ImTalk::getUserId2, userId).eq(ImTalk::getUserId1, finalSelfId).or().eq(ImTalk::getUserId2, finalSelfId).eq(ImTalk::getUserId1, userId));
|
||||
ImTalk imTalk = this.getOne(queryWrapper);
|
||||
//如果没有聊天,则创建聊天
|
||||
if (imTalk == null) {
|
||||
//当自己为店铺时
|
||||
if(UserEnums.STORE.equals(currentUser.getRole())){
|
||||
if (UserEnums.STORE.equals(currentUser.getRole())) {
|
||||
Store selfStore = storeService.getById(selfId);
|
||||
//没有这个用户信息
|
||||
Member other = memberService.getById(userId);
|
||||
if(other == null){
|
||||
if (other == null) {
|
||||
return null;
|
||||
}
|
||||
//自己为店铺其他人必定为用户
|
||||
imTalk = new ImTalk(other,selfStore);
|
||||
}else if(UserEnums.MEMBER.equals(currentUser.getRole())){
|
||||
imTalk = new ImTalk(other, selfStore);
|
||||
} else if (UserEnums.MEMBER.equals(currentUser.getRole())) {
|
||||
//没有这个店铺信息
|
||||
Member self = memberService.getById(selfId);
|
||||
Member otherMember = memberService.getById(userId);
|
||||
Store otherStore = storeService.getById(userId);
|
||||
if(otherStore != null){
|
||||
if (otherStore != null) {
|
||||
imTalk = new ImTalk(self, otherStore);
|
||||
}else if (otherMember != null){
|
||||
} else if (otherMember != null) {
|
||||
imTalk = new ImTalk(self, otherMember);
|
||||
}
|
||||
}
|
||||
this.save(imTalk);
|
||||
}
|
||||
return new ImTalkVO(imTalk,currentUser.getId());
|
||||
return new ImTalkVO(imTalk, currentUser.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -173,13 +175,16 @@ public class ImTalkServiceImpl extends ServiceImpl<ImTalkMapper, ImTalk> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ImTalkVO> getUserTalkList() {
|
||||
public List<ImTalkVO> getUserTalkList(IMTalkQueryParams imTalkQueryParams) {
|
||||
AuthUser authUser = UserContext.getCurrentUser();
|
||||
if(authUser == null){
|
||||
if (authUser == null) {
|
||||
throw new ServiceException(ResultCode.USER_NOT_LOGIN);
|
||||
}
|
||||
LambdaQueryWrapper<ImTalk> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.and(wq-> wq.eq(ImTalk::getUserId1, authUser.getId()).or().eq(ImTalk::getUserId2,authUser.getId()));
|
||||
queryWrapper.and(wq -> wq.eq(ImTalk::getUserId1, authUser.getId()).or().eq(ImTalk::getUserId2, authUser.getId()));
|
||||
if (CharSequenceUtil.isNotEmpty(imTalkQueryParams.getUserName())) {
|
||||
queryWrapper.and(wq -> wq.ne(ImTalk::getUserId1, authUser.getId()).like(ImTalk::getName1, imTalkQueryParams.getUserName()).or().ne(ImTalk::getUserId2, authUser.getId()).like(ImTalk::getName2, imTalkQueryParams.getUserName()));
|
||||
}
|
||||
queryWrapper.orderByDesc(ImTalk::getLastTalkTime);
|
||||
List<ImTalk> imTalks = this.list(queryWrapper);
|
||||
List<ImTalkVO> imTalkVOList = imTalks.stream().map(imTalk -> new ImTalkVO(imTalk, authUser.getId())).collect(Collectors.toList());
|
||||
@@ -188,33 +193,33 @@ public class ImTalkServiceImpl extends ServiceImpl<ImTalkMapper, ImTalk> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ImTalkVO> getStoreTalkList() {
|
||||
public List<ImTalkVO> getStoreTalkList(IMTalkQueryParams imTalkQueryParams) {
|
||||
AuthUser authUser = UserContext.getCurrentUser();
|
||||
if(authUser == null){
|
||||
if (authUser == null) {
|
||||
throw new ServiceException(ResultCode.STORE_NOT_LOGIN_ERROR);
|
||||
}
|
||||
LambdaQueryWrapper<ImTalk> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.and(wq->{
|
||||
wq.eq(ImTalk::getUserId1, authUser.getStoreId()).or().eq(ImTalk::getUserId2,authUser.getStoreId());
|
||||
});
|
||||
queryWrapper.and(wq -> wq.eq(ImTalk::getUserId1, authUser.getStoreId()).or().eq(ImTalk::getUserId2, authUser.getStoreId()));
|
||||
if (CharSequenceUtil.isNotEmpty(imTalkQueryParams.getUserName())) {
|
||||
queryWrapper.and(wq -> wq.ne(ImTalk::getUserId1, authUser.getStoreId()).like(ImTalk::getName1, imTalkQueryParams.getUserName()).or().ne(ImTalk::getUserId2, authUser.getStoreId()).like(ImTalk::getName2, imTalkQueryParams.getUserName()));
|
||||
}
|
||||
queryWrapper.orderByDesc(ImTalk::getLastTalkTime);
|
||||
List<ImTalk> imTalks = this.list(queryWrapper);
|
||||
|
||||
List<ImTalkVO> imTalkVOList = imTalks.stream().map(imTalk -> {
|
||||
return new ImTalkVO(imTalk, authUser.getStoreId());
|
||||
}).collect(Collectors.toList());
|
||||
List<ImTalkVO> imTalkVOList = imTalks.stream().map(imTalk -> new ImTalkVO(imTalk, authUser.getStoreId())).collect(Collectors.toList());
|
||||
getUnread(imTalkVOList);
|
||||
return imTalkVOList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取未读消息数量
|
||||
*
|
||||
* @param imTalkVOList 消息列表
|
||||
*/
|
||||
private void getUnread(List<ImTalkVO> imTalkVOList){
|
||||
if(!imTalkVOList.isEmpty()){
|
||||
private void getUnread(List<ImTalkVO> imTalkVOList) {
|
||||
if (!imTalkVOList.isEmpty()) {
|
||||
for (ImTalkVO imTalkVO : imTalkVOList) {
|
||||
long count = imMessageService.count(new LambdaQueryWrapper<ImMessage>().eq(ImMessage::getFromUser, imTalkVO.getUserId()).eq(ImMessage::getTalkId,imTalkVO.getId()).eq(ImMessage::getIsRead, false));
|
||||
long count = imMessageService.count(new LambdaQueryWrapper<ImMessage>().eq(ImMessage::getFromUser, imTalkVO.getUserId()).eq(ImMessage::getTalkId, imTalkVO.getId()).eq(ImMessage::getIsRead, false));
|
||||
imTalkVO.setUnread(count);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package cn.lili.modules.logistics.plugin.kdniao;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.modules.logistics.LogisticsPlugin;
|
||||
@@ -12,8 +13,13 @@ import cn.lili.modules.order.order.entity.vo.OrderDetailVO;
|
||||
import cn.lili.modules.store.entity.dos.StoreLogistics;
|
||||
import cn.lili.modules.store.entity.dto.StoreDeliverGoodsAddressDTO;
|
||||
import cn.lili.modules.system.entity.dos.Logistics;
|
||||
import cn.lili.modules.system.entity.dos.Setting;
|
||||
import cn.lili.modules.system.entity.dto.DeliverySetting;
|
||||
import cn.lili.modules.system.entity.dto.LogisticsSetting;
|
||||
import cn.lili.modules.system.entity.dto.payment.UnionPaymentSetting;
|
||||
import cn.lili.modules.system.entity.enums.SettingEnum;
|
||||
import cn.lili.modules.system.entity.vo.Traces;
|
||||
import cn.lili.modules.system.service.SettingService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -40,6 +46,9 @@ public class KdniaoPlugin implements LogisticsPlugin {
|
||||
@Autowired
|
||||
private LogisticsSetting logisticsSetting;
|
||||
|
||||
@Autowired
|
||||
private SettingService settingService;
|
||||
|
||||
public KdniaoPlugin(LogisticsSetting logisticsSetting) {
|
||||
this.logisticsSetting = logisticsSetting;
|
||||
}
|
||||
@@ -124,31 +133,41 @@ public class KdniaoPlugin implements LogisticsPlugin {
|
||||
//收件人地址
|
||||
String[] ConsigneeAddress = order.getConsigneeAddressPath().split(",");
|
||||
//获取店家信息
|
||||
StoreDeliverGoodsAddressDTO storeDeliverGoodsAddressDTO = labelOrderDTO.getStoreDeliverGoodsAddressDTO();
|
||||
// StoreDeliverGoodsAddressDTO storeDeliverGoodsAddressDTO = labelOrderDTO.getStoreDeliverGoodsAddressDTO();
|
||||
//发件人地址
|
||||
String[] consignorAddress = storeDeliverGoodsAddressDTO.getSalesConsignorAddressPath().split(",");
|
||||
// String[] consignorAddress = storeDeliverGoodsAddressDTO.getSalesConsignorAddressPath().split(",");
|
||||
//店铺-物流公司设置
|
||||
StoreLogistics storeLogistics = labelOrderDTO.getStoreLogistics();
|
||||
// StoreLogistics storeLogistics = labelOrderDTO.getStoreLogistics();
|
||||
Setting systemSetting = settingService.get(SettingEnum.DELIVERY_SETTING.name());
|
||||
DeliverySetting deliverySetting = JSONUtil.toBean(systemSetting.getSettingValue(), DeliverySetting.class);
|
||||
if(deliverySetting.getSalesConsignorName() == null
|
||||
|| deliverySetting.getSalesConsignorAddressId() == null
|
||||
|| deliverySetting.getSalesConsignorAddressPath() == null
|
||||
|| deliverySetting.getSalesConsignorMobile() == null
|
||||
|| deliverySetting.getSalesConsignorDetail() == null){
|
||||
throw new ServiceException(ResultCode.DELIVERY_SETTING_ERROR);
|
||||
}
|
||||
String[] consignorAddress = deliverySetting.getSalesConsignorAddressPath().split(",");
|
||||
|
||||
//组装快递鸟应用级参数
|
||||
String resultDate = "{" +
|
||||
"'OrderCode': '" + order.getSn() + "'," + //订单编码
|
||||
"'ShipperCode': '" + logistics.getCode() + "'," + //快递公司编码
|
||||
"'CustomerName': '" + storeLogistics.getCustomerName() + "'," +//客户编码
|
||||
"'CustomerPwd': '" + storeLogistics.getCustomerPwd() + "'," + //客户密码
|
||||
"'MonthCode': '" + storeLogistics.getMonthCode() + "'," + //密钥
|
||||
"'SendSite': '" + storeLogistics.getSendSite() + "'," + //归属网点
|
||||
"'SendStaff': '" + storeLogistics.getSendStaff() + "'," + //收件快递员
|
||||
"'PayType': " + storeLogistics.getPayType() + "," +
|
||||
"'ExpType': " + storeLogistics.getExpType() + "," +
|
||||
"'CustomerName': '" + logistics.getCustomerName() + "'," +//客户编码
|
||||
"'CustomerPwd': '" + logistics.getCustomerPwd() + "'," + //客户密码
|
||||
"'MonthCode': '" + logistics.getMonthCode() + "'," + //密钥
|
||||
"'SendSite': '" + logistics.getSendSite() + "'," + //归属网点
|
||||
"'SendStaff': '" + logistics.getSendStaff() + "'," + //收件快递员
|
||||
"'PayType': " + logistics.getPayType() + "," +
|
||||
"'ExpType': " + logistics.getExpType() + "," +
|
||||
//发件人信息
|
||||
"'Sender': {" +
|
||||
"'Name': '" + storeDeliverGoodsAddressDTO.getSalesConsignorName() + "'," +
|
||||
"'Mobile': '" + storeDeliverGoodsAddressDTO.getSalesConsignorMobile() + "'," +
|
||||
"'Name': '" + deliverySetting.getSalesConsignorName() + "'," +
|
||||
"'Mobile': '" + deliverySetting.getSalesConsignorMobile() + "'," +
|
||||
"'ProvinceName': '" + consignorAddress[0] + "'," + //省
|
||||
"'CityName': '" + consignorAddress[1] + "'," + //市
|
||||
"'ExpAreaName': '" + consignorAddress[2] + "'," + //区
|
||||
"'Address': '" + storeDeliverGoodsAddressDTO.getSalesConsignorDetail() + "'" + //发件人详细地址
|
||||
"'Address': '" + deliverySetting.getSalesConsignorDetail() + "'" + //发件人详细地址
|
||||
"}," +
|
||||
//收件人信息
|
||||
"'Receiver': {" +
|
||||
|
||||
@@ -3,6 +3,7 @@ package cn.lili.modules.member.entity.dos;
|
||||
import cn.lili.common.enums.ClientTypeEnum;
|
||||
import cn.lili.common.security.sensitive.Sensitive;
|
||||
import cn.lili.common.security.sensitive.enums.SensitiveStrategy;
|
||||
import cn.lili.common.utils.CommonUtil;
|
||||
import cn.lili.mybatis.BaseEntity;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
@@ -101,7 +102,7 @@ public class Member extends BaseEntity {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.mobile = mobile;
|
||||
this.nickName = "临时昵称";
|
||||
this.nickName = CommonUtil.getSpecialStr("用户");
|
||||
this.disabled = true;
|
||||
this.haveStore = false;
|
||||
this.sex = 0;
|
||||
|
||||
@@ -24,13 +24,16 @@ public class MemberGrade extends BaseEntity {
|
||||
private String gradeName;
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "等级图片")
|
||||
@ApiModelProperty(value = "等级图片 1029*498")
|
||||
private String gradeImage;
|
||||
|
||||
@NotNull
|
||||
@ApiModelProperty(value = "所需经验值")
|
||||
private Integer experienceValue;
|
||||
@ApiModelProperty(value = "会员等级")
|
||||
private Integer level;
|
||||
|
||||
@ApiModelProperty(value = "是否为默认等级")
|
||||
private Boolean isDefault;
|
||||
@ApiModelProperty(value = "累计实付")
|
||||
private Double payPrice;
|
||||
|
||||
@ApiModelProperty(value = "累计购买次数")
|
||||
private Integer count;
|
||||
}
|
||||
|
||||
@@ -4,8 +4,7 @@ import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.*;
|
||||
|
||||
/**
|
||||
* 评价查询条件
|
||||
@@ -15,8 +14,13 @@ import lombok.EqualsAndHashCode;
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Builder
|
||||
public class EvaluationQueryParams extends PageVO {
|
||||
|
||||
private static final long serialVersionUID = 2038158669175297129L;
|
||||
|
||||
@ApiModelProperty(value = "ID")
|
||||
private String id;
|
||||
|
||||
|
||||
@@ -98,4 +98,21 @@ public class MemberVO implements Serializable {
|
||||
public MemberVO(Member member) {
|
||||
BeanUtil.copyProperties(member, this);
|
||||
}
|
||||
|
||||
public String getRegionId() {
|
||||
return getDefaultValue(regionId);
|
||||
}
|
||||
|
||||
public String getRegion() {
|
||||
return getDefaultValue(region);
|
||||
}
|
||||
|
||||
/**
|
||||
* JSON转换中的null 会转成 "null"
|
||||
* @param value
|
||||
* @return
|
||||
*/
|
||||
private String getDefaultValue(String value){
|
||||
return (value == null || "null".equals(value)) ? "" : value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,10 +135,9 @@ public interface MemberService extends IService<Member> {
|
||||
/**
|
||||
* 注销账号
|
||||
*
|
||||
* @param password 密码
|
||||
* @return 操作结果
|
||||
*/
|
||||
void cancellation(String password);
|
||||
void cancellation();
|
||||
/**
|
||||
* 修改当前会员的手机号
|
||||
*
|
||||
|
||||
@@ -85,17 +85,16 @@ public class FootprintServiceImpl extends ServiceImpl<FootprintMapper, FootPrint
|
||||
List<EsGoodsIndex> collect = IntStream.range(0, goodsSkuByIdFromCache.size())
|
||||
.mapToObj(i -> {
|
||||
if (goodsSkuByIdFromCache.get(i) == null) {
|
||||
EsGoodsIndex esGoodsIndex = new EsGoodsIndex();
|
||||
FootPrint footPrint = footPrintPages.getRecords().get(i);
|
||||
esGoodsIndex.setGoodsId(footPrint.getGoodsId());
|
||||
esGoodsIndex.setId(footPrint.getSkuId());
|
||||
esGoodsIndex.setReleaseTime(footPrintPages.getRecords().get(i).getCreateTime().getTime());
|
||||
return esGoodsIndex;
|
||||
return null;
|
||||
}
|
||||
Optional<FootPrint> first = footPrintPages.getRecords().stream().filter(j -> j.getSkuId().equals(goodsSkuByIdFromCache.get(i).getId())).findFirst();
|
||||
Optional<FootPrint> first =
|
||||
footPrintPages.getRecords().stream().filter(j -> j.getSkuId().equals(goodsSkuByIdFromCache.get(i).getId())).findFirst();
|
||||
return first.map(footPrint -> new EsGoodsIndex(goodsSkuByIdFromCache.get(i), footPrint.getCreateTime())).orElseGet(() -> new EsGoodsIndex(goodsSkuByIdFromCache.get(i)));
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
collect.removeIf(Objects::isNull);
|
||||
|
||||
esGoodsIndexIPage.setPages(footPrintPages.getPages());
|
||||
esGoodsIndexIPage.setRecords(collect);
|
||||
esGoodsIndexIPage.setTotal(footPrintPages.getTotal());
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package cn.lili.modules.member.serviceimpl;
|
||||
|
||||
import cn.lili.common.security.AuthUser;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
import cn.lili.common.security.enums.UserEnums;
|
||||
import cn.lili.common.vo.PageVO;
|
||||
import cn.lili.modules.member.entity.dos.MemberAddress;
|
||||
import cn.lili.modules.member.mapper.MemberAddressMapper;
|
||||
@@ -35,10 +37,15 @@ public class MemberAddressServiceImpl extends ServiceImpl<MemberAddressMapper, M
|
||||
|
||||
@Override
|
||||
public MemberAddress getMemberAddress(String id) {
|
||||
return this.getOne(
|
||||
new QueryWrapper<MemberAddress>()
|
||||
.eq("member_id", Objects.requireNonNull(UserContext.getCurrentUser()).getId())
|
||||
.eq("id", id));
|
||||
AuthUser authUser = UserContext.getCurrentUser();
|
||||
if (authUser.getIsSuper() || UserEnums.MANAGER.equals(authUser.getRole())){
|
||||
return this.getOne(new QueryWrapper<MemberAddress>().eq("id", id));
|
||||
}else{
|
||||
return this.getOne(
|
||||
new QueryWrapper<MemberAddress>()
|
||||
.eq("member_id", Objects.requireNonNull(UserContext.getCurrentUser()).getId())
|
||||
.eq("id", id));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -6,6 +6,7 @@ import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.enums.SwitchEnum;
|
||||
import cn.lili.common.event.TransactionCommitSendMQEvent;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.properties.RocketmqCustomProperties;
|
||||
import cn.lili.common.security.context.UserContext;
|
||||
@@ -31,7 +32,6 @@ import cn.lili.modules.order.order.entity.enums.CommentStatusEnum;
|
||||
import cn.lili.modules.order.order.service.OrderItemService;
|
||||
import cn.lili.modules.order.order.service.OrderService;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
|
||||
import cn.lili.rocketmq.tags.GoodsTagsEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@@ -40,8 +40,8 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -77,17 +77,15 @@ public class MemberEvaluationServiceImpl extends ServiceImpl<MemberEvaluationMap
|
||||
*/
|
||||
@Autowired
|
||||
private GoodsSkuService goodsSkuService;
|
||||
/**
|
||||
* rocketMq
|
||||
*/
|
||||
@Autowired
|
||||
private RocketMQTemplate rocketMQTemplate;
|
||||
/**
|
||||
* rocketMq配置
|
||||
*/
|
||||
@Autowired
|
||||
private RocketmqCustomProperties rocketmqCustomProperties;
|
||||
|
||||
@Autowired
|
||||
private ApplicationEventPublisher applicationEventPublisher;
|
||||
|
||||
@Override
|
||||
public IPage<MemberEvaluation> managerQuery(EvaluationQueryParams queryParams) {
|
||||
//获取评价分页
|
||||
@@ -133,8 +131,8 @@ public class MemberEvaluationServiceImpl extends ServiceImpl<MemberEvaluationMap
|
||||
//修改订单货物评价状态为已评价
|
||||
orderItemService.updateCommentStatus(orderItem.getSn(), CommentStatusEnum.FINISHED);
|
||||
//发送商品评价消息
|
||||
String destination = rocketmqCustomProperties.getGoodsTopic() + ":" + GoodsTagsEnum.GOODS_COMMENT_COMPLETE.name();
|
||||
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(memberEvaluation), RocketmqSendCallbackBuilder.commonCallback());
|
||||
applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("同步商品评价消息",
|
||||
rocketmqCustomProperties.getGoodsTopic(), GoodsTagsEnum.GOODS_COMMENT_COMPLETE.name(), JSONUtil.toJsonStr(memberEvaluation)));
|
||||
return memberEvaluationDTO;
|
||||
}
|
||||
|
||||
@@ -196,6 +194,7 @@ public class MemberEvaluationServiceImpl extends ServiceImpl<MemberEvaluationMap
|
||||
evaluationNumberVO.setWorse(worse);
|
||||
evaluationNumberVO.setHaveImage(this.count(new QueryWrapper<MemberEvaluation>()
|
||||
.eq("have_image", 1)
|
||||
.eq("status", SwitchEnum.OPEN.name())
|
||||
.eq("goods_id", goodsId)));
|
||||
|
||||
return evaluationNumberVO;
|
||||
|
||||
@@ -118,7 +118,11 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
public Member getUserInfo() {
|
||||
AuthUser tokenUser = UserContext.getCurrentUser();
|
||||
if (tokenUser != null) {
|
||||
return this.findByUsername(tokenUser.getUsername());
|
||||
Member member = this.findByUsername(tokenUser.getUsername());
|
||||
if(member != null && member.getDisabled()){
|
||||
throw new ServiceException(ResultCode.USER_STATUS_ERROR);
|
||||
}
|
||||
return member;
|
||||
}
|
||||
throw new ServiceException(ResultCode.USER_NOT_LOGIN);
|
||||
}
|
||||
@@ -233,7 +237,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
private Member findMember(String userName) {
|
||||
QueryWrapper<Member> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("username", userName).or().eq("mobile", userName);
|
||||
return this.getOne(queryWrapper);
|
||||
return this.getOne(queryWrapper, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -241,7 +245,7 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
public Member autoRegister(ConnectAuthUser authUser) {
|
||||
|
||||
if (CharSequenceUtil.isEmpty(authUser.getNickname())) {
|
||||
authUser.setNickname("临时昵称");
|
||||
authUser.setNickname(CommonUtil.getSpecialStr("用户"));
|
||||
}
|
||||
if (CharSequenceUtil.isEmpty(authUser.getAvatar())) {
|
||||
authUser.setAvatar("https://i.loli.net/2020/11/19/LyN6JF7zZRskdIe.png");
|
||||
@@ -286,12 +290,16 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
public Token mobilePhoneLogin(String mobilePhone) {
|
||||
QueryWrapper<Member> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("mobile", mobilePhone);
|
||||
Member member = this.baseMapper.selectOne(queryWrapper);
|
||||
Member member = this.baseMapper.selectOne(queryWrapper, false);
|
||||
//如果手机号不存在则自动注册用户
|
||||
if (member == null) {
|
||||
member = new Member(mobilePhone, UuidUtils.getUUID(), mobilePhone);
|
||||
registerHandler(member);
|
||||
}
|
||||
//判断用户是否有效
|
||||
if (member.getDisabled().equals(false) || member.getDeleteFlag().equals(true)) {
|
||||
throw new ServiceException(ResultCode.USER_STATUS_ERROR);
|
||||
}
|
||||
loginBindUser(member);
|
||||
return memberTokenGenerate.createToken(member, false);
|
||||
}
|
||||
@@ -375,19 +383,17 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancellation(String password) {
|
||||
public void cancellation() {
|
||||
|
||||
AuthUser tokenUser = UserContext.getCurrentUser();
|
||||
if (tokenUser == null) {
|
||||
throw new ServiceException(ResultCode.USER_NOT_LOGIN);
|
||||
}
|
||||
Member member = this.getById(tokenUser.getId());
|
||||
if (member.getPassword().equals(new BCryptPasswordEncoder().encode(password))) {
|
||||
//删除联合登录
|
||||
connectService.deleteByMemberId(member.getId());
|
||||
//混淆用户信息
|
||||
this.confusionMember(member);
|
||||
}
|
||||
//删除联合登录
|
||||
connectService.deleteByMemberId(member.getId());
|
||||
//混淆用户信息
|
||||
this.confusionMember(member);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -841,4 +847,5 @@ public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> impleme
|
||||
throw new ServiceException(ResultCode.USER_EXIST);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,6 +22,11 @@ import java.util.Date;
|
||||
@Data
|
||||
public class AfterSaleSearchParams extends PageVO {
|
||||
|
||||
private static final long serialVersionUID = 28604026820923515L;
|
||||
|
||||
@ApiModelProperty(value = "关键字")
|
||||
private String keywords;
|
||||
|
||||
@ApiModelProperty(value = "售后服务单号")
|
||||
private String sn;
|
||||
|
||||
@@ -71,6 +76,10 @@ public class AfterSaleSearchParams extends PageVO {
|
||||
|
||||
public <T> QueryWrapper<T> queryWrapper() {
|
||||
QueryWrapper<T> queryWrapper = new QueryWrapper<>();
|
||||
if (CharSequenceUtil.isNotEmpty(keywords)) {
|
||||
queryWrapper.and(wrapper -> wrapper.like("sn", keywords).or().like("order_sn", keywords).or().like("goods_name", keywords));
|
||||
}
|
||||
|
||||
if (CharSequenceUtil.isNotEmpty(sn)) {
|
||||
queryWrapper.like("sn", sn);
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@ package cn.lili.modules.order.aftersale.serviceimpl;
|
||||
|
||||
import cn.hutool.core.text.CharSequenceUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.lili.common.enums.ResultCode;
|
||||
import cn.lili.common.event.TransactionCommitSendMQEvent;
|
||||
import cn.lili.common.exception.ServiceException;
|
||||
import cn.lili.common.properties.RocketmqCustomProperties;
|
||||
import cn.lili.common.security.AuthUser;
|
||||
@@ -22,10 +24,7 @@ import cn.lili.modules.order.aftersale.mapper.AfterSaleMapper;
|
||||
import cn.lili.modules.order.aftersale.service.AfterSaleService;
|
||||
import cn.lili.modules.order.order.entity.dos.Order;
|
||||
import cn.lili.modules.order.order.entity.dos.OrderItem;
|
||||
import cn.lili.modules.order.order.entity.enums.OrderItemAfterSaleStatusEnum;
|
||||
import cn.lili.modules.order.order.entity.enums.OrderStatusEnum;
|
||||
import cn.lili.modules.order.order.entity.enums.OrderTypeEnum;
|
||||
import cn.lili.modules.order.order.entity.enums.PayStatusEnum;
|
||||
import cn.lili.modules.order.order.entity.enums.*;
|
||||
import cn.lili.modules.order.order.service.OrderItemService;
|
||||
import cn.lili.modules.order.order.service.OrderService;
|
||||
import cn.lili.modules.order.trade.entity.enums.AfterSaleRefundWayEnum;
|
||||
@@ -42,6 +41,7 @@ import cn.lili.modules.system.service.LogisticsService;
|
||||
import cn.lili.mybatis.util.PageUtil;
|
||||
import cn.lili.rocketmq.RocketmqSendCallbackBuilder;
|
||||
import cn.lili.rocketmq.tags.AfterSaleTagsEnum;
|
||||
import cn.lili.rocketmq.tags.OrderTagsEnum;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
@@ -50,6 +50,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@@ -102,6 +103,9 @@ public class AfterSaleServiceImpl extends ServiceImpl<AfterSaleMapper, AfterSale
|
||||
*/
|
||||
@Autowired
|
||||
private RocketMQTemplate rocketMQTemplate;
|
||||
@Autowired
|
||||
private ApplicationEventPublisher applicationEventPublisher;
|
||||
|
||||
|
||||
@Override
|
||||
public IPage<AfterSaleVO> getAfterSalePages(AfterSaleSearchParams saleSearchParams) {
|
||||
@@ -292,7 +296,7 @@ public class AfterSaleServiceImpl extends ServiceImpl<AfterSaleMapper, AfterSale
|
||||
throw new ServiceException(ResultCode.AFTER_STATUS_ERROR);
|
||||
}
|
||||
AfterSaleStatusEnum afterSaleStatusEnum;
|
||||
String pass = "PASS";
|
||||
String pass = AfterSaleStatusEnum.PASS.name();
|
||||
//判断审核状态
|
||||
//在线支付 则直接进行退款
|
||||
if (pass.equals(serviceStatus) &&
|
||||
@@ -461,8 +465,9 @@ public class AfterSaleServiceImpl extends ServiceImpl<AfterSaleMapper, AfterSale
|
||||
case APPLY: {
|
||||
// 买家申请售后时已经输入了订单售后数量,这里不需要(+x)处理
|
||||
orderItem.setReturnGoodsNumber(orderItem.getReturnGoodsNumber() + afterSale.getNum());
|
||||
orderItem.setRefundPrice(CurrencyUtil.add(orderItem.getRefundPrice(), afterSale.getApplyRefundPrice()));
|
||||
//修改orderItem订单
|
||||
this.updateOrderItem(orderItem);
|
||||
this.updateOrderItem(orderItem, afterSale);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -471,8 +476,9 @@ public class AfterSaleServiceImpl extends ServiceImpl<AfterSaleMapper, AfterSale
|
||||
case BUYER_CANCEL:
|
||||
case SELLER_TERMINATION: {
|
||||
orderItem.setReturnGoodsNumber(orderItem.getReturnGoodsNumber() - afterSale.getNum());
|
||||
orderItem.setRefundPrice(CurrencyUtil.sub(orderItem.getRefundPrice(), afterSale.getApplyRefundPrice()));
|
||||
//修改orderItem订单
|
||||
this.updateOrderItem(orderItem);
|
||||
this.updateOrderItem(orderItem, afterSale);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@@ -580,11 +586,10 @@ public class AfterSaleServiceImpl extends ServiceImpl<AfterSaleMapper, AfterSale
|
||||
*
|
||||
* @param afterSale 售后对象
|
||||
*/
|
||||
private void sendAfterSaleMessage(AfterSale afterSale) {
|
||||
//发送售后创建消息
|
||||
String destination = rocketmqCustomProperties.getAfterSaleTopic() + ":" + AfterSaleTagsEnum.AFTER_SALE_STATUS_CHANGE.name();
|
||||
//发送订单变更mq消息
|
||||
rocketMQTemplate.asyncSend(destination, JSONUtil.toJsonStr(afterSale), RocketmqSendCallbackBuilder.commonCallback());
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void sendAfterSaleMessage(AfterSale afterSale) {
|
||||
applicationEventPublisher.publishEvent(new TransactionCommitSendMQEvent("发送售后单状态变更MQ消息", rocketmqCustomProperties.getAfterSaleTopic(),
|
||||
AfterSaleTagsEnum.AFTER_SALE_STATUS_CHANGE.name(), JSONUtil.toJsonStr(afterSale)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -627,7 +632,7 @@ public class AfterSaleServiceImpl extends ServiceImpl<AfterSaleMapper, AfterSale
|
||||
* @return void
|
||||
* @author ftyy
|
||||
**/
|
||||
private void updateOrderItem(OrderItem orderItem) {
|
||||
private void updateOrderItem(OrderItem orderItem, AfterSale afterSale) {
|
||||
//订单状态不能为新订单,已失效订单或未申请订单才可以去修改订单信息
|
||||
OrderItemAfterSaleStatusEnum afterSaleTypeEnum = OrderItemAfterSaleStatusEnum.valueOf(orderItem.getAfterSaleStatus());
|
||||
switch (afterSaleTypeEnum) {
|
||||
@@ -652,10 +657,27 @@ public class AfterSaleServiceImpl extends ServiceImpl<AfterSaleMapper, AfterSale
|
||||
default:
|
||||
break;
|
||||
}
|
||||
orderItemService.update(new LambdaUpdateWrapper<OrderItem>()
|
||||
|
||||
LambdaUpdateWrapper<OrderItem> lambdaUpdateWrapper = new LambdaUpdateWrapper<OrderItem>()
|
||||
.eq(OrderItem::getSn, orderItem.getSn())
|
||||
.set(OrderItem::getAfterSaleStatus, orderItem.getAfterSaleStatus())
|
||||
.set(OrderItem::getReturnGoodsNumber, orderItem.getReturnGoodsNumber()));
|
||||
.set(OrderItem::getReturnGoodsNumber, orderItem.getReturnGoodsNumber());
|
||||
|
||||
if (afterSale.getServiceStatus().equals(AfterSaleStatusEnum.COMPLETE.name())) {
|
||||
if (orderItem.getReturnGoodsNumber().equals(orderItem.getNum())) {
|
||||
lambdaUpdateWrapper.set(OrderItem::getIsRefund, RefundStatusEnum.ALL_REFUND.name());
|
||||
} else {
|
||||
lambdaUpdateWrapper.set(OrderItem::getIsRefund, RefundStatusEnum.PART_REFUND.name());
|
||||
}
|
||||
} else if (afterSale.getServiceStatus().equals(AfterSaleStatusEnum.APPLY.name())) {
|
||||
lambdaUpdateWrapper.set(OrderItem::getIsRefund, RefundStatusEnum.REFUNDING.name());
|
||||
} else if (afterSale.getServiceStatus().equals(AfterSaleStatusEnum.REFUSE.name()) ||
|
||||
afterSale.getServiceStatus().equals(AfterSaleStatusEnum.BUYER_CANCEL.name()) ||
|
||||
afterSale.getServiceStatus().equals(AfterSaleStatusEnum.SELLER_TERMINATION.name())) {
|
||||
lambdaUpdateWrapper.set(OrderItem::getIsRefund, RefundStatusEnum.NO_REFUND.name());
|
||||
}
|
||||
|
||||
orderItemService.update(lambdaUpdateWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -116,7 +116,11 @@ public class CheckDataRender implements CartRenderStep {
|
||||
//商品上架状态判定 sku为空、sku非上架状态、sku审核不通过
|
||||
boolean checkGoodsStatus = dataSku == null || !GoodsAuthEnum.PASS.name().equals(dataSku.getAuthFlag()) || !GoodsStatusEnum.UPPER.name().equals(dataSku.getMarketEnable());
|
||||
//商品有效性判定 sku不为空且sku的更新时间不为空且sku的更新时间在购物车sku的更新时间之后
|
||||
boolean checkGoodsValid = dataSku != null && dataSku.getUpdateTime() != null && dataSku.getUpdateTime().after(cartSkuVO.getGoodsSku().getUpdateTime());
|
||||
boolean checkGoodsValid = dataSku != null &&
|
||||
dataSku.getUpdateTime() != null &&
|
||||
cartSkuVO.getGoodsSku() != null &&
|
||||
cartSkuVO.getGoodsSku().getUpdateTime() != null &&
|
||||
dataSku.getUpdateTime().after(cartSkuVO.getGoodsSku().getUpdateTime());
|
||||
|
||||
|
||||
if (checkGoodsStatus || checkGoodsValid) {
|
||||
|
||||
@@ -50,7 +50,7 @@ public class SkuFreightRender implements CartRenderStep {
|
||||
return;
|
||||
}
|
||||
//选择物流的时候计算价格
|
||||
if(DeliveryMethodEnum.LOGISTICS.name().equals(tradeDTO.getCartList().get(0).getDeliveryMethod())){
|
||||
if (DeliveryMethodEnum.LOGISTICS.name().equals(tradeDTO.getCartList().get(0).getDeliveryMethod())) {
|
||||
if (memberAddress != null) {
|
||||
//运费分组信息
|
||||
Map<String, List<String>> freightGroups = freightTemplateGrouping(cartSkuVOS);
|
||||
@@ -116,7 +116,7 @@ public class SkuFreightRender implements CartRenderStep {
|
||||
}
|
||||
}
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
//自提清空不配送商品
|
||||
tradeDTO.setNotSupportFreight(null);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package cn.lili.modules.order.cart.render.util;
|
||||
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.lili.common.enums.PromotionTypeEnum;
|
||||
import cn.lili.common.utils.CurrencyUtil;
|
||||
import cn.lili.modules.order.cart.entity.dto.TradeDTO;
|
||||
@@ -10,7 +11,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
/**
|
||||
* 促销价格计算业务层实现
|
||||
@@ -33,7 +35,7 @@ public class PromotionPriceUtil {
|
||||
PromotionTypeEnum promotionTypeEnum, String activityId) {
|
||||
|
||||
// sku 促销信息非空判定
|
||||
if (skuPromotionDetail == null || skuPromotionDetail.size() == 0) {
|
||||
if (skuPromotionDetail == null || skuPromotionDetail.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -68,40 +70,39 @@ public class PromotionPriceUtil {
|
||||
List<CartSkuVO> skuVOList = tradeDTO.getSkuList();
|
||||
|
||||
// 获取map分配sku的总数,如果是最后一个商品分配金额,则将金额从百分比改为总金额扣减,避免出现小数除不尽
|
||||
int count = skuPromotionDetail.size();
|
||||
AtomicInteger count = new AtomicInteger(skuPromotionDetail.size());
|
||||
|
||||
//已优惠金额
|
||||
Double deducted = 0D;
|
||||
AtomicReference<Double> deducted = new AtomicReference<>(0D);
|
||||
|
||||
for (String skuId : skuPromotionDetail.keySet()) {
|
||||
|
||||
//获取对应商品进行计算
|
||||
for (CartSkuVO cartSkuVO : skuVOList) {
|
||||
|
||||
if (cartSkuVO.getGoodsSku().getId().equals(skuId)) {
|
||||
Double finalDiscountPrice = discountPrice;
|
||||
Double finalTotalPrice = totalPrice;
|
||||
skuVOList.stream().filter(l -> l.getGoodsSku().getId().equals(skuId)).findFirst().ifPresent(cartSkuVO -> {
|
||||
//sku 优惠金额
|
||||
Double skuDiscountPrice;
|
||||
count.getAndDecrement();
|
||||
|
||||
count--;
|
||||
|
||||
//sku 优惠金额
|
||||
Double skuDiscountPrice;
|
||||
|
||||
//非最后一个商品,则按照比例计算
|
||||
if (count > 0) {
|
||||
//商品金额占比
|
||||
double point = CurrencyUtil.div(cartSkuVO.getPriceDetailDTO().getGoodsPrice(), totalPrice, 4);
|
||||
//商品优惠金额
|
||||
skuDiscountPrice = CurrencyUtil.mul(discountPrice, point);
|
||||
//累加已优惠金额
|
||||
deducted = CurrencyUtil.add(deducted, skuDiscountPrice);
|
||||
}
|
||||
// 如果是最后一个商品 则减去之前优惠的金额来进行计算
|
||||
else {
|
||||
skuDiscountPrice = CurrencyUtil.sub(discountPrice, deducted);
|
||||
}
|
||||
|
||||
calculateCartSkuPromotionsPrice(cartSkuVO, skuDiscountPrice, promotionTypeEnum, activityId);
|
||||
//非最后一个商品,则按照比例计算
|
||||
if (count.get() > 0) {
|
||||
//商品金额占比
|
||||
double point = CurrencyUtil.div(cartSkuVO.getPriceDetailDTO().getGoodsPrice(), finalTotalPrice, 4);
|
||||
//商品优惠金额
|
||||
skuDiscountPrice = CurrencyUtil.mul(finalDiscountPrice, point);
|
||||
//累加已优惠金额
|
||||
deducted.set(CurrencyUtil.add(deducted.get(), skuDiscountPrice));
|
||||
}
|
||||
}
|
||||
// 如果是最后一个商品 则减去之前优惠的金额来进行计算
|
||||
else {
|
||||
skuDiscountPrice = CurrencyUtil.sub(finalDiscountPrice, deducted.get());
|
||||
}
|
||||
|
||||
calculateCartSkuPromotionsPrice(cartSkuVO, skuDiscountPrice, promotionTypeEnum, activityId);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
calculateNotEnoughPromotionsPrice(skuVOList, skuPromotionDetail, discountPrice, totalPrice, promotionTypeEnum, activityId);
|
||||
@@ -186,51 +187,100 @@ public class PromotionPriceUtil {
|
||||
// 特殊情况处理,如参与多个促销活动,部分商品在其他促销计算后的金额不足以满足与当前参与的促销活动的优惠金额
|
||||
// 但当前购物车内存在当前当前促销活动的其他商品且剩余金额也满足分摊不足商品的不足金额,则分摊到其他商品上
|
||||
// 满足当前促销的总优惠金额
|
||||
if (skuPromotionDetail == null || skuPromotionDetail.isEmpty()) {
|
||||
if (skuPromotionDetail == null || skuPromotionDetail.size() < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
// clone skuPromotionDetail
|
||||
Map<String, Double> skuPromotionDetailClone = MapUtil.sortByValue(skuPromotionDetail, false);
|
||||
|
||||
// 未满足优惠金额的商品
|
||||
long matchPromotionsZeroCount =
|
||||
skuVOList.stream().filter(l -> l.getPriceDetailDTO().getFlowPrice() == 0 && skuPromotionDetail.containsKey(l.getGoodsSku().getId())).count();
|
||||
long matchPromotionsCount = skuVOList.stream().filter(l -> skuPromotionDetail.containsKey(l.getGoodsSku().getId())).count();
|
||||
skuVOList.stream().filter(l -> l.getPriceDetailDTO().getFlowPrice() == 0 && skuPromotionDetailClone.containsKey(l.getGoodsSku().getId())).count();
|
||||
// 参与当前促销活动的商品
|
||||
long matchPromotionsCount = skuVOList.stream().filter(l -> skuPromotionDetailClone.containsKey(l.getGoodsSku().getId())).count();
|
||||
if (matchPromotionsZeroCount == matchPromotionsCount) {
|
||||
return;
|
||||
}
|
||||
// 获取剩余金额不足优惠金额的商品
|
||||
List<CartSkuVO> unEnoughSku = skuVOList.stream().filter(k -> {
|
||||
if (skuPromotionDetail.containsKey(k.getGoodsSku().getId()) && skuPromotionDetail.size() >= 2) {
|
||||
//商品金额占比
|
||||
double point = CurrencyUtil.div(k.getPriceDetailDTO().getGoodsPrice(), totalPrice, 4);
|
||||
//商品优惠金额
|
||||
Double skuDiscountPrice = CurrencyUtil.mul(discountPrice, point);
|
||||
return k.getPriceDetailDTO().getCouponPrice() > 0 && skuDiscountPrice > k.getPriceDetailDTO().getCouponPrice();
|
||||
// 分配到其他商品的优惠金额
|
||||
AtomicReference<Double> balance = new AtomicReference<>(0D);
|
||||
StringBuilder lastSkuId = new StringBuilder();
|
||||
|
||||
// 计数器
|
||||
int count = 0;
|
||||
|
||||
|
||||
// 检查是否有不满足优惠金额的商品
|
||||
filterEnoughSku(skuVOList, skuPromotionDetailClone, discountPrice, totalPrice, balance, lastSkuId, promotionTypeEnum, activityId);
|
||||
|
||||
// 循环 优惠金额分摊,直到所有商品都满足优惠金额
|
||||
while (true) {
|
||||
// 如果还有剩余金额,则继续分摊
|
||||
if (balance.get() > 0) {
|
||||
skuPromotionDetailClone.remove(lastSkuId.toString());
|
||||
double lastDiscountPrice = CurrencyUtil.sub(discountPrice, skuPromotionDetail.get(lastSkuId.toString()));
|
||||
double lastTotalPrice = CurrencyUtil.sub(totalPrice, skuPromotionDetail.get(lastSkuId.toString()));
|
||||
filterEnoughSku(skuVOList, skuPromotionDetailClone, lastDiscountPrice, lastTotalPrice, balance, lastSkuId, promotionTypeEnum, activityId);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}).collect(Collectors.toList());
|
||||
if (!unEnoughSku.isEmpty()) {
|
||||
if (unEnoughSku.size() == skuVOList.size()) {
|
||||
return;
|
||||
count++;
|
||||
|
||||
// 防止死循环
|
||||
if (count > skuPromotionDetail.size()) {
|
||||
break;
|
||||
}
|
||||
for (CartSkuVO cartSkuVO : skuVOList) {
|
||||
if (unEnoughSku.isEmpty()) {
|
||||
break;
|
||||
}
|
||||
if (skuPromotionDetail.containsKey(cartSkuVO.getGoodsSku().getId()) && unEnoughSku.stream().noneMatch(k -> k.getGoodsSku().getId().equals(cartSkuVO.getGoodsSku().getId()))) {
|
||||
// 商品金额占比
|
||||
double point = CurrencyUtil.div(cartSkuVO.getPriceDetailDTO().getGoodsPrice(), totalPrice, 4);
|
||||
// 商品优惠金额
|
||||
Double skuDiscountPrice = CurrencyUtil.mul(discountPrice, point);
|
||||
// 商品优惠金额 - 不足优惠金额 = 差额
|
||||
Double sub = CurrencyUtil.sub(skuDiscountPrice, unEnoughSku.get(0).getPriceDetailDTO().getCouponPrice());
|
||||
// 分摊到其他商品: 其他商品原优惠金额 + 差额
|
||||
calculateCartSkuPromotionsPrice(cartSkuVO, sub, promotionTypeEnum, activityId);
|
||||
// 从不足商品列表中移除
|
||||
unEnoughSku.remove(0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
calculateNotEnoughPromotionsPrice(skuVOList, skuPromotionDetail, discountPrice, totalPrice, promotionTypeEnum, activityId);
|
||||
}
|
||||
|
||||
|
||||
private static void filterEnoughSku(List<CartSkuVO> skuVOList, Map<String, Double> skuPromotionDetail,
|
||||
Double discountPrice, Double totalPrice,
|
||||
AtomicReference<Double> balance, StringBuilder lastSkuId,
|
||||
PromotionTypeEnum promotionTypeEnum, String activityId) {
|
||||
AtomicInteger count = new AtomicInteger(skuPromotionDetail.size());
|
||||
AtomicReference<Double> countPrice = new AtomicReference<>(0D);
|
||||
for (String skuId : skuPromotionDetail.keySet()) {
|
||||
skuVOList.forEach(l -> {
|
||||
if (l.getGoodsSku().getId().equals(skuId)) {
|
||||
count.getAndDecrement();
|
||||
|
||||
//商品金额占比
|
||||
double point = CurrencyUtil.div(l.getPriceDetailDTO().getGoodsPrice(), totalPrice, 4);
|
||||
|
||||
//商品优惠金额
|
||||
Double skuDiscountPrice;
|
||||
|
||||
if (count.get() > 0) {
|
||||
//非最后一个商品,则按照比例计算
|
||||
skuDiscountPrice = CurrencyUtil.mul(discountPrice, point);
|
||||
} else {
|
||||
// 如果是最后一个商品 则减去之前优惠的金额来进行计算
|
||||
skuDiscountPrice = CurrencyUtil.sub(discountPrice, countPrice.get());
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (balance.get() > 0) {
|
||||
// 分摊到其他商品: 其他商品原优惠金额 + 差额
|
||||
calculateCartSkuPromotionsPrice(l, balance.get(), promotionTypeEnum, activityId);
|
||||
}
|
||||
|
||||
// 如果商品优惠金额大于商品金额,则取商品金额。差额分摊到其他商品
|
||||
if (skuDiscountPrice > l.getPriceDetailDTO().getGoodsPrice()) {
|
||||
balance.set(CurrencyUtil.sub(skuDiscountPrice, l.getPriceDetailDTO().getGoodsPrice()));
|
||||
lastSkuId.append(skuId);
|
||||
skuDiscountPrice = l.getPriceDetailDTO().getGoodsPrice();
|
||||
} else {
|
||||
balance.set(0D);
|
||||
}
|
||||
|
||||
|
||||
countPrice.set(CurrencyUtil.add(countPrice.get(), skuDiscountPrice));
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,6 +16,7 @@ import cn.lili.modules.goods.entity.dos.Wholesale;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsAuthEnum;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsSalesModeEnum;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsStatusEnum;
|
||||
import cn.lili.modules.goods.entity.enums.GoodsTypeEnum;
|
||||
import cn.lili.modules.goods.service.GoodsSkuService;
|
||||
import cn.lili.modules.goods.service.WholesaleService;
|
||||
import cn.lili.modules.member.entity.dos.Member;
|
||||
@@ -568,10 +569,8 @@ public class CartServiceImpl implements CartService {
|
||||
tradeDTO.setStoreRemark(tradeParams.getRemark());
|
||||
tradeDTO.setParentOrderSn(tradeParams.getParentOrderSn());
|
||||
//订单无收货地址校验
|
||||
if(tradeDTO.getStoreAddress() == null){
|
||||
if (tradeDTO.getMemberAddress() == null) {
|
||||
throw new ServiceException(ResultCode.MEMBER_ADDRESS_NOT_EXIST);
|
||||
}
|
||||
if (tradeDTO.getStoreAddress() == null && tradeDTO.getMemberAddress() == null && !GoodsTypeEnum.VIRTUAL_GOODS.name().equals(tradeDTO.getCheckedSkuList().get(0).getGoodsSku().getGoodsType())) {
|
||||
throw new ServiceException(ResultCode.MEMBER_ADDRESS_NOT_EXIST);
|
||||
}
|
||||
//构建交易
|
||||
Trade trade = tradeBuilder.createTrade(tradeDTO);
|
||||
@@ -584,10 +583,10 @@ public class CartServiceImpl implements CartService {
|
||||
List<String> list = new ArrayList<String>();
|
||||
list.add(DeliveryMethodEnum.LOGISTICS.name());
|
||||
TradeDTO tradeDTO = this.getCheckedTradeDTO(CartTypeEnum.valueOf(way));
|
||||
if(tradeDTO.getCartList().size()==1){
|
||||
if (tradeDTO.getCartList().size() == 1) {
|
||||
for (CartVO cartVO : tradeDTO.getCartList()) {
|
||||
Store store = storeService.getById(cartVO.getStoreId());
|
||||
if(store.getSelfPickFlag() != null && store.getSelfPickFlag()){
|
||||
if (store.getSelfPickFlag() != null && store.getSelfPickFlag()) {
|
||||
list.add(DeliveryMethodEnum.SELF_PICK_UP.name());
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user