Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
wwwanlingxiao
mall
Commits
cbdb93ee
Commit
cbdb93ee
authored
Sep 05, 2018
by
zhh
Browse files
下单接口完善,添加支付成功回调及自动取消超时订单接口
parent
cae7f7e4
Changes
21
Expand all
Hide whitespace changes
Inline
Side-by-side
README.md
View file @
cbdb93ee
...
...
@@ -53,12 +53,12 @@ JTA事务处理 | ✔
OSS上传功能 | ✔
Elasticsearch搜索功能 | ✔
HTTPS支持 | ✔
ELK日志收集功能 |
Redis数字型ID生成 |
Redis数字型ID生成 | ✔
SpringTask定时任务支持 | ✔
RestTemplate服务间调用 |
docker容器化部署 | ✔
配置区分生产和测试环境 | ✔
ELK日志收集功能 |
SpringSecurity权限管理功能 |
### 使用工具
...
...
@@ -273,9 +273,9 @@ Linux远程连接工具 | http://www.netsarang.com/download/software.html
-
根据用户搜索记录聚合生成热搜词
#### 购物流程
#### 购物流程
✔
> **购物车**
✔
> **购物车**
-
添加商品到购物车
-
购物车商品列表(商品主图、商品名称、商品数量、商品规格)
...
...
@@ -283,7 +283,7 @@ Linux远程连接工具 | http://www.netsarang.com/download/software.html
-
购物车中商品重选规格
-
购物车中商品删除功能
> **生成确认单**
✔
> **生成确认单**
-
生成确认单信息:收货信息、商品信息、价格信息、发票信息、支付方式
-
选择收货地址:默认收货地址
...
...
@@ -292,7 +292,7 @@ Linux远程连接工具 | http://www.netsarang.com/download/software.html
-
选择支付方式:在线支付及货到付款
-
计算应付金额:合计+运费-优惠券抵扣-积分抵扣-活动优惠
> **提交订单**
✔
> **提交订单**
-
将确认单信息转化为订单
-
删除购物车中相关商品
...
...
@@ -306,7 +306,6 @@ Linux远程连接工具 | http://www.netsarang.com/download/software.html
> **取消订单(未支付情况下)**
-
订单超时后自动取消订单,解除商品库存锁定,返还优惠券,积分
-
用户自己取消订单,解除商品库存锁定,返还优惠券,积分
#### 会员模块(我的)✔
...
...
document/pdm/mall.pdb
View file @
cbdb93ee
This diff is collapsed.
Click to expand it.
document/pdm/mall.pdm
View file @
cbdb93ee
This diff is collapsed.
Click to expand it.
document/sql/mall.sql
View file @
cbdb93ee
...
...
@@ -10,7 +10,7 @@ Target Server Type : MYSQL
Target Server Version : 50719
File Encoding : 65001
Date: 2018-09-0
3
17:
10:32
Date: 2018-09-0
5
17:
02:45
*/
SET
FOREIGN_KEY_CHECKS
=
0
;
...
...
@@ -379,16 +379,18 @@ CREATE TABLE `oms_order` (
`note`
varchar
(
500
)
DEFAULT
NULL
COMMENT
'订单备注'
,
`confirm_status`
int
(
1
)
DEFAULT
NULL
COMMENT
'确认收货状态:0->未确认;1->已确认'
,
`delete_status`
int
(
1
)
NOT
NULL
DEFAULT
'0'
COMMENT
'删除状态:0->未删除;1->已删除'
,
`use_integration`
int
(
11
)
DEFAULT
NULL
COMMENT
'下单时使用的积分'
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
1
6
DEFAULT
CHARSET
=
utf8
COMMENT
=
'订单表'
;
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
1
7
DEFAULT
CHARSET
=
utf8
COMMENT
=
'订单表'
;
-- ----------------------------
-- Records of oms_order
-- ----------------------------
INSERT
INTO
`oms_order`
VALUES
(
'12'
,
'1'
,
'2'
,
null
,
'2018-09-03 16:24:27'
,
'test'
,
'18732.00'
,
'16377.75'
,
'0.00'
,
'2344.25'
,
'0.00'
,
'10.00'
,
null
,
'0'
,
'1'
,
'0'
,
'0'
,
null
,
null
,
null
,
'0'
,
null
,
'单品促销,打折优惠:满3件,打7.50折,满减优惠:满1000.00元,减120.00元,满减优惠:满1000.00元,减120.00元,无优惠'
,
null
,
null
,
null
,
null
,
null
,
'大梨'
,
'18033441849'
,
'518000'
,
'广东省'
,
'深圳市'
,
'福田区'
,
'东晓街道'
,
null
,
'0'
,
'0'
);
INSERT
INTO
`oms_order`
VALUES
(
'13'
,
'1'
,
'2'
,
null
,
'2018-09-03 16:24:29'
,
'test'
,
'18732.00'
,
'16377.75'
,
'0.00'
,
'2344.25'
,
'0.00'
,
'10.00'
,
null
,
'0'
,
'1'
,
'0'
,
'0'
,
null
,
null
,
null
,
'0'
,
null
,
'单品促销,打折优惠:满3件,打7.50折,满减优惠:满1000.00元,减120.00元,满减优惠:满1000.00元,减120.00元,无优惠'
,
null
,
null
,
null
,
null
,
null
,
'大梨'
,
'18033441849'
,
'518000'
,
'广东省'
,
'深圳市'
,
'福田区'
,
'东晓街道'
,
null
,
'0'
,
'0'
);
INSERT
INTO
`oms_order`
VALUES
(
'14'
,
'1'
,
'2'
,
null
,
'2018-09-03 16:57:40'
,
'test'
,
'18732.00'
,
'16377.75'
,
'0.00'
,
'2344.25'
,
'0.00'
,
'10.00'
,
null
,
'0'
,
'1'
,
'0'
,
'0'
,
null
,
null
,
null
,
'18682'
,
'18682'
,
'单品促销,打折优惠:满3件,打7.50折,满减优惠:满1000.00元,减120.00元,满减优惠:满1000.00元,减120.00元,无优惠'
,
null
,
null
,
null
,
null
,
null
,
'大梨'
,
'18033441849'
,
'518000'
,
'广东省'
,
'深圳市'
,
'福田区'
,
'东晓街道'
,
null
,
'0'
,
'0'
);
INSERT
INTO
`oms_order`
VALUES
(
'15'
,
'1'
,
'2'
,
null
,
'2018-09-03 17:03:00'
,
'test'
,
'18732.00'
,
'16377.75'
,
'0.00'
,
'2344.25'
,
'0.00'
,
'10.00'
,
null
,
'0'
,
'1'
,
'0'
,
'0'
,
null
,
null
,
null
,
'18682'
,
'18682'
,
'单品促销,打折优惠:满3件,打7.50折,满减优惠:满1000.00元,减120.00元,满减优惠:满1000.00元,减120.00元,无优惠'
,
null
,
null
,
null
,
null
,
null
,
'大梨'
,
'18033441849'
,
'518000'
,
'广东省'
,
'深圳市'
,
'福田区'
,
'东晓街道'
,
null
,
'0'
,
'0'
);
INSERT
INTO
`oms_order`
VALUES
(
'12'
,
'1'
,
'2'
,
null
,
'2018-09-05 12:24:27'
,
'test'
,
'18732.00'
,
'16377.75'
,
'0.00'
,
'2344.25'
,
'0.00'
,
'10.00'
,
null
,
'0'
,
'1'
,
'1'
,
'0'
,
null
,
null
,
null
,
'0'
,
null
,
'单品促销,打折优惠:满3件,打7.50折,满减优惠:满1000.00元,减120.00元,满减优惠:满1000.00元,减120.00元,无优惠'
,
null
,
null
,
null
,
null
,
null
,
'大梨'
,
'18033441849'
,
'518000'
,
'广东省'
,
'深圳市'
,
'福田区'
,
'东晓街道'
,
null
,
'0'
,
'0'
,
null
);
INSERT
INTO
`oms_order`
VALUES
(
'13'
,
'1'
,
'2'
,
null
,
'2018-09-05 14:24:29'
,
'test'
,
'18732.00'
,
'16377.75'
,
'0.00'
,
'2344.25'
,
'0.00'
,
'10.00'
,
null
,
'0'
,
'1'
,
'4'
,
'0'
,
null
,
null
,
null
,
'0'
,
null
,
'单品促销,打折优惠:满3件,打7.50折,满减优惠:满1000.00元,减120.00元,满减优惠:满1000.00元,减120.00元,无优惠'
,
null
,
null
,
null
,
null
,
null
,
'大梨'
,
'18033441849'
,
'518000'
,
'广东省'
,
'深圳市'
,
'福田区'
,
'东晓街道'
,
null
,
'0'
,
'0'
,
'1000'
);
INSERT
INTO
`oms_order`
VALUES
(
'14'
,
'1'
,
'2'
,
null
,
'2018-09-03 16:57:40'
,
'test'
,
'18732.00'
,
'16377.75'
,
'0.00'
,
'2344.25'
,
'0.00'
,
'10.00'
,
null
,
'0'
,
'1'
,
'4'
,
'0'
,
null
,
null
,
null
,
'18682'
,
'18682'
,
'单品促销,打折优惠:满3件,打7.50折,满减优惠:满1000.00元,减120.00元,满减优惠:满1000.00元,减120.00元,无优惠'
,
null
,
null
,
null
,
null
,
null
,
'大梨'
,
'18033441849'
,
'518000'
,
'广东省'
,
'深圳市'
,
'福田区'
,
'东晓街道'
,
null
,
'0'
,
'0'
,
null
);
INSERT
INTO
`oms_order`
VALUES
(
'15'
,
'1'
,
'2'
,
null
,
'2018-09-03 17:03:00'
,
'test'
,
'18732.00'
,
'16377.75'
,
'0.00'
,
'2344.25'
,
'0.00'
,
'10.00'
,
null
,
'0'
,
'1'
,
'4'
,
'0'
,
null
,
null
,
null
,
'18682'
,
'18682'
,
'单品促销,打折优惠:满3件,打7.50折,满减优惠:满1000.00元,减120.00元,满减优惠:满1000.00元,减120.00元,无优惠'
,
null
,
null
,
null
,
null
,
null
,
'大梨'
,
'18033441849'
,
'518000'
,
'广东省'
,
'深圳市'
,
'福田区'
,
'东晓街道'
,
null
,
'0'
,
'0'
,
null
);
INSERT
INTO
`oms_order`
VALUES
(
'16'
,
'1'
,
'2'
,
null
,
'2018-09-04 16:16:16'
,
'test'
,
'18732.00'
,
'16377.75'
,
'0.00'
,
'2344.25'
,
'0.00'
,
'10.00'
,
null
,
'0'
,
'1'
,
'4'
,
'0'
,
null
,
null
,
null
,
'18682'
,
'18682'
,
'单品促销,打折优惠:满3件,打7.50折,满减优惠:满1000.00元,减120.00元,满减优惠:满1000.00元,减120.00元,无优惠'
,
null
,
null
,
null
,
null
,
null
,
'大梨'
,
'18033441849'
,
'518000'
,
'广东省'
,
'深圳市'
,
'福田区'
,
'东晓街道'
,
null
,
'0'
,
'0'
,
null
);
-- ----------------------------
-- Table structure for oms_order_item
...
...
@@ -419,7 +421,7 @@ CREATE TABLE `oms_order_item` (
`gift_integration`
int
(
11
)
DEFAULT
'0'
,
`gift_growth`
int
(
11
)
DEFAULT
'0'
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
4
1
DEFAULT
CHARSET
=
utf8
COMMENT
=
'订单中所包含的商品'
;
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
4
6
DEFAULT
CHARSET
=
utf8
COMMENT
=
'订单中所包含的商品'
;
-- ----------------------------
-- Records of oms_order_item
...
...
@@ -444,6 +446,11 @@ INSERT INTO `oms_order_item` VALUES ('37', '15', null, '27', null, '小米8', nu
INSERT
INTO
`oms_order_item`
VALUES
(
'38'
,
'15'
,
null
,
'28'
,
null
,
'红米5A'
,
null
,
null
,
'649.00'
,
'1'
,
'102'
,
'201808270028001'
,
'19'
,
null
,
null
,
null
,
'满减优惠:满1000.00元,减120.00元'
,
'57.60'
,
'0.35'
,
'0.00'
,
'591.05'
,
'0'
,
'0'
);
INSERT
INTO
`oms_order_item`
VALUES
(
'39'
,
'15'
,
null
,
'28'
,
null
,
'红米5A'
,
null
,
null
,
'699.00'
,
'1'
,
'103'
,
'201808270028001'
,
'19'
,
null
,
null
,
null
,
'满减优惠:满1000.00元,减120.00元'
,
'62.40'
,
'0.37'
,
'0.00'
,
'636.23'
,
'0'
,
'0'
);
INSERT
INTO
`oms_order_item`
VALUES
(
'40'
,
'15'
,
null
,
'29'
,
null
,
'Apple iPhone 8 Plus'
,
null
,
null
,
'5499.00'
,
'1'
,
'106'
,
'201808270029001'
,
'19'
,
null
,
null
,
null
,
'无优惠'
,
'0.00'
,
'2.94'
,
'0.00'
,
'5496.06'
,
'0'
,
'0'
);
INSERT
INTO
`oms_order_item`
VALUES
(
'41'
,
'16'
,
null
,
'26'
,
null
,
'华为 HUAWEI P20'
,
null
,
null
,
'3788.00'
,
'1'
,
'90'
,
'201806070026001'
,
'19'
,
null
,
null
,
null
,
'单品促销'
,
'200.00'
,
'2.02'
,
'0.00'
,
'3585.98'
,
'0'
,
'0'
);
INSERT
INTO
`oms_order_item`
VALUES
(
'42'
,
'16'
,
null
,
'27'
,
null
,
'小米8'
,
null
,
null
,
'2699.00'
,
'3'
,
'98'
,
'201808270027001'
,
'19'
,
null
,
null
,
null
,
'打折优惠:满3件,打7.50折'
,
'674.75'
,
'1.44'
,
'0.00'
,
'2022.81'
,
'0'
,
'0'
);
INSERT
INTO
`oms_order_item`
VALUES
(
'43'
,
'16'
,
null
,
'28'
,
null
,
'红米5A'
,
null
,
null
,
'649.00'
,
'1'
,
'102'
,
'201808270028001'
,
'19'
,
null
,
null
,
null
,
'满减优惠:满1000.00元,减120.00元'
,
'57.60'
,
'0.35'
,
'0.00'
,
'591.05'
,
'0'
,
'0'
);
INSERT
INTO
`oms_order_item`
VALUES
(
'44'
,
'16'
,
null
,
'28'
,
null
,
'红米5A'
,
null
,
null
,
'699.00'
,
'1'
,
'103'
,
'201808270028001'
,
'19'
,
null
,
null
,
null
,
'满减优惠:满1000.00元,减120.00元'
,
'62.40'
,
'0.37'
,
'0.00'
,
'636.23'
,
'0'
,
'0'
);
INSERT
INTO
`oms_order_item`
VALUES
(
'45'
,
'16'
,
null
,
'29'
,
null
,
'Apple iPhone 8 Plus'
,
null
,
null
,
'5499.00'
,
'1'
,
'106'
,
'201808270029001'
,
'19'
,
null
,
null
,
null
,
'无优惠'
,
'0.00'
,
'2.94'
,
'0.00'
,
'5496.06'
,
'0'
,
'0'
);
-- ----------------------------
-- Table structure for oms_order_operate_history
...
...
@@ -530,11 +537,12 @@ CREATE TABLE `oms_order_setting` (
`finish_overtime`
int
(
11
)
DEFAULT
NULL
COMMENT
'自动完成交易时间,不能申请售后(天)'
,
`comment_overtime`
int
(
11
)
DEFAULT
NULL
COMMENT
'订单完成后自动好评时间(天)'
,
PRIMARY
KEY
(
`id`
)
)
ENGINE
=
InnoDB
DEFAULT
CHARSET
=
utf8
COMMENT
=
'订单设置表'
;
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
2
DEFAULT
CHARSET
=
utf8
COMMENT
=
'订单设置表'
;
-- ----------------------------
-- Records of oms_order_setting
-- ----------------------------
INSERT
INTO
`oms_order_setting`
VALUES
(
'1'
,
'40'
,
'60'
,
'15'
,
'7'
,
'7'
);
-- ----------------------------
-- Table structure for pms_album
...
...
@@ -1237,19 +1245,19 @@ INSERT INTO `pms_sku_stock` VALUES ('78', '23', '201806070023001', '99.00', '0',
INSERT
INTO
`pms_sku_stock`
VALUES
(
'79'
,
'23'
,
'201806070023002'
,
'99.00'
,
'0'
,
null
,
'米白色'
,
'X'
,
null
,
'http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180604/1522738681.jpg'
,
null
,
null
,
'0'
);
INSERT
INTO
`pms_sku_stock`
VALUES
(
'80'
,
'23'
,
'201806070023003'
,
'99.00'
,
'0'
,
null
,
'浅黄色'
,
'M'
,
null
,
'http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180604/2017091716493787_20170917164937650 (1).png'
,
null
,
null
,
'0'
);
INSERT
INTO
`pms_sku_stock`
VALUES
(
'81'
,
'23'
,
'201806070023004'
,
'99.00'
,
'0'
,
null
,
'浅黄色'
,
'X'
,
null
,
'http://macro-oss.oss-cn-shenzhen.aliyuncs.com/mall/images/20180604/2017091716493787_20170917164937650 (1).png'
,
null
,
null
,
'0'
);
INSERT
INTO
`pms_sku_stock`
VALUES
(
'90'
,
'26'
,
'201806070026001'
,
'3788.00'
,
'
500
'
,
null
,
'金色'
,
'16G'
,
null
,
null
,
null
,
'3588.00'
,
'
19
'
);
INSERT
INTO
`pms_sku_stock`
VALUES
(
'90'
,
'26'
,
'201806070026001'
,
'3788.00'
,
'
499
'
,
null
,
'金色'
,
'16G'
,
null
,
null
,
null
,
'3588.00'
,
'
-4
'
);
INSERT
INTO
`pms_sku_stock`
VALUES
(
'91'
,
'26'
,
'201806070026002'
,
'3999.00'
,
'500'
,
null
,
'金色'
,
'32G'
,
null
,
null
,
null
,
'3799.00'
,
'0'
);
INSERT
INTO
`pms_sku_stock`
VALUES
(
'92'
,
'26'
,
'201806070026003'
,
'3788.00'
,
'500'
,
null
,
'银色'
,
'16G'
,
null
,
null
,
null
,
'3588.00'
,
'0'
);
INSERT
INTO
`pms_sku_stock`
VALUES
(
'93'
,
'26'
,
'201806070026004'
,
'3999.00'
,
'500'
,
null
,
'银色'
,
'32G'
,
null
,
null
,
null
,
'3799.00'
,
'0'
);
INSERT
INTO
`pms_sku_stock`
VALUES
(
'98'
,
'27'
,
'201808270027001'
,
'2699.00'
,
'
100
'
,
null
,
'黑色'
,
'32G'
,
null
,
null
,
null
,
null
,
'
57
'
);
INSERT
INTO
`pms_sku_stock`
VALUES
(
'98'
,
'27'
,
'201808270027001'
,
'2699.00'
,
'
97
'
,
null
,
'黑色'
,
'32G'
,
null
,
null
,
null
,
null
,
'
-12
'
);
INSERT
INTO
`pms_sku_stock`
VALUES
(
'99'
,
'27'
,
'201808270027002'
,
'2999.00'
,
'100'
,
null
,
'黑色'
,
'64G'
,
null
,
null
,
null
,
null
,
'0'
);
INSERT
INTO
`pms_sku_stock`
VALUES
(
'100'
,
'27'
,
'201808270027003'
,
'2699.00'
,
'100'
,
null
,
'蓝色'
,
'32G'
,
null
,
null
,
null
,
null
,
'0'
);
INSERT
INTO
`pms_sku_stock`
VALUES
(
'101'
,
'27'
,
'201808270027004'
,
'2999.00'
,
'100'
,
null
,
'蓝色'
,
'64G'
,
null
,
null
,
null
,
null
,
'0'
);
INSERT
INTO
`pms_sku_stock`
VALUES
(
'102'
,
'28'
,
'201808270028001'
,
'649.00'
,
'
100
'
,
null
,
'金色'
,
'16G'
,
null
,
null
,
null
,
null
,
'
19
'
);
INSERT
INTO
`pms_sku_stock`
VALUES
(
'103'
,
'28'
,
'201808270028002'
,
'699.00'
,
'
100
'
,
null
,
'金色'
,
'32G'
,
null
,
null
,
null
,
null
,
'
19
'
);
INSERT
INTO
`pms_sku_stock`
VALUES
(
'102'
,
'28'
,
'201808270028001'
,
'649.00'
,
'
99
'
,
null
,
'金色'
,
'16G'
,
null
,
null
,
null
,
null
,
'
-4
'
);
INSERT
INTO
`pms_sku_stock`
VALUES
(
'103'
,
'28'
,
'201808270028002'
,
'699.00'
,
'
99
'
,
null
,
'金色'
,
'32G'
,
null
,
null
,
null
,
null
,
'
-4
'
);
INSERT
INTO
`pms_sku_stock`
VALUES
(
'104'
,
'28'
,
'201808270028003'
,
'649.00'
,
'100'
,
null
,
'银色'
,
'16G'
,
null
,
null
,
null
,
null
,
'0'
);
INSERT
INTO
`pms_sku_stock`
VALUES
(
'105'
,
'28'
,
'201808270028004'
,
'699.00'
,
'100'
,
null
,
'银色'
,
'32G'
,
null
,
null
,
null
,
null
,
'0'
);
INSERT
INTO
`pms_sku_stock`
VALUES
(
'106'
,
'29'
,
'201808270029001'
,
'5499.00'
,
'
100
'
,
null
,
'金色'
,
'32G'
,
null
,
null
,
null
,
null
,
'
19
'
);
INSERT
INTO
`pms_sku_stock`
VALUES
(
'106'
,
'29'
,
'201808270029001'
,
'5499.00'
,
'
99
'
,
null
,
'金色'
,
'32G'
,
null
,
null
,
null
,
null
,
'
-4
'
);
INSERT
INTO
`pms_sku_stock`
VALUES
(
'107'
,
'29'
,
'201808270029002'
,
'6299.00'
,
'100'
,
null
,
'金色'
,
'64G'
,
null
,
null
,
null
,
null
,
'0'
);
INSERT
INTO
`pms_sku_stock`
VALUES
(
'108'
,
'29'
,
'201808270029003'
,
'5499.00'
,
'100'
,
null
,
'银色'
,
'32G'
,
null
,
null
,
null
,
null
,
'0'
);
INSERT
INTO
`pms_sku_stock`
VALUES
(
'109'
,
'29'
,
'201808270029004'
,
'6299.00'
,
'100'
,
null
,
'银色'
,
'64G'
,
null
,
null
,
null
,
null
,
'0'
);
...
...
@@ -1286,7 +1294,7 @@ CREATE TABLE `sms_coupon` (
INSERT
INTO
`sms_coupon`
VALUES
(
'2'
,
'0'
,
'全品类通用券'
,
'0'
,
'99'
,
'10.00'
,
'1'
,
'100.00'
,
'2018-08-27 16:40:47'
,
'2018-09-15 16:40:47'
,
'0'
,
'满100减10'
,
'100'
,
'0'
,
'1'
,
'2018-08-27 16:40:47'
,
null
,
null
);
INSERT
INTO
`sms_coupon`
VALUES
(
'3'
,
'0'
,
'小米手机专用券'
,
'0'
,
'99'
,
'50.00'
,
'1'
,
'1000.00'
,
'2018-08-27 16:40:47'
,
'2018-09-15 16:40:47'
,
'2'
,
'小米手机专用优惠券'
,
'100'
,
'0'
,
'1'
,
'2018-08-27 16:40:47'
,
null
,
null
);
INSERT
INTO
`sms_coupon`
VALUES
(
'4'
,
'0'
,
'手机品类专用券'
,
'0'
,
'99'
,
'300.00'
,
'1'
,
'2000.00'
,
'2018-08-27 16:40:47'
,
'2018-09-15 16:40:47'
,
'1'
,
'手机分类专用优惠券'
,
'100'
,
'0'
,
'1'
,
'2018-08-27 16:40:47'
,
null
,
null
);
INSERT
INTO
`sms_coupon`
VALUES
(
'7'
,
'0'
,
'T恤分类专用优惠券'
,
'0'
,
'9
9
'
,
'50.00'
,
'1'
,
'500.00'
,
'2018-08-27 16:40:47'
,
'2018-08-15 16:40:47'
,
'1'
,
'满500减50'
,
'100'
,
'0'
,
'
1
'
,
'2018-08-27 16:40:47'
,
null
,
null
);
INSERT
INTO
`sms_coupon`
VALUES
(
'7'
,
'0'
,
'T恤分类专用优惠券'
,
'0'
,
'9
3
'
,
'50.00'
,
'1'
,
'500.00'
,
'2018-08-27 16:40:47'
,
'2018-08-15 16:40:47'
,
'1'
,
'满500减50'
,
'100'
,
'0'
,
'
7
'
,
'2018-08-27 16:40:47'
,
null
,
null
);
-- ----------------------------
-- Table structure for sms_coupon_history
...
...
@@ -1306,15 +1314,15 @@ CREATE TABLE `sms_coupon_history` (
PRIMARY
KEY
(
`id`
),
KEY
`idx_member_id`
(
`member_id`
)
USING
BTREE
,
KEY
`idx_coupon_id`
(
`coupon_id`
)
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
6
DEFAULT
CHARSET
=
utf8
COMMENT
=
'优惠券使用、领取历史表'
;
)
ENGINE
=
InnoDB
AUTO_INCREMENT
=
12
DEFAULT
CHARSET
=
utf8
COMMENT
=
'优惠券使用、领取历史表'
;
-- ----------------------------
-- Records of sms_coupon_history
-- ----------------------------
INSERT
INTO
`sms_coupon_history`
VALUES
(
'2'
,
'2'
,
'1'
,
null
,
'windir'
,
'1'
,
'2018-08-29 14:04:12'
,
'
1
'
,
'2018-09-0
3
1
7:03:00
'
,
null
);
INSERT
INTO
`sms_coupon_history`
VALUES
(
'2'
,
'2'
,
'1'
,
null
,
'windir'
,
'1'
,
'2018-08-29 14:04:12'
,
'
0
'
,
'2018-09-0
4
1
6:16:16
'
,
null
);
INSERT
INTO
`sms_coupon_history`
VALUES
(
'3'
,
'3'
,
'1'
,
null
,
'windir'
,
'1'
,
'2018-08-29 14:04:29'
,
'0'
,
null
,
null
);
INSERT
INTO
`sms_coupon_history`
VALUES
(
'4'
,
'4'
,
'1'
,
null
,
'windir'
,
'1'
,
'2018-08-29 14:04:32'
,
'0'
,
null
,
null
);
INSERT
INTO
`sms_coupon_history`
VALUES
(
'
5
'
,
'7'
,
'1'
,
null
,
'windir'
,
'1'
,
'2018-0
8-29 14:04:37
'
,
'0'
,
null
,
null
);
INSERT
INTO
`sms_coupon_history`
VALUES
(
'
11
'
,
'7'
,
'1'
,
'4931048380330001'
,
'windir'
,
'1'
,
'2018-0
9-04 16:21:50
'
,
'0'
,
null
,
null
);
-- ----------------------------
-- Table structure for sms_coupon_product_category_relation
...
...
@@ -1607,7 +1615,7 @@ CREATE TABLE `ums_member` (
-- ----------------------------
-- Records of ums_member
-- ----------------------------
INSERT
INTO
`ums_member`
VALUES
(
'1'
,
'4'
,
'test'
,
'202cb962ac59075b964b07152d234b70'
,
'windir'
,
'18061581849'
,
'1'
,
'2018-08-02 10:35:44'
,
null
,
'1'
,
'2009-06-01'
,
'上海'
,
'学生'
,
'test'
,
null
,
'
1
000'
,
null
,
null
,
null
);
INSERT
INTO
`ums_member`
VALUES
(
'1'
,
'4'
,
'test'
,
'202cb962ac59075b964b07152d234b70'
,
'windir'
,
'18061581849'
,
'1'
,
'2018-08-02 10:35:44'
,
null
,
'1'
,
'2009-06-01'
,
'上海'
,
'学生'
,
'test'
,
null
,
'
3
000'
,
null
,
null
,
null
);
INSERT
INTO
`ums_member`
VALUES
(
'3'
,
'4'
,
'test1'
,
'698d51a19d8a121ce581499d7b701668'
,
null
,
'18061581848'
,
'1'
,
'2018-08-03 16:46:38'
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
);
-- ----------------------------
...
...
mall-admin/src/main/java/com/macro/mall/service/impl/SmsCouponServiceImpl.java
View file @
cbdb93ee
...
...
@@ -37,7 +37,6 @@ public class SmsCouponServiceImpl implements SmsCouponService {
@Override
public
int
add
(
SmsCouponParam
couponParam
)
{
//插入优惠券表
// TODO: 2018/8/28 生成优惠券条码
int
count
=
couponMapper
.
insert
(
couponParam
);
//插入优惠券和商品关系表
if
(
couponParam
.
getUseType
().
equals
(
2
)){
...
...
mall-mbg/src/main/java/com/macro/mall/model/OmsOrder.java
View file @
cbdb93ee
...
...
@@ -261,6 +261,13 @@ public class OmsOrder implements Serializable {
*/
private
Integer
deleteStatus
;
/**
* 下单时使用的积分
*
* @mbggenerated
*/
private
Integer
useIntegration
;
private
static
final
long
serialVersionUID
=
1L
;
public
Long
getId
()
{
...
...
@@ -567,6 +574,14 @@ public class OmsOrder implements Serializable {
this
.
deleteStatus
=
deleteStatus
;
}
public
Integer
getUseIntegration
()
{
return
useIntegration
;
}
public
void
setUseIntegration
(
Integer
useIntegration
)
{
this
.
useIntegration
=
useIntegration
;
}
@Override
public
String
toString
()
{
StringBuilder
sb
=
new
StringBuilder
();
...
...
@@ -611,6 +626,7 @@ public class OmsOrder implements Serializable {
sb
.
append
(
", note="
).
append
(
note
);
sb
.
append
(
", confirmStatus="
).
append
(
confirmStatus
);
sb
.
append
(
", deleteStatus="
).
append
(
deleteStatus
);
sb
.
append
(
", useIntegration="
).
append
(
useIntegration
);
sb
.
append
(
", serialVersionUID="
).
append
(
serialVersionUID
);
sb
.
append
(
"]"
);
return
sb
.
toString
();
...
...
mall-mbg/src/main/java/com/macro/mall/model/OmsOrderExample.java
View file @
cbdb93ee
...
...
@@ -2555,6 +2555,66 @@ public class OmsOrderExample {
addCriterion
(
"delete_status not between"
,
value1
,
value2
,
"deleteStatus"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUseIntegrationIsNull
()
{
addCriterion
(
"use_integration is null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUseIntegrationIsNotNull
()
{
addCriterion
(
"use_integration is not null"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUseIntegrationEqualTo
(
Integer
value
)
{
addCriterion
(
"use_integration ="
,
value
,
"useIntegration"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUseIntegrationNotEqualTo
(
Integer
value
)
{
addCriterion
(
"use_integration <>"
,
value
,
"useIntegration"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUseIntegrationGreaterThan
(
Integer
value
)
{
addCriterion
(
"use_integration >"
,
value
,
"useIntegration"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUseIntegrationGreaterThanOrEqualTo
(
Integer
value
)
{
addCriterion
(
"use_integration >="
,
value
,
"useIntegration"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUseIntegrationLessThan
(
Integer
value
)
{
addCriterion
(
"use_integration <"
,
value
,
"useIntegration"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUseIntegrationLessThanOrEqualTo
(
Integer
value
)
{
addCriterion
(
"use_integration <="
,
value
,
"useIntegration"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUseIntegrationIn
(
List
<
Integer
>
values
)
{
addCriterion
(
"use_integration in"
,
values
,
"useIntegration"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUseIntegrationNotIn
(
List
<
Integer
>
values
)
{
addCriterion
(
"use_integration not in"
,
values
,
"useIntegration"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUseIntegrationBetween
(
Integer
value1
,
Integer
value2
)
{
addCriterion
(
"use_integration between"
,
value1
,
value2
,
"useIntegration"
);
return
(
Criteria
)
this
;
}
public
Criteria
andUseIntegrationNotBetween
(
Integer
value1
,
Integer
value2
)
{
addCriterion
(
"use_integration not between"
,
value1
,
value2
,
"useIntegration"
);
return
(
Criteria
)
this
;
}
}
public
static
class
Criteria
extends
GeneratedCriteria
{
...
...
mall-mbg/src/main/resources/com/macro/mall/mapper/OmsOrderMapper.xml
View file @
cbdb93ee
...
...
@@ -40,6 +40,7 @@
<result
column=
"note"
jdbcType=
"VARCHAR"
property=
"note"
/>
<result
column=
"confirm_status"
jdbcType=
"INTEGER"
property=
"confirmStatus"
/>
<result
column=
"delete_status"
jdbcType=
"INTEGER"
property=
"deleteStatus"
/>
<result
column=
"use_integration"
jdbcType=
"INTEGER"
property=
"useIntegration"
/>
</resultMap>
<sql
id=
"Example_Where_Clause"
>
<where>
...
...
@@ -105,7 +106,8 @@
pay_type, source_type, status, order_type, delivery_company, delivery_sn, auto_confirm_day,
integration, growth, promotion_info, bill_type, bill_header, bill_content, bill_receiver_phone,
bill_receiver_email, receiver_name, receiver_phone, receiver_post_code, receiver_province,
receiver_city, receiver_region, receiver_detail_address, note, confirm_status, delete_status
receiver_city, receiver_region, receiver_detail_address, note, confirm_status, delete_status,
use_integration
</sql>
<select
id=
"selectByExample"
parameterType=
"com.macro.mall.model.OmsOrderExample"
resultMap=
"BaseResultMap"
>
select
...
...
@@ -153,7 +155,7 @@
receiver_name, receiver_phone, receiver_post_code,
receiver_province, receiver_city, receiver_region,
receiver_detail_address, note, confirm_status,
delete_status)
delete_status
, use_integration
)
values (#{memberId,jdbcType=BIGINT}, #{couponId,jdbcType=BIGINT}, #{orderSn,jdbcType=VARCHAR},
#{createTime,jdbcType=TIMESTAMP}, #{memberUsername,jdbcType=VARCHAR}, #{totalAmount,jdbcType=DECIMAL},
#{payAmount,jdbcType=DECIMAL}, #{freightAmount,jdbcType=DECIMAL}, #{promotionAmount,jdbcType=DECIMAL},
...
...
@@ -166,7 +168,7 @@
#{receiverName,jdbcType=VARCHAR}, #{receiverPhone,jdbcType=VARCHAR}, #{receiverPostCode,jdbcType=VARCHAR},
#{receiverProvince,jdbcType=VARCHAR}, #{receiverCity,jdbcType=VARCHAR}, #{receiverRegion,jdbcType=VARCHAR},
#{receiverDetailAddress,jdbcType=VARCHAR}, #{note,jdbcType=VARCHAR}, #{confirmStatus,jdbcType=INTEGER},
#{deleteStatus,jdbcType=INTEGER})
#{deleteStatus,jdbcType=INTEGER}
, #{useIntegration,jdbcType=INTEGER}
)
</insert>
<insert
id=
"insertSelective"
parameterType=
"com.macro.mall.model.OmsOrder"
>
<selectKey
keyProperty=
"id"
order=
"AFTER"
resultType=
"java.lang.Long"
>
...
...
@@ -285,6 +287,9 @@
<if
test=
"deleteStatus != null"
>
delete_status,
</if>
<if
test=
"useIntegration != null"
>
use_integration,
</if>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"memberId != null"
>
...
...
@@ -398,6 +403,9 @@
<if
test=
"deleteStatus != null"
>
#{deleteStatus,jdbcType=INTEGER},
</if>
<if
test=
"useIntegration != null"
>
#{useIntegration,jdbcType=INTEGER},
</if>
</trim>
</insert>
<select
id=
"countByExample"
parameterType=
"com.macro.mall.model.OmsOrderExample"
resultType=
"java.lang.Integer"
>
...
...
@@ -523,6 +531,9 @@
<if
test=
"record.deleteStatus != null"
>
delete_status = #{record.deleteStatus,jdbcType=INTEGER},
</if>
<if
test=
"record.useIntegration != null"
>
use_integration = #{record.useIntegration,jdbcType=INTEGER},
</if>
</set>
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
...
...
@@ -567,7 +578,8 @@
receiver_detail_address = #{record.receiverDetailAddress,jdbcType=VARCHAR},
note = #{record.note,jdbcType=VARCHAR},
confirm_status = #{record.confirmStatus,jdbcType=INTEGER},
delete_status = #{record.deleteStatus,jdbcType=INTEGER}
delete_status = #{record.deleteStatus,jdbcType=INTEGER},
use_integration = #{record.useIntegration,jdbcType=INTEGER}
<if
test=
"_parameter != null"
>
<include
refid=
"Update_By_Example_Where_Clause"
/>
</if>
...
...
@@ -686,6 +698,9 @@
<if
test=
"deleteStatus != null"
>
delete_status = #{deleteStatus,jdbcType=INTEGER},
</if>
<if
test=
"useIntegration != null"
>
use_integration = #{useIntegration,jdbcType=INTEGER},
</if>
</set>
where id = #{id,jdbcType=BIGINT}
</update>
...
...
@@ -727,7 +742,8 @@
receiver_detail_address = #{receiverDetailAddress,jdbcType=VARCHAR},
note = #{note,jdbcType=VARCHAR},
confirm_status = #{confirmStatus,jdbcType=INTEGER},
delete_status = #{deleteStatus,jdbcType=INTEGER}
delete_status = #{deleteStatus,jdbcType=INTEGER},
use_integration = #{useIntegration,jdbcType=INTEGER}
where id = #{id,jdbcType=BIGINT}
</update>
</mapper>
\ No newline at end of file
mall-portal/src/main/java/com/macro/mall/portal/component/OrderTimeOutCancelTask.java
View file @
cbdb93ee
package
com.macro.mall.portal.component
;
import
com.macro.mall.portal.domain.CommonResult
;
import
com.macro.mall.portal.service.OmsPortalOrderService
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Component
;
...
...
@@ -12,13 +15,16 @@ import org.springframework.stereotype.Component;
@Component
public
class
OrderTimeOutCancelTask
{
private
Logger
LOGGER
=
LoggerFactory
.
getLogger
(
OrderTimeOutCancelTask
.
class
);
@Autowired
private
OmsPortalOrderService
portalOrderService
;
/**
* cron表达式:Seconds Minutes Hours DayofMonth Month DayofWeek [Year]
* 每10分钟扫描一次,扫描超时时间
*2时间内所下
订单,如果没支付则取消该订单
* 每10分钟扫描一次,扫描
设定
超时时间
之前下的
订单,如果没支付则取消该订单
*/
@Scheduled
(
cron
=
"0 0/10 * ? * ?"
)
private
void
cancelTimeOutOrder
(){
LOGGER
.
info
(
"取消订单,并根据sku编号释放锁定库存"
);
CommonResult
result
=
portalOrderService
.
cancelTimeOutOrder
();
LOGGER
.
info
(
"取消订单,并根据sku编号释放锁定库存:{}"
,
result
);
}
}
mall-portal/src/main/java/com/macro/mall/portal/controller/OmsPortalOrderController.java
View file @
cbdb93ee
...
...
@@ -8,10 +8,7 @@ import io.swagger.annotations.Api;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
org.springframework.web.bind.annotation.*
;
/**
* 订单管理Controller
...
...
@@ -37,4 +34,17 @@ public class OmsPortalOrderController {
public
Object
generateOrder
(
@RequestBody
OrderParam
orderParam
){
return
portalOrderService
.
generateOrder
(
orderParam
);
}
@ApiOperation
(
"支付成功的回调"
)
@RequestMapping
(
value
=
"/paySuccess"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Object
paySuccess
(
@RequestParam
Long
orderId
){
return
portalOrderService
.
paySuccess
(
orderId
);
}
@ApiOperation
(
"自动取消超时订单"
)
@RequestMapping
(
value
=
"/cancelTimeOutOrder"
,
method
=
RequestMethod
.
POST
)
@ResponseBody
public
Object
cancelTimeOutOrder
(){
return
portalOrderService
.
cancelTimeOutOrder
();
}
}
mall-portal/src/main/java/com/macro/mall/portal/dao/PortalOrderDao.java
0 → 100644
View file @
cbdb93ee
package
com.macro.mall.portal.dao
;
import
com.macro.mall.model.OmsOrderItem
;
import
com.macro.mall.portal.domain.OmsOrderDetail
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
/**
* 前台订单自定义Dao
* Created by macro on 2018/9/4.
*/
public
interface
PortalOrderDao
{
/**
* 获取订单及下单商品详情
*/
OmsOrderDetail
getDetail
(
@Param
(
"orderId"
)
Long
orderId
);
/**
* 修改 pms_sku_stock表的锁定库存及真实库存
*/
int
updateSkuStock
(
@Param
(
"itemList"
)
List
<
OmsOrderItem
>
orderItemList
);
/**
* 获取超时订单
* @param minute 超时时间(分)
*/
List
<
OmsOrderDetail
>
getTimeOutOrders
(
@Param
(
"minute"
)
Integer
minute
);
/**
* 批量修改订单状态
*/
int
updateOrderStatus
(
@Param
(
"ids"
)
List
<
Long
>
ids
,
@Param
(
"status"
)
Integer
status
);
/**
* 解除取消订单的库存锁定
*/
int
releaseSkuStockLock
(
@Param
(
"itemList"
)
List
<
OmsOrderItem
>
orderItemList
);
}
mall-portal/src/main/java/com/macro/mall/portal/domain/OmsOrderDetail.java
0 → 100644
View file @
cbdb93ee
package
com.macro.mall.portal.domain
;
import
com.macro.mall.model.OmsOrder
;
import
com.macro.mall.model.OmsOrderItem
;
import
java.util.List
;
/**
* 包含订单商品信息的订单详情
* Created by macro on 2018/9/4.
*/
public
class
OmsOrderDetail
extends
OmsOrder
{
private
List
<
OmsOrderItem
>
orderItemList
;
public
List
<
OmsOrderItem
>
getOrderItemList
()
{
return
orderItemList
;
}
public
void
setOrderItemList
(
List
<
OmsOrderItem
>
orderItemList
)
{
this
.
orderItemList
=
orderItemList
;
}
}
mall-portal/src/main/java/com/macro/mall/portal/service/OmsPortalOrderService.java
View file @
cbdb93ee
...
...
@@ -20,4 +20,16 @@ public interface OmsPortalOrderService {
*/
@Transactional
CommonResult
generateOrder
(
OrderParam
orderParam
);
/**
* 支付成功后的回调
*/
@Transactional
CommonResult
paySuccess
(
Long
orderId
);
/**
* 自动取消超时订单
*/
@Transactional
CommonResult
cancelTimeOutOrder
();
}
mall-portal/src/main/java/com/macro/mall/portal/service/RedisService.java
View file @
cbdb93ee
...
...
@@ -25,4 +25,11 @@ public interface RedisService {
* 删除数据
*/
void
remove
(
String
key
);
/**
* 自增操作
* @param delta 自增步长
*/
Long
increment
(
String
key
,
long
delta
);
}
mall-portal/src/main/java/com/macro/mall/portal/service/UmsMemberService.java
View file @
cbdb93ee
...
...
@@ -14,6 +14,11 @@ public interface UmsMemberService {
*/
UmsMember
getByUsername
(
String
username
);
/**
* 根据会员编号获取会员
*/
UmsMember
getById
(
Long
id
);
/**
* 用户注册
*/
...
...
@@ -35,4 +40,9 @@ public interface UmsMemberService {
* 获取当前登录会员
*/
UmsMember
getCurrentMember
();
/**
* 根据会员id修改会员积分
*/
void
updateIntegration
(
Long
id
,
Integer
integration
);
}
mall-portal/src/main/java/com/macro/mall/portal/service/impl/OmsPortalOrderServiceImpl.java
View file @
cbdb93ee
package
com.macro.mall.portal.service.impl
;
import
com.macro.mall.mapper.OmsOrderMapper
;
import
com.macro.mall.mapper.PmsSkuStockMapper
;
import
com.macro.mall.mapper.SmsCouponHistoryMapper
;
import
com.macro.mall.mapper.UmsIntegrationConsumeSettingMapper
;
import
com.macro.mall.mapper.*
;
import
com.macro.mall.model.*
;
import
com.macro.mall.portal.dao.PortalOrderDao
;
import
com.macro.mall.portal.dao.PortalOrderItemDao
;
import
com.macro.mall.portal.dao.SmsCouponHistoryDao
;
import
com.macro.mall.portal.domain.*
;
import
com.macro.mall.portal.service.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
import
java.text.SimpleDateFormat
;
import
java.util.*
;
/**
...
...
@@ -43,7 +43,14 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
private
PortalOrderItemDao
orderItemDao
;
@Autowired
private
SmsCouponHistoryMapper
couponHistoryMapper
;
@Autowired
private
RedisService
redisService
;
@Value
(
"${redis.key.prefix.orderId}"
)
private
String
REDIS_KEY_PREFIX_ORDER_ID
;
@Autowired
private
PortalOrderDao
portalOrderDao
;
@Autowired
private
OmsOrderSettingMapper
orderSettingMapper
;
@Override
public
ConfirmOrderResult
generateConfirmOrder
()
{
ConfirmOrderResult
result
=
new
ConfirmOrderResult
();
...
...
@@ -184,15 +191,25 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
order
.
setIntegration
(
calcGifIntegration
(
orderItemList
));
//计算赠送成长值
order
.
setGrowth
(
calcGiftGrowth
(
orderItemList
));
// TODO: 2018/9/3 order_sn,bill_*,delivery_*
//生成订单号
order
.
setOrderSn
(
generateOrderSn
(
order
));
// TODO: 2018/9/3 bill_*,delivery_*
//插入order表和order_item表
orderMapper
.
insert
(
order
);
for
(
OmsOrderItem
orderItem
:
orderItemList
)
{
orderItem
.
setOrderId
(
order
.
getId
());
orderItem
.
setOrderSn
(
order
.
getOrderSn
());
}
orderItemDao
.
insertList
(
orderItemList
);
//更新优惠券使用状态
updateCouponStatus
(
orderParam
.
getCouponId
(),
currentMember
);
//如使用优惠券更新优惠券使用状态
if
(
orderParam
.
getCouponId
()!=
null
){
updateCouponStatus
(
orderParam
.
getCouponId
(),
currentMember
.
getId
(),
1
);
}
//如使用积分需要扣除积分
if
(
orderParam
.
getUseIntegration
()!=
null
){
order
.
setUseIntegration
(
orderParam
.
getUseIntegration
());
memberService
.
updateIntegration
(
currentMember
.
getId
(),
currentMember
.
getIntegration
()-
orderParam
.
getUseIntegration
());
}
//删除购物车中的下单商品
deleteCartItemList
(
cartPromotionItemList
,
currentMember
);
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
...
...
@@ -201,6 +218,67 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
return
new
CommonResult
().
success
(
"下单成功"
,
result
);
}
@Override
public
CommonResult
paySuccess
(
Long
orderId
)
{
//修改订单支付状态
OmsOrder
order
=
new
OmsOrder
();
order
.
setId
(
orderId
);
order
.
setStatus
(
1
);
orderMapper
.
updateByPrimaryKeySelective
(
order
);
//恢复所有下单商品的锁定库存,扣减真实库存
OmsOrderDetail
orderDetail
=
portalOrderDao
.
getDetail
(
orderId
);
int
count
=
portalOrderDao
.
updateSkuStock
(
orderDetail
.
getOrderItemList
());
return
new
CommonResult
().
success
(
"支付成功"
,
count
);
}
@Override
public
CommonResult
cancelTimeOutOrder
()
{
OmsOrderSetting
orderSetting
=
orderSettingMapper
.
selectByPrimaryKey
(
1L
);
//查询超时、未支付的订单及订单详情
List
<
OmsOrderDetail
>
timeOutOrders
=
portalOrderDao
.
getTimeOutOrders
(
orderSetting
.
getNormalOrderOvertime
());
if
(
CollectionUtils
.
isEmpty
(
timeOutOrders
)){
return
new
CommonResult
().
failed
(
"暂无超时订单"
);
}
//修改订单状态为交易取消
List
<
Long
>
ids
=
new
ArrayList
<>();
for
(
OmsOrderDetail
timeOutOrder
:
timeOutOrders
)
{
ids
.
add
(
timeOutOrder
.
getId
());
}
portalOrderDao
.
updateOrderStatus
(
ids
,
4
);
for
(
OmsOrderDetail
timeOutOrder
:
timeOutOrders
)
{
//解除订单商品库存锁定
portalOrderDao
.
releaseSkuStockLock
(
timeOutOrder
.
getOrderItemList
());
//修改优惠券使用状态
updateCouponStatus
(
timeOutOrder
.
getCouponId
(),
timeOutOrder
.
getMemberId
(),
0
);
//返还使用积分
if
(
timeOutOrder
.
getUseIntegration
()!=
null
){
UmsMember
member
=
memberService
.
getById
(
timeOutOrder
.
getMemberId
());
memberService
.
updateIntegration
(
timeOutOrder
.
getMemberId
(),
member
.
getIntegration
()+
timeOutOrder
.
getUseIntegration
());
}
}
return
new
CommonResult
().
success
(
null
);
}
/**
* 生成18位订单编号:8位日期+2位平台号码+2位支付方式+6位以上自增id
*/
private
String
generateOrderSn
(
OmsOrder
order
)
{
StringBuilder
sb
=
new
StringBuilder
();
String
date
=
new
SimpleDateFormat
(
"yyyyMMdd"
).
format
(
new
Date
());
String
key
=
REDIS_KEY_PREFIX_ORDER_ID
+
date
;
Long
increment
=
redisService
.
increment
(
key
,
1
);
sb
.
append
(
date
);
sb
.
append
(
String
.
format
(
"%02d"
,
order
.
getSourceType
()));
sb
.
append
(
String
.
format
(
"%02d"
,
order
.
getPayType
()));
String
incrementStr
=
increment
.
toString
();
if
(
incrementStr
.
length
()<=
6
){
sb
.
append
(
String
.
format
(
"%06d"
,
increment
));
}
else
{
sb
.
append
(
incrementStr
);
}
return
sb
.
toString
();
}
/**
* 删除下单商品的购物车信息
*/
...
...
@@ -235,22 +313,22 @@ public class OmsPortalOrderServiceImpl implements OmsPortalOrderService {
}
/**
*
更新sms_coupon_history的可用信息
*
将优惠券信息更改为指定状态
* @param couponId 优惠券id
* @param currentMember 当前会员
* @param memberId 会员id
* @param useStatus 0->未使用;1->已使用
*/
private
void
updateCouponStatus
(
Long
couponId
,
UmsMember
currentMember
)
{
SmsCouponHistory
record
=
new
SmsCouponHistory
();
record
.
setUseStatus
(
1
);
//查询第一张未使用优惠券
private
void
updateCouponStatus
(
Long
couponId
,
Long
memberId
,
Integer
useStatus
)
{
if
(
couponId
==
null
)
return
;
//查询第一张优惠券
SmsCouponHistoryExample
example
=
new
SmsCouponHistoryExample
();
example
.
createCriteria
().
andMemberIdEqualTo
(
currentMember
.
getId
()
)
.
andCouponIdEqualTo
(
couponId
).
andUseStatusEqualTo
(
0
);
example
.
createCriteria
().
andMemberIdEqualTo
(
memberId
)
.
andCouponIdEqualTo
(
couponId
).
andUseStatusEqualTo
(
useStatus
==
0
?
1
:
0
);
List
<
SmsCouponHistory
>
couponHistoryList
=
couponHistoryMapper
.
selectByExample
(
example
);
if
(!
CollectionUtils
.
isEmpty
(
couponHistoryList
)){
SmsCouponHistory
couponHistory
=
couponHistoryList
.
get
(
0
);
couponHistory
.
setUseTime
(
new
Date
());
couponHistory
.
setUseStatus
(
1
);
couponHistory
.
setUseStatus
(
useStatus
);
couponHistoryMapper
.
updateByPrimaryKeySelective
(
couponHistory
);
}
}
...
...
mall-portal/src/main/java/com/macro/mall/portal/service/impl/RedisServiceImpl.java
View file @
cbdb93ee
...
...
@@ -35,4 +35,9 @@ public class RedisServiceImpl implements RedisService {
public
void
remove
(
String
key
)
{
stringRedisTemplate
.
delete
(
key
);
}
@Override
public
Long
increment
(
String
key
,
long
delta
)
{
return
stringRedisTemplate
.
opsForValue
().
increment
(
key
,
delta
);
}
}
mall-portal/src/main/java/com/macro/mall/portal/service/impl/UmsMemberCouponServiceImpl.java
View file @
cbdb93ee
...
...
@@ -13,9 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.stereotype.Service
;
import
java.math.BigDecimal
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.*
;
/**
* 会员优惠券管理Service实现类
...
...
@@ -56,7 +54,7 @@ public class UmsMemberCouponServiceImpl implements UmsMemberCouponService {
//生成领取优惠券历史
SmsCouponHistory
couponHistory
=
new
SmsCouponHistory
();
couponHistory
.
setCouponId
(
couponId
);
couponHistory
.
setCouponCode
(
coupon
.
getCode
(
));
couponHistory
.
setCouponCode
(
generateCouponCode
(
currentMember
.
getId
()
));
couponHistory
.
setCreateTime
(
now
);
couponHistory
.
setMemberId
(
currentMember
.
getId
());
couponHistory
.
setMemberNickname
(
currentMember
.
getNickname
());
...
...
@@ -72,6 +70,26 @@ public class UmsMemberCouponServiceImpl implements UmsMemberCouponService {
return
new
CommonResult
().
success
(
"领取成功"
,
null
);
}
/**
* 16位优惠码生成:时间戳后8位+4位随机数+用户id后4位
*/
private
String
generateCouponCode
(
Long
memberId
)
{
StringBuilder
sb
=
new
StringBuilder
();
Long
currentTimeMillis
=
System
.
currentTimeMillis
();
String
timeMillisStr
=
currentTimeMillis
.
toString
();
sb
.
append
(
timeMillisStr
.
substring
(
timeMillisStr
.
length
()
-
8
));
for
(
int
i
=
0
;
i
<
4
;
i
++)
{
sb
.
append
(
new
Random
().
nextInt
(
10
));
}
String
memberIdStr
=
memberId
.
toString
();
if
(
memberIdStr
.
length
()
<=
4
)
{
sb
.
append
(
String
.
format
(
"%04d"
,
memberId
));
}
else
{
sb
.
append
(
memberIdStr
.
substring
(
memberIdStr
.
length
()-
4
));
}
return
sb
.
toString
();
}
@Override
public
List
<
SmsCouponHistory
>
list
(
Integer
useStatus
)
{
UmsMember
currentMember
=
memberService
.
getCurrentMember
();
...
...
mall-portal/src/main/java/com/macro/mall/portal/service/impl/UmsMemberServiceImpl.java
View file @
cbdb93ee
...
...
@@ -54,6 +54,11 @@ public class UmsMemberServiceImpl implements UmsMemberService {
return
null
;
}
@Override
public
UmsMember
getById
(
Long
id
)
{
return
memberMapper
.
selectByPrimaryKey
(
id
);
}
@Override
public
CommonResult
register
(
String
username
,
String
password
,
String
telephone
,
String
authCode
)
{
//验证验证码
...
...
@@ -125,6 +130,15 @@ public class UmsMemberServiceImpl implements UmsMemberService {
MemberDetails
memberDetails
=
(
MemberDetails
)
auth
.
getPrincipal
();
return
memberDetails
.
getUmsMember
();
}
@Override
public
void
updateIntegration
(
Long
id
,
Integer
integration
)
{
UmsMember
record
=
new
UmsMember
();
record
.
setId
(
id
);
record
.
setIntegration
(
integration
);
memberMapper
.
updateByPrimaryKeySelective
(
record
);
}
//对输入的验证码进行校验
private
boolean
verifyAuthCode
(
String
authCode
,
String
telephone
){
if
(
StringUtils
.
isEmpty
(
authCode
)){
...
...
mall-portal/src/main/resources/application.properties
View file @
cbdb93ee
...
...
@@ -11,6 +11,7 @@ mybatis.mapper-locations=classpath:dao/*.xml,classpath*:com/**/mapper/*.xml
#===redis custom key start===
redis.key.prefix.authCode
=
portal:authCode:
redis.key.prefix.orderId
=
portal:orderId:
authCode.expire.seconds
=
90
#===redis custom key end===
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment