Commit 52848d6341f4692ec57cafa49986497be9daad36
Merge remote-tracking branch 'yudao/feature/mall_product' into feature/mall_product
# Conflicts: # yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java # yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityService.java
Showing
56 changed files
with
989 additions
and
411 deletions
sql/mysql/brokerage.sql
| ... | ... | @@ -2,41 +2,50 @@ |
| 2 | 2 | create table trade_config |
| 3 | 3 | ( |
| 4 | 4 | id bigint auto_increment comment '自增主键' primary key, |
| 5 | - brokerage_enabled bit default 1 not null comment '是å¦å¯ç”¨åˆ†ä½£', | |
| 6 | - brokerage_enabled_condition tinyint default 0 not null comment '分佣模å¼ï¼š1-人人分销 2-指定分销', | |
| 7 | - brokerage_bind_mode tinyint default 0 not null comment '分销关系绑定模å¼: 1-没有推广人,2-新用户, 3-扫ç 覆盖', | |
| 8 | - brokerage_post_urls varchar(2000) default '' null comment 'åˆ†é”€æµ·æŠ¥å›¾åœ°å€æ•°ç»„', | |
| 9 | - brokerage_first_percent int default 0 not null comment '一级返佣比例', | |
| 10 | - brokerage_second_percent int default 0 not null comment '二级返佣比例', | |
| 11 | - brokerage_withdraw_min_price int default 0 not null comment '用户æçŽ°æœ€ä½Žé‡‘é¢', | |
| 12 | - brokerage_bank_names varchar(200) default '' not null comment 'æçŽ°é“¶è¡Œï¼ˆå—典类型=brokerage_bank_name)', | |
| 13 | - brokerage_frozen_days int default 7 not null comment '佣金冻结时间(天)', | |
| 14 | - brokerage_withdraw_type varchar(32) default '1,2,3,4' not null comment 'æçŽ°æ–¹å¼ï¼š1-钱包;2-银行å¡ï¼›3-微信;4-支付å®', | |
| 15 | - creator varchar(64) collate utf8mb4_unicode_ci default '' null comment '创建者', | |
| 16 | - create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间', | |
| 17 | - updater varchar(64) collate utf8mb4_unicode_ci default '' null comment '更新者', | |
| 18 | - update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment 'æ›´æ–°æ—¶é—´', | |
| 19 | - deleted bit default b'0' not null comment '是å¦åˆ 除', | |
| 20 | - tenant_id bigint default 0 not null comment '租户编å·' | |
| 5 | + brokerage_enabled bit default 1 not null comment '是å¦å¯ç”¨åˆ†ä½£', | |
| 6 | + brokerage_enabled_condition tinyint default 0 not null comment '分佣模å¼ï¼š1-人人分销 2-指定分销', | |
| 7 | + brokerage_bind_mode tinyint default 0 not null comment '分销关系绑定模å¼: 1-没有推广人,2-新用户, 3-扫ç 覆盖', | |
| 8 | + brokerage_post_urls varchar(2000) default '' null comment 'åˆ†é”€æµ·æŠ¥å›¾åœ°å€æ•°ç»„', | |
| 9 | + brokerage_first_percent int default 0 not null comment '一级返佣比例', | |
| 10 | + brokerage_second_percent int default 0 not null comment '二级返佣比例', | |
| 11 | + brokerage_withdraw_min_price int default 0 not null comment '用户æçŽ°æœ€ä½Žé‡‘é¢', | |
| 12 | + brokerage_bank_names varchar(200) default '' not null comment 'æçŽ°é“¶è¡Œï¼ˆå—典类型=brokerage_bank_name)', | |
| 13 | + brokerage_frozen_days int default 7 not null comment '佣金冻结时间(天)', | |
| 14 | + brokerage_withdraw_type varchar(32) default '1,2,3,4' not null comment 'æçŽ°æ–¹å¼ï¼š1-钱包;2-银行å¡ï¼›3-微信;4-支付å®', | |
| 15 | + creator varchar(64) default '' null comment '创建者', | |
| 16 | + create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间', | |
| 17 | + updater varchar(64) default '' null comment '更新者', | |
| 18 | + update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment 'æ›´æ–°æ—¶é—´', | |
| 19 | + deleted bit default b'0' not null comment '是å¦åˆ 除', | |
| 20 | + tenant_id bigint default 0 not null comment '租户编å·' | |
| 21 | 21 | ) comment '交易ä¸å¿ƒé…ç½®'; |
| 22 | 22 | |
| 23 | +# alter table trade_brokerage_user | |
| 24 | +# add level int not null default 1 comment 'ç‰çº§' after frozen_price; | |
| 25 | +# alter table trade_brokerage_user | |
| 26 | +# add path varchar(2000) null comment '路径' after level; | |
| 27 | + | |
| 28 | + | |
| 23 | 29 | -- å¢žåŠ åˆ†é”€ç”¨æˆ·æ‰©å±•è¡¨ |
| 24 | 30 | create table trade_brokerage_user |
| 25 | 31 | ( |
| 26 | 32 | id bigint auto_increment comment '用户编å·' primary key, |
| 27 | - bind_user_id bigint null comment '推广员编å·', | |
| 28 | - bind_user_time datetime null comment '推广员绑定时间', | |
| 29 | - brokerage_enabled bit default 1 not null comment 'æ˜¯å¦æˆä¸ºæŽ¨å¹¿å‘˜', | |
| 30 | - brokerage_time datetime null comment 'æˆä¸ºåˆ†é”€å‘˜æ—¶é—´', | |
| 31 | - price int default 0 not null comment 'å¯ç”¨ä½£é‡‘', | |
| 32 | - frozen_price int default 0 not null comment '冻结佣金', | |
| 33 | - creator varchar(64) collate utf8mb4_unicode_ci default '' null comment '创建者', | |
| 34 | - create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间', | |
| 35 | - updater varchar(64) collate utf8mb4_unicode_ci default '' null comment '更新者', | |
| 36 | - update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment 'æ›´æ–°æ—¶é—´', | |
| 37 | - deleted bit default b'0' not null comment '是å¦åˆ 除', | |
| 38 | - tenant_id bigint default 0 not null comment '租户编å·' | |
| 39 | -) comment '分销用户'; | |
| 33 | + bind_user_id bigint null comment '推广员编å·', | |
| 34 | + bind_user_time datetime null comment '推广员绑定时间', | |
| 35 | + brokerage_enabled bit default 1 not null comment 'æ˜¯å¦æˆä¸ºæŽ¨å¹¿å‘˜', | |
| 36 | + brokerage_time datetime null comment 'æˆä¸ºåˆ†é”€å‘˜æ—¶é—´', | |
| 37 | + price int default 0 not null comment 'å¯ç”¨ä½£é‡‘', | |
| 38 | + frozen_price int default 0 not null comment '冻结佣金', | |
| 39 | + level int default 1 not null comment 'ç‰çº§', | |
| 40 | + path varchar(2000) null comment '路径', | |
| 41 | + creator varchar(64) default '' null comment '创建者', | |
| 42 | + create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间', | |
| 43 | + updater varchar(64) default '' null comment '更新者', | |
| 44 | + update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment 'æ›´æ–°æ—¶é—´', | |
| 45 | + deleted bit default b'0' not null comment '是å¦åˆ 除', | |
| 46 | + tenant_id bigint default 0 not null comment '租户编å·' | |
| 47 | +) | |
| 48 | + comment '分销用户'; | |
| 40 | 49 | |
| 41 | 50 | create index idx_invite_user_id on trade_brokerage_user (bind_user_id) comment '推广员编å·'; |
| 42 | 51 | create index idx_agent on trade_brokerage_user (brokerage_enabled) comment 'æ˜¯å¦æˆä¸ºæŽ¨å¹¿å‘˜'; |
| ... | ... | @@ -44,26 +53,26 @@ create index idx_agent on trade_brokerage_user (brokerage_enabled) comment '是å |
| 44 | 53 | |
| 45 | 54 | create table trade_brokerage_record |
| 46 | 55 | ( |
| 47 | - id int auto_increment comment 'ç¼–å·' | |
| 56 | + id int auto_increment comment 'ç¼–å·' | |
| 48 | 57 | primary key, |
| 49 | - user_id bigint not null comment '用户编å·', | |
| 50 | - biz_id varchar(64) default '' not null comment '业务编å·', | |
| 51 | - biz_type tinyint default 0 not null comment '业务类型:1-订å•,2-æçް', | |
| 52 | - title varchar(64) default '' not null comment 'æ ‡é¢˜', | |
| 53 | - price int default 0 not null comment '金é¢', | |
| 54 | - total_price int default 0 not null comment '当剿€»ä½£é‡‘', | |
| 55 | - description varchar(500) default '' not null comment '说明', | |
| 56 | - status tinyint default 0 not null comment '状æ€ï¼š0-待结算,1-已结算,2-已喿¶ˆ', | |
| 57 | - frozen_days int default 0 not null comment '冻结时间(天)', | |
| 58 | - unfreeze_time datetime null comment '解冻时间', | |
| 59 | - source_user_type tinyint not null comment 'æ¥æºç”¨æˆ·ç±»åž‹ï¼š1-一级推广用户,2-二级推广用户', | |
| 60 | - source_user_id bigint not null comment 'æ¥æºç”¨æˆ·ç¼–å·', | |
| 61 | - creator varchar(64) collate utf8mb4_general_ci default '' null comment '创建者', | |
| 62 | - create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间', | |
| 63 | - updater varchar(64) collate utf8mb4_general_ci default '' null comment '更新者', | |
| 64 | - update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment 'æ›´æ–°æ—¶é—´', | |
| 65 | - deleted bit default b'0' not null comment '是å¦åˆ 除', | |
| 66 | - tenant_id bigint default 0 not null comment '租户编å·' | |
| 58 | + user_id bigint not null comment '用户编å·', | |
| 59 | + biz_id varchar(64) default '' not null comment '业务编å·', | |
| 60 | + biz_type tinyint default 0 not null comment '业务类型:1-订å•,2-æçް', | |
| 61 | + title varchar(64) default '' not null comment 'æ ‡é¢˜', | |
| 62 | + price int default 0 not null comment '金é¢', | |
| 63 | + total_price int default 0 not null comment '当剿€»ä½£é‡‘', | |
| 64 | + description varchar(500) default '' not null comment '说明', | |
| 65 | + status tinyint default 0 not null comment '状æ€ï¼š0-待结算,1-已结算,2-已喿¶ˆ', | |
| 66 | + frozen_days int default 0 not null comment '冻结时间(天)', | |
| 67 | + unfreeze_time datetime null comment '解冻时间', | |
| 68 | + source_user_level int not null comment 'æ¥æºç”¨æˆ·ç‰çº§', | |
| 69 | + source_user_id bigint not null comment 'æ¥æºç”¨æˆ·ç¼–å·', | |
| 70 | + creator varchar(64) default '' null comment '创建者', | |
| 71 | + create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间', | |
| 72 | + updater varchar(64) default '' null comment '更新者', | |
| 73 | + update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment 'æ›´æ–°æ—¶é—´', | |
| 74 | + deleted bit default b'0' not null comment '是å¦åˆ 除', | |
| 75 | + tenant_id bigint default 0 not null comment '租户编å·' | |
| 67 | 76 | ) |
| 68 | 77 | comment '佣金记录'; |
| 69 | 78 | |
| ... | ... | @@ -76,26 +85,26 @@ create table trade_brokerage_withdraw |
| 76 | 85 | ( |
| 77 | 86 | id int auto_increment comment 'ç¼–å·' |
| 78 | 87 | primary key, |
| 79 | - user_id bigint not null comment '用户编å·', | |
| 80 | - price int default 0 not null comment 'æçް金é¢', | |
| 81 | - fee_price int default 0 not null comment 'æçŽ°æ‰‹ç»è´¹', | |
| 82 | - total_price int default 0 not null comment '当剿€»ä½£é‡‘', | |
| 83 | - type tinyint default 0 not null comment 'æçŽ°ç±»åž‹ï¼š1-钱包;2-银行å¡ï¼›3-微信;4-支付å®', | |
| 84 | - name varchar(64) null comment '真实姓å', | |
| 85 | - account_no varchar(64) null comment 'è´¦å·', | |
| 86 | - bank_name varchar(100) null comment '银行åç§°', | |
| 87 | - bank_address varchar(200) null comment '开户地å€', | |
| 88 | - account_qr_code_url varchar(512) null comment '收款ç ', | |
| 89 | - status tinyint(2) default 0 not null comment '状æ€ï¼š0-å®¡æ ¸ä¸ï¼Œ10-å®¡æ ¸é€šè¿‡ 20-å®¡æ ¸ä¸é€šè¿‡ï¼›é¢„留:11 - æçްæˆåŠŸï¼›21-æçŽ°å¤±è´¥', | |
| 90 | - audit_reason varchar(128) null comment 'å®¡æ ¸é©³å›žåŽŸå› ', | |
| 91 | - audit_time datetime null comment 'å®¡æ ¸æ—¶é—´', | |
| 92 | - remark varchar(500) null comment '备注', | |
| 93 | - creator varchar(64) collate utf8mb4_general_ci default '' null comment '创建者', | |
| 94 | - create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间', | |
| 95 | - updater varchar(64) collate utf8mb4_general_ci default '' null comment '更新者', | |
| 96 | - update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment 'æ›´æ–°æ—¶é—´', | |
| 97 | - deleted bit default b'0' not null comment '是å¦åˆ 除', | |
| 98 | - tenant_id bigint default 0 not null comment '租户编å·' | |
| 88 | + user_id bigint not null comment '用户编å·', | |
| 89 | + price int default 0 not null comment 'æçް金é¢', | |
| 90 | + fee_price int default 0 not null comment 'æçŽ°æ‰‹ç»è´¹', | |
| 91 | + total_price int default 0 not null comment '当剿€»ä½£é‡‘', | |
| 92 | + type tinyint default 0 not null comment 'æçŽ°ç±»åž‹ï¼š1-钱包;2-银行å¡ï¼›3-微信;4-支付å®', | |
| 93 | + name varchar(64) null comment '真实姓å', | |
| 94 | + account_no varchar(64) null comment 'è´¦å·', | |
| 95 | + bank_name varchar(100) null comment '银行åç§°', | |
| 96 | + bank_address varchar(200) null comment '开户地å€', | |
| 97 | + account_qr_code_url varchar(512) null comment '收款ç ', | |
| 98 | + status tinyint(2) default 0 not null comment '状æ€ï¼š0-å®¡æ ¸ä¸ï¼Œ10-å®¡æ ¸é€šè¿‡ 20-å®¡æ ¸ä¸é€šè¿‡ï¼›é¢„留:11 - æçްæˆåŠŸï¼›21-æçŽ°å¤±è´¥', | |
| 99 | + audit_reason varchar(128) null comment 'å®¡æ ¸é©³å›žåŽŸå› ', | |
| 100 | + audit_time datetime null comment 'å®¡æ ¸æ—¶é—´', | |
| 101 | + remark varchar(500) null comment '备注', | |
| 102 | + creator varchar(64) default '' null comment '创建者', | |
| 103 | + create_time datetime default CURRENT_TIMESTAMP not null comment '创建时间', | |
| 104 | + updater varchar(64) default '' null comment '更新者', | |
| 105 | + update_time datetime default CURRENT_TIMESTAMP not null on update CURRENT_TIMESTAMP comment 'æ›´æ–°æ—¶é—´', | |
| 106 | + deleted bit default b'0' not null comment '是å¦åˆ 除', | |
| 107 | + tenant_id bigint default 0 not null comment '租户编å·' | |
| 99 | 108 | ) |
| 100 | 109 | comment '佣金æçް'; |
| 101 | 110 | |
| ... | ... | @@ -139,12 +148,12 @@ values ('brokerage_record_status', '待结算', 0, 0), |
| 139 | 148 | |
| 140 | 149 | insert into system_dict_type(type, name) |
| 141 | 150 | values ('brokerage_withdraw_status', '佣金æçŽ°çŠ¶æ€'); |
| 142 | -insert into system_dict_data(dict_type, label, value, sort) | |
| 143 | -values ('brokerage_withdraw_status', 'å®¡æ ¸ä¸', 0, 0), | |
| 144 | - ('brokerage_withdraw_status', 'å®¡æ ¸é€šè¿‡', 10, 10), | |
| 145 | - ('brokerage_withdraw_status', 'æçްæˆåŠŸ', 11, 11), | |
| 146 | - ('brokerage_withdraw_status', 'å®¡æ ¸ä¸é€šè¿‡', 20, 20), | |
| 147 | - ('brokerage_withdraw_status', 'æçŽ°å¤±è´¥', 21, 21); | |
| 151 | +insert into system_dict_data(dict_type, label, value, sort, color_type) | |
| 152 | +values ('brokerage_withdraw_status', 'å®¡æ ¸ä¸', 0, 0, ''), | |
| 153 | + ('brokerage_withdraw_status', 'å®¡æ ¸é€šè¿‡', 10, 10, 'success'), | |
| 154 | + ('brokerage_withdraw_status', 'æçްæˆåŠŸ', 11, 11, 'success'), | |
| 155 | + ('brokerage_withdraw_status', 'å®¡æ ¸ä¸é€šè¿‡', 20, 20, 'danger'), | |
| 156 | + ('brokerage_withdraw_status', 'æçŽ°å¤±è´¥', 21, 21, 'danger'); | |
| 148 | 157 | |
| 149 | 158 | insert into system_dict_type(type, name) |
| 150 | 159 | values ('brokerage_bank_name', '佣金æçŽ°é“¶è¡Œ'); |
| ... | ... | @@ -220,4 +229,10 @@ SELECT @parentId := LAST_INSERT_ID(); |
| 220 | 229 | INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) |
| 221 | 230 | VALUES ('佣金æçŽ°æŸ¥è¯¢', 'trade:brokerage-withdraw:query', 3, 1, @parentId, '', '', '', 0); |
| 222 | 231 | INSERT INTO system_menu(name, permission, type, sort, parent_id, path, icon, component, status) |
| 223 | -VALUES ('佣金æçŽ°å®¡æ ¸', 'trade:brokerage-withdraw:audit', 3, 2, @parentId, '', '', '', 0); | |
| 224 | 232 | \ No newline at end of file |
| 233 | +VALUES ('佣金æçŽ°å®¡æ ¸', 'trade:brokerage-withdraw:audit', 3, 2, @parentId, '', '', '', 0); | |
| 234 | + | |
| 235 | +-- ç«™å†…ä¿¡æ¨¡æ¿ | |
| 236 | +INSERT INTO `ruoyi-vue-pro`.system_notify_template (name, code, nickname, content, type, params, status) | |
| 237 | +VALUES | |
| 238 | + ('佣金æçŽ°ï¼ˆå®¡æ ¸é€šè¿‡ï¼‰', 'brokerage_withdraw_audit_approve', 'system', '您在{createTime}æçŽ°ï¿¥{price}å…ƒçš„ç”³è¯·å·²é€šè¿‡å®¡æ ¸', 2, '["createTime","price"]', 0), | |
| 239 | + ('佣金æçŽ°ï¼ˆå®¡æ ¸ä¸é€šè¿‡ï¼‰', 'brokerage_withdraw_audit_reject', 'system', '您在{createTime}æçŽ°ï¿¥{price}å…ƒçš„ç”³è¯·æœªé€šè¿‡å®¡æ ¸ï¼ŒåŽŸå› ï¼š{reason}', 2, '["createTime","price","reason"]', 0); | ... | ... |
yudao-framework/yudao-common/src/main/java/cn/iocoder/yudao/framework/common/util/date/LocalDateTimeUtils.java
| ... | ... | @@ -50,6 +50,7 @@ public class LocalDateTimeUtils { |
| 50 | 50 | * @return 指定时间 |
| 51 | 51 | */ |
| 52 | 52 | public static LocalDateTime buildTime(String timeStr) { |
| 53 | + // TODO @puhui999:这个方法的实现,和 LocalDateTimeUtil.parse() 的差异点是啥呀 | |
| 53 | 54 | return LocalDateTime.of(LocalDate.now(), LocalTime.parse(timeStr)); |
| 54 | 55 | } |
| 55 | 56 | ... | ... |
yudao-framework/yudao-spring-boot-starter-mybatis/src/main/java/cn/iocoder/yudao/framework/mybatis/core/query/LambdaQueryWrapperX.java
| ... | ... | @@ -100,6 +100,14 @@ public class LambdaQueryWrapperX<T> extends LambdaQueryWrapper<T> { |
| 100 | 100 | return betweenIfPresent(column, val1, val2); |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | + // TODO @疯狂:这个是 mysql 独有的,不好做成通用的哈。如果多层级,有没可能先查询一个层级,再查询一个层级;形成 set 后,直接去 in? | |
| 104 | + public LambdaQueryWrapperX<T> findInSetIfPresent(SFunction<T, ?> column, Object val) { | |
| 105 | + if (val != null) { | |
| 106 | + return (LambdaQueryWrapperX<T>) super.apply("FIND_IN_SET({0}, " + columnToString(column) + ")", val); | |
| 107 | + } | |
| 108 | + return this; | |
| 109 | + } | |
| 110 | + | |
| 103 | 111 | // ========== 重写父类方法,方便链式调用 ========== |
| 104 | 112 | |
| 105 | 113 | @Override | ... | ... |
yudao-module-infra/yudao-module-infra-biz/src/main/resources/codegen/java/service/serviceImpl.vm
| ... | ... | @@ -64,14 +64,14 @@ public class ${table.className}ServiceImpl implements ${table.className}Service |
| 64 | 64 | |
| 65 | 65 | @Override |
| 66 | 66 | public ${table.className}DO get${simpleClassName}(${primaryColumn.javaType} id) { |
| 67 | - if (CollUtil.isEmpty(ids)) { | |
| 68 | - return ListUtil.empty(); | |
| 69 | - } | |
| 70 | 67 | return ${classNameVar}Mapper.selectById(id); |
| 71 | 68 | } |
| 72 | 69 | |
| 73 | 70 | @Override |
| 74 | 71 | public List<${table.className}DO> get${simpleClassName}List(Collection<${primaryColumn.javaType}> ids) { |
| 72 | + if (CollUtil.isEmpty(ids)) { | |
| 73 | + return ListUtil.empty(); | |
| 74 | + } | |
| 75 | 75 | return ${classNameVar}Mapper.selectBatchIds(ids); |
| 76 | 76 | } |
| 77 | 77 | ... | ... |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationRecordApi.java
| ... | ... | @@ -31,7 +31,7 @@ public interface CombinationRecordApi { |
| 31 | 31 | boolean isCombinationRecordSuccess(Long userId, Long orderId); |
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | - * 更新拼团状态为 成功 | |
| 34 | + * 更新拼团状态为【成功】 | |
| 35 | 35 | * |
| 36 | 36 | * @param userId 用户编号 |
| 37 | 37 | * @param orderId 订单编号 |
| ... | ... | @@ -39,7 +39,7 @@ public interface CombinationRecordApi { |
| 39 | 39 | void updateRecordStatusToSuccess(Long userId, Long orderId); |
| 40 | 40 | |
| 41 | 41 | /** |
| 42 | - * 更新拼团状态为 失败 | |
| 42 | + * 更新拼团状态为【失败】 | |
| 43 | 43 | * |
| 44 | 44 | * @param userId 用户编号 |
| 45 | 45 | * @param orderId 订单编号 | ... | ... |
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/api/seckill/SeckillActivityApi.java
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/admin/bargain/BargainActivityController.java
| ... | ... | @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.promotion.controller.admin.bargain; |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | |
| 7 | 6 | import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; |
| 8 | 7 | import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; |
| 9 | 8 | import cn.iocoder.yudao.module.promotion.controller.admin.bargain.vo.BargainActivityCreateReqVO; |
| ... | ... | @@ -25,6 +24,7 @@ import javax.validation.Valid; |
| 25 | 24 | import java.util.List; |
| 26 | 25 | |
| 27 | 26 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 27 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | |
| 28 | 28 | |
| 29 | 29 | @Tag(name = "管理后台 - 砍价活动") |
| 30 | 30 | @RestController |
| ... | ... | @@ -79,7 +79,9 @@ public class BargainActivityController { |
| 79 | 79 | if (CollUtil.isEmpty(pageResult.getList())) { |
| 80 | 80 | return success(PageResult.empty(pageResult.getTotal())); |
| 81 | 81 | } |
| 82 | - List<ProductSpuRespDTO> spuList = spuApi.getSpuList(CollectionUtils.convertList(pageResult.getList(), BargainActivityDO::getSpuId)); | |
| 82 | + | |
| 83 | + // 拼接数据 | |
| 84 | + List<ProductSpuRespDTO> spuList = spuApi.getSpuList(convertList(pageResult.getList(), BargainActivityDO::getSpuId)); | |
| 83 | 85 | return success(BargainActivityConvert.INSTANCE.convertPage(pageResult, spuList)); |
| 84 | 86 | } |
| 85 | 87 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/bargain/AppBargainActivityController.java
| ... | ... | @@ -4,7 +4,6 @@ import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 5 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 6 | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | -import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; | |
| 8 | 7 | import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi; |
| 9 | 8 | import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO; |
| 10 | 9 | import cn.iocoder.yudao.module.promotion.controller.app.bargain.vo.activity.AppBargainActivityDetailRespVO; |
| ... | ... | @@ -25,6 +24,7 @@ import javax.annotation.Resource; |
| 25 | 24 | import java.util.List; |
| 26 | 25 | |
| 27 | 26 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 27 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; | |
| 28 | 28 | |
| 29 | 29 | @Tag(name = "用户 App - 砍价活动") |
| 30 | 30 | @RestController |
| ... | ... | @@ -39,27 +39,27 @@ public class AppBargainActivityController { |
| 39 | 39 | @GetMapping("/page") |
| 40 | 40 | @Operation(summary = "获得砍价活动分页") |
| 41 | 41 | public CommonResult<PageResult<AppBargainActivityRespVO>> getBargainActivityPage(PageParam pageReqVO) { |
| 42 | - PageResult<BargainActivityDO> result = bargainActivityService.getBargainActivityAppPage(pageReqVO); | |
| 42 | + PageResult<BargainActivityDO> result = bargainActivityService.getBargainActivityPageForApp(pageReqVO); | |
| 43 | 43 | if (CollUtil.isEmpty(result.getList())) { |
| 44 | 44 | return success(PageResult.empty(result.getTotal())); |
| 45 | 45 | } |
| 46 | - | |
| 47 | - List<ProductSpuRespDTO> spuList = spuApi.getSpuList(CollectionUtils.convertList(result.getList(), BargainActivityDO::getSpuId)); | |
| 46 | + // 拼接数据 | |
| 47 | + List<ProductSpuRespDTO> spuList = spuApi.getSpuList(convertList(result.getList(), BargainActivityDO::getSpuId)); | |
| 48 | 48 | return success(BargainActivityConvert.INSTANCE.convertAppPage(result, spuList)); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | + // TODO 芋艿:增加 Spring Cache | |
| 51 | 52 | @GetMapping("/list") |
| 52 | 53 | @Operation(summary = "获得砍价活动列表", description = "用于小程序首页") |
| 53 | 54 | @Parameter(name = "count", description = "需要展示的数量", example = "6") |
| 54 | 55 | public CommonResult<List<AppBargainActivityRespVO>> getBargainActivityList( |
| 55 | 56 | @RequestParam(name = "count", defaultValue = "6") Integer count) { |
| 56 | - List<BargainActivityDO> list = bargainActivityService.getBargainActivityAppList(count); | |
| 57 | + List<BargainActivityDO> list = bargainActivityService.getBargainActivityListForApp(count); | |
| 57 | 58 | if (CollUtil.isEmpty(list)) { |
| 58 | 59 | return success(BargainActivityConvert.INSTANCE.convertAppList(list)); |
| 59 | 60 | } |
| 60 | - | |
| 61 | - List<ProductSpuRespDTO> spuList = spuApi.getSpuList(CollectionUtils.convertList(list, BargainActivityDO::getSpuId)); | |
| 62 | - // TODO 芋艿:增加 Spring Cache | |
| 61 | + // 拼接数据 | |
| 62 | + List<ProductSpuRespDTO> spuList = spuApi.getSpuList(convertList(list, BargainActivityDO::getSpuId)); | |
| 63 | 63 | return success(BargainActivityConvert.INSTANCE.convertAppList(list, spuList)); |
| 64 | 64 | } |
| 65 | 65 | |
| ... | ... | @@ -71,9 +71,9 @@ public class AppBargainActivityController { |
| 71 | 71 | if (activity == null) { |
| 72 | 72 | return success(null); |
| 73 | 73 | } |
| 74 | - | |
| 74 | + // 拼接数据 | |
| 75 | 75 | ProductSpuRespDTO spu = spuApi.getSpu(activity.getSpuId()); |
| 76 | - return success(BargainActivityConvert.INSTANCE.convert1(activity, spu)); | |
| 76 | + return success(BargainActivityConvert.INSTANCE.convert(activity, spu)); | |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillActivityController.java
| ... | ... | @@ -53,19 +53,20 @@ public class AppSeckillActivityController { |
| 53 | 53 | @GetMapping("/get-now") |
| 54 | 54 | @Operation(summary = "获得当前秒杀活动", description = "获取当前正在进行的活动,提供给首页使用") |
| 55 | 55 | public CommonResult<AppSeckillActivityNowRespVO> getNowSeckillActivity() { |
| 56 | - // 1、获取当前时间处在哪个秒杀阶段 | |
| 56 | + // 1. 获取当前时间处在哪个秒杀阶段 | |
| 57 | + // TODO @puhui999:可以考虑在 service 写个方法;这样 controller 不用关注过多逻辑 | |
| 57 | 58 | List<SeckillConfigDO> configList = configService.getSeckillConfigList(); |
| 58 | 59 | SeckillConfigDO filteredConfig = findFirst(configList, config -> ObjectUtil.equal(config.getStatus(), |
| 59 | 60 | CommonStatusEnum.ENABLE.getStatus()) && isBetween(config.getStartTime(), config.getEndTime())); |
| 60 | - // 1、1 时段不存在直接返回 null | |
| 61 | - if (filteredConfig == null) { | |
| 61 | + if (filteredConfig == null) { // 时段不存在直接返回 null | |
| 62 | 62 | return success(null); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - // 2、查询满足当前阶段的活动 | |
| 65 | + // 2. 查询满足当前阶段的活动 | |
| 66 | + // TODO @puhui999:最好直接返回开启的;不多查询数据 | |
| 66 | 67 | List<SeckillActivityDO> activityList = activityService.getSeckillActivityListByConfigIds(Arrays.asList(filteredConfig.getId())); |
| 67 | 68 | List<SeckillActivityDO> filteredList = filterList(activityList, item -> ObjectUtil.equal(item.getStatus(), CommonStatusEnum.ENABLE.getStatus())); |
| 68 | - // 2、1 获取 spu 信息 | |
| 69 | + // 3 获取 spu 信息 | |
| 69 | 70 | List<ProductSpuRespDTO> spuList = spuApi.getSpuList(convertList(filteredList, SeckillActivityDO::getSpuId)); |
| 70 | 71 | // TODO 芋艿:需要增加 spring cache |
| 71 | 72 | return success(SeckillActivityConvert.INSTANCE.convert(filteredConfig, filteredList, spuList)); |
| ... | ... | @@ -74,9 +75,10 @@ public class AppSeckillActivityController { |
| 74 | 75 | @GetMapping("/page") |
| 75 | 76 | @Operation(summary = "获得秒杀活动分页") |
| 76 | 77 | public CommonResult<PageResult<AppSeckillActivityRespVO>> getSeckillActivityPage(AppSeckillActivityPageReqVO pageReqVO) { |
| 77 | - // 1、查询满足当前阶段的活动 | |
| 78 | + // 1. 查询满足当前阶段的活动 | |
| 78 | 79 | PageResult<SeckillActivityDO> pageResult = activityService.getSeckillActivityAppPageByConfigId(pageReqVO); |
| 79 | - // 1、1 获取 spu 信息 | |
| 80 | + | |
| 81 | + // 2. 拼接数据 | |
| 80 | 82 | List<ProductSpuRespDTO> spuList = spuApi.getSpuList(convertList(pageResult.getList(), SeckillActivityDO::getSpuId)); |
| 81 | 83 | return success(SeckillActivityConvert.INSTANCE.convertPage(pageResult, spuList)); |
| 82 | 84 | } |
| ... | ... | @@ -86,15 +88,15 @@ public class AppSeckillActivityController { |
| 86 | 88 | @Parameter(name = "id", description = "活动编号", required = true, example = "1024") |
| 87 | 89 | public CommonResult<AppSeckillActivityDetailRespVO> getSeckillActivity(@RequestParam("id") Long id) { |
| 88 | 90 | // 1、获取当前时间处在哪个秒杀阶段 |
| 91 | + // TODO puhui999:这里,和 58 行是雷同的 | |
| 89 | 92 | List<SeckillConfigDO> configList = configService.getSeckillConfigList(); |
| 90 | 93 | SeckillConfigDO filteredConfig = findFirst(configList, config -> ObjectUtil.equal(config.getStatus(), |
| 91 | 94 | CommonStatusEnum.ENABLE.getStatus()) && isBetween(config.getStartTime(), config.getEndTime())); |
| 92 | - // 1、1 时段不存在直接返回 null | |
| 93 | - if (filteredConfig == null) { | |
| 95 | + if (filteredConfig == null) { // 时段不存在直接返回 null | |
| 94 | 96 | return success(null); |
| 95 | 97 | } |
| 96 | 98 | |
| 97 | - // 2、获取活动 | |
| 99 | + // 2. 获取活动 | |
| 98 | 100 | SeckillActivityDO seckillActivity = activityService.getSeckillActivity(id); |
| 99 | 101 | if (seckillActivity == null) { |
| 100 | 102 | return success(null); |
| ... | ... | @@ -103,7 +105,7 @@ public class AppSeckillActivityController { |
| 103 | 105 | throw exception(SECKILL_ACTIVITY_APP_STATUS_CLOSED); |
| 104 | 106 | } |
| 105 | 107 | |
| 106 | - // 3、获取活动商品 | |
| 108 | + // 3. 拼接数据 | |
| 107 | 109 | List<SeckillProductDO> products = activityService.getSeckillProductListByActivityId(seckillActivity.getId()); |
| 108 | 110 | return success(SeckillActivityConvert.INSTANCE.convert3(seckillActivity, products, filteredConfig)); |
| 109 | 111 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/controller/app/seckill/AppSeckillConfigController.java
| ... | ... | @@ -32,19 +32,12 @@ public class AppSeckillConfigController { |
| 32 | 32 | @Operation(summary = "获得秒杀时间段列表") |
| 33 | 33 | public CommonResult<List<AppSeckillConfigRespVO>> getSeckillConfigList() { |
| 34 | 34 | List<SeckillConfigDO> list = configService.getSeckillConfigListByStatus(CommonStatusEnum.ENABLE.getStatus()); |
| 35 | + // TODO @puhui999:如果这种,不用判空也问题不大; | |
| 35 | 36 | if (CollectionUtil.isEmpty(list)) { |
| 36 | 37 | return success(Collections.emptyList()); |
| 37 | 38 | } |
| 38 | 39 | |
| 39 | 40 | return success(SeckillConfigConvert.INSTANCE.convertList2(list)); |
| 40 | - //return success(Arrays.asList( | |
| 41 | - // new AppSeckillConfigRespVO().setId(1L).setStartTime("00:00").setEndTime("09:59") | |
| 42 | - // .setSliderPicUrls(Arrays.asList("https://static.iocoder.cn/mall/a79f5d2ea6bf0c3c11b2127332dfe2df.jpg", | |
| 43 | - // "https://static.iocoder.cn/mall/132.jpeg")), | |
| 44 | - // new AppSeckillConfigRespVO().setId(2L).setStartTime("10:00").setEndTime("12:59"), | |
| 45 | - // new AppSeckillConfigRespVO().setId(2L).setStartTime("13:00").setEndTime("22:59"), | |
| 46 | - // new AppSeckillConfigRespVO().setId(2L).setStartTime("23:00").setEndTime("23:59") | |
| 47 | - //)); | |
| 48 | 41 | } |
| 49 | 42 | |
| 50 | 43 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/bargain/BargainActivityConvert.java
| ... | ... | @@ -42,9 +42,11 @@ public interface BargainActivityConvert { |
| 42 | 42 | |
| 43 | 43 | default PageResult<BargainActivityRespVO> convertPage(PageResult<BargainActivityDO> page, List<ProductSpuRespDTO> spuList) { |
| 44 | 44 | PageResult<BargainActivityRespVO> result = convertPage(page); |
| 45 | + // 拼接关联属性 | |
| 45 | 46 | Map<Long, ProductSpuRespDTO> spuMap = convertMap(spuList, ProductSpuRespDTO::getId); |
| 46 | 47 | List<BargainActivityRespVO> list = CollectionUtils.convertList(result.getList(), item -> { |
| 47 | 48 | findAndThen(spuMap, item.getSpuId(), spu -> { |
| 49 | + // TODO @puhui999:这里可以使用链式哈 | |
| 48 | 50 | item.setPicUrl(spu.getPicUrl()); |
| 49 | 51 | item.setSpuName(spu.getName()); |
| 50 | 52 | }); |
| ... | ... | @@ -56,7 +58,7 @@ public interface BargainActivityConvert { |
| 56 | 58 | |
| 57 | 59 | AppBargainActivityDetailRespVO convert1(BargainActivityDO bean); |
| 58 | 60 | |
| 59 | - default AppBargainActivityDetailRespVO convert1(BargainActivityDO bean, ProductSpuRespDTO spu) { | |
| 61 | + default AppBargainActivityDetailRespVO convert(BargainActivityDO bean, ProductSpuRespDTO spu) { | |
| 60 | 62 | AppBargainActivityDetailRespVO detail = convert1(bean); |
| 61 | 63 | if (spu != null) { |
| 62 | 64 | detail.setPicUrl(spu.getPicUrl()); |
| ... | ... | @@ -70,9 +72,11 @@ public interface BargainActivityConvert { |
| 70 | 72 | |
| 71 | 73 | default PageResult<AppBargainActivityRespVO> convertAppPage(PageResult<BargainActivityDO> page, List<ProductSpuRespDTO> spuList) { |
| 72 | 74 | PageResult<AppBargainActivityRespVO> result = convertAppPage(page); |
| 75 | + // 拼接关联属性 | |
| 73 | 76 | Map<Long, ProductSpuRespDTO> spuMap = convertMap(spuList, ProductSpuRespDTO::getId); |
| 74 | 77 | List<AppBargainActivityRespVO> list = CollectionUtils.convertList(result.getList(), item -> { |
| 75 | 78 | findAndThen(spuMap, item.getSpuId(), spu -> { |
| 79 | + // TODO @puhui999:这里可以使用链式哈 | |
| 76 | 80 | item.setPicUrl(spu.getPicUrl()); |
| 77 | 81 | item.setMarketPrice(spu.getMarketPrice()); |
| 78 | 82 | }); |
| ... | ... | @@ -89,6 +93,7 @@ public interface BargainActivityConvert { |
| 89 | 93 | Map<Long, ProductSpuRespDTO> spuMap = convertMap(spuList, ProductSpuRespDTO::getId); |
| 90 | 94 | return CollectionUtils.convertList(activityList, item -> { |
| 91 | 95 | findAndThen(spuMap, item.getSpuId(), spu -> { |
| 96 | + // TODO @puhui999:这里可以使用链式哈 | |
| 92 | 97 | item.setPicUrl(spu.getPicUrl()); |
| 93 | 98 | item.setMarketPrice(spu.getMarketPrice()); |
| 94 | 99 | }); | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/combination/CombinationActivityConvert.java
| ... | ... | @@ -97,8 +97,10 @@ public interface CombinationActivityConvert { |
| 97 | 97 | |
| 98 | 98 | CombinationRecordDO convert(CombinationRecordCreateReqDTO reqDTO); |
| 99 | 99 | |
| 100 | - default CombinationRecordDO convert1(CombinationRecordCreateReqDTO reqDTO, CombinationActivityDO activity, MemberUserRespDTO user, | |
| 101 | - ProductSpuRespDTO spu, ProductSkuRespDTO sku) { | |
| 100 | + default CombinationRecordDO convert(CombinationRecordCreateReqDTO reqDTO, | |
| 101 | + CombinationActivityDO activity, MemberUserRespDTO user, | |
| 102 | + ProductSpuRespDTO spu, ProductSkuRespDTO sku) { | |
| 103 | + // TODO @puhui999:搞成链式的 set;这样会更规整一点; | |
| 102 | 104 | CombinationRecordDO record = convert(reqDTO); |
| 103 | 105 | record.setVirtualGroup(false); |
| 104 | 106 | record.setExpireTime(record.getStartTime().plusHours(activity.getLimitDuration())); | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/convert/seckill/seckillactivity/SeckillActivityConvert.java
| ... | ... | @@ -98,6 +98,7 @@ public interface SeckillActivityConvert { |
| 98 | 98 | Map<Long, ProductSpuRespDTO> spuMap = convertMap(spuList, ProductSpuRespDTO::getId); |
| 99 | 99 | respVO.setActivities(CollectionUtils.convertList(convertList3(activityList), item -> { |
| 100 | 100 | findAndThen(spuMap, item.getSpuId(), spu -> { |
| 101 | + // TODO @puhui999:可以尝试链式 set 哈; | |
| 101 | 102 | item.setPicUrl(spu.getPicUrl()); |
| 102 | 103 | item.setMarketPrice(spu.getMarketPrice()); |
| 103 | 104 | item.setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit())); |
| ... | ... | @@ -114,6 +115,7 @@ public interface SeckillActivityConvert { |
| 114 | 115 | Map<Long, ProductSpuRespDTO> spuMap = convertMap(spuList, ProductSpuRespDTO::getId); |
| 115 | 116 | List<AppSeckillActivityRespVO> list = CollectionUtils.convertList(result.getList(), item -> { |
| 116 | 117 | findAndThen(spuMap, item.getSpuId(), spu -> { |
| 118 | + // TODO @puhui999:可以尝试链式 set 哈; | |
| 117 | 119 | item.setPicUrl(spu.getPicUrl()); |
| 118 | 120 | item.setMarketPrice(spu.getMarketPrice()); |
| 119 | 121 | item.setUnitName(DictFrameworkUtils.getDictDataLabel(DictTypeConstants.PRODUCT_UNIT, spu.getUnit())); |
| ... | ... | @@ -131,6 +133,7 @@ public interface SeckillActivityConvert { |
| 131 | 133 | default AppSeckillActivityDetailRespVO convert3(SeckillActivityDO seckillActivity, List<SeckillProductDO> products, SeckillConfigDO filteredConfig) { |
| 132 | 134 | AppSeckillActivityDetailRespVO respVO = convert2(seckillActivity); |
| 133 | 135 | respVO.setProducts(convertList1(products)); |
| 136 | + // TODO @puhui999:可以尝试链式 set 哈; | |
| 134 | 137 | respVO.setStartTime(buildTime(filteredConfig.getStartTime())); |
| 135 | 138 | respVO.setEndTime(buildTime(filteredConfig.getEndTime())); |
| 136 | 139 | return respVO; | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/bargain/BargainActivityMapper.java
| ... | ... | @@ -41,7 +41,7 @@ public interface BargainActivityMapper extends BaseMapperX<BargainActivityDO> { |
| 41 | 41 | default int updateActivityStock(Long id, int count) { |
| 42 | 42 | return update(null, new LambdaUpdateWrapper<BargainActivityDO>() |
| 43 | 43 | .eq(BargainActivityDO::getId, id) |
| 44 | - .gt(BargainActivityDO::getStock, count) | |
| 44 | + .ge(BargainActivityDO::getStock, count) | |
| 45 | 45 | .setSql("stock = stock - " + count)); |
| 46 | 46 | } |
| 47 | 47 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/dal/mysql/seckill/seckillactivity/SeckillActivityMapper.java
| ... | ... | @@ -52,6 +52,7 @@ public interface SeckillActivityMapper extends BaseMapperX<SeckillActivityDO> { |
| 52 | 52 | default PageResult<SeckillActivityDO> selectPage(AppSeckillActivityPageReqVO pageReqVO, Integer status) { |
| 53 | 53 | return selectPage(pageReqVO, new LambdaQueryWrapperX<SeckillActivityDO>() |
| 54 | 54 | .eqIfPresent(SeckillActivityDO::getStatus, status) |
| 55 | + // TODO 芋艿:对 find in set 的想法; | |
| 55 | 56 | .apply(ObjectUtil.isNotNull(pageReqVO.getConfigId()), "FIND_IN_SET(" + pageReqVO.getConfigId() + ",config_ids) > 0")); |
| 56 | 57 | } |
| 57 | 58 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityService.java
| ... | ... | @@ -63,20 +63,22 @@ public interface BargainActivityService { |
| 63 | 63 | */ |
| 64 | 64 | PageResult<BargainActivityDO> getBargainActivityPage(BargainActivityPageReqVO pageReqVO); |
| 65 | 65 | |
| 66 | + // TODO @puhui999:这里可以改成进行中的活动;尽量避免专门为 app 定制,或者类似的名字哈;mapper 那也是 | |
| 67 | + | |
| 66 | 68 | /** |
| 67 | 69 | * 获取 APP 端活动分页数据 |
| 68 | 70 | * |
| 69 | 71 | * @param pageReqVO 分页请求 |
| 70 | 72 | * @return 砍价活动分页 |
| 71 | 73 | */ |
| 72 | - PageResult<BargainActivityDO> getBargainActivityAppPage(PageParam pageReqVO); | |
| 74 | + PageResult<BargainActivityDO> getBargainActivityPageForApp(PageParam pageReqVO); | |
| 73 | 75 | |
| 74 | 76 | /** |
| 75 | 77 | * 获取 APP 端活动展示数据 |
| 76 | 78 | * |
| 77 | 79 | * @param count 需要的数量 |
| 78 | - * @return 活动列表 | |
| 80 | + * @return 砍价活动分页 | |
| 79 | 81 | */ |
| 80 | - List<BargainActivityDO> getBargainActivityAppList(Integer count); | |
| 82 | + List<BargainActivityDO> getBargainActivityListForApp(Integer count); | |
| 81 | 83 | |
| 82 | 84 | } | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/bargain/BargainActivityServiceImpl.java
| ... | ... | @@ -142,18 +142,20 @@ public class BargainActivityServiceImpl implements BargainActivityService { |
| 142 | 142 | } |
| 143 | 143 | |
| 144 | 144 | @Override |
| 145 | - public PageResult<BargainActivityDO> getBargainActivityAppPage(PageParam pageReqVO) { | |
| 145 | + public PageResult<BargainActivityDO> getBargainActivityPageForApp(PageParam pageReqVO) { | |
| 146 | 146 | // 只查询进行中,且在时间范围内的 |
| 147 | 147 | return bargainActivityMapper.selectAppPage(pageReqVO, CommonStatusEnum.ENABLE.getStatus(), LocalDateTime.now()); |
| 148 | - | |
| 149 | 148 | } |
| 150 | 149 | |
| 151 | 150 | @Override |
| 152 | - public List<BargainActivityDO> getBargainActivityAppList(Integer count) { | |
| 151 | + public List<BargainActivityDO> getBargainActivityListForApp(Integer count) { | |
| 152 | + // TODO @puhui999:这种 default count 的逻辑,可以放到 controller 哈;然后可以使用 ObjectUtils.default 方法 | |
| 153 | 153 | if (count == null) { |
| 154 | 154 | count = 6; |
| 155 | 155 | } |
| 156 | - PageResult<BargainActivityDO> result = bargainActivityMapper.selectAppPage(new PageParam().setPageSize(count), CommonStatusEnum.ENABLE.getStatus(), LocalDateTime.now()); | |
| 156 | + // TODO @puhui999:这种不要用 page;会浪费一次 count; | |
| 157 | + PageResult<BargainActivityDO> result = bargainActivityMapper.selectAppPage(new PageParam().setPageSize(count), | |
| 158 | + CommonStatusEnum.ENABLE.getStatus(), LocalDateTime.now()); | |
| 157 | 159 | return result.getList(); |
| 158 | 160 | } |
| 159 | 161 | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityService.java
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImpl.java
| ... | ... | @@ -224,6 +224,7 @@ public class CombinationActivityServiceImpl implements CombinationActivityServic |
| 224 | 224 | throw exception(COMBINATION_ACTIVITY_STATUS_DISABLE); |
| 225 | 225 | } |
| 226 | 226 | // 1.3 校验是否超出单次限购数量 |
| 227 | + // TODO puhui999:count > activity.getSingleLimitCount() 会更好理解点; | |
| 227 | 228 | if (activity.getSingleLimitCount() < count) { |
| 228 | 229 | throw exception(COMBINATION_RECORD_FAILED_SINGLE_LIMIT_COUNT_EXCEED); |
| 229 | 230 | } |
| ... | ... | @@ -243,7 +244,6 @@ public class CombinationActivityServiceImpl implements CombinationActivityServic |
| 243 | 244 | if (activity.getTotalLimitCount() < countSum) { |
| 244 | 245 | throw exception(COMBINATION_RECORD_FAILED_TOTAL_LIMIT_COUNT_EXCEED); |
| 245 | 246 | } |
| 246 | - | |
| 247 | 247 | } |
| 248 | 248 | |
| 249 | 249 | @Override | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java
| ... | ... | @@ -132,7 +132,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 132 | 132 | MemberUserRespDTO user = memberUserApi.getUser(reqDTO.getUserId()); |
| 133 | 133 | ProductSpuRespDTO spu = productSpuApi.getSpu(reqDTO.getSpuId()); |
| 134 | 134 | ProductSkuRespDTO sku = productSkuApi.getSku(reqDTO.getSkuId()); |
| 135 | - recordMapper.insert(CombinationActivityConvert.INSTANCE.convert1(reqDTO, activity, user, spu, sku)); | |
| 135 | + recordMapper.insert(CombinationActivityConvert.INSTANCE.convert(reqDTO, activity, user, spu, sku)); | |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | 138 | @Override | ... | ... |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/brokerage/BrokerageApi.java deleted
| 1 | -package cn.iocoder.yudao.module.trade.api.brokerage; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; | |
| 4 | -import cn.iocoder.yudao.module.trade.api.brokerage.dto.BrokerageUserDTO; | |
| 5 | - | |
| 6 | -import javax.validation.constraints.NotNull; | |
| 7 | -import java.time.LocalDateTime; | |
| 8 | - | |
| 9 | -// TODO @疯狂:是不是不需要这个啦? | |
| 10 | -/** | |
| 11 | - * 分销 API 接口 | |
| 12 | - * | |
| 13 | - * @author owen | |
| 14 | - */ | |
| 15 | -public interface BrokerageApi { | |
| 16 | - | |
| 17 | - /** | |
| 18 | - * 获得分销用户 | |
| 19 | - * | |
| 20 | - * @param userId 用户编号 | |
| 21 | - * @return 分销用户信息 | |
| 22 | - */ | |
| 23 | - BrokerageUserDTO getBrokerageUser(Long userId); | |
| 24 | - | |
| 25 | - /** | |
| 26 | - * 【会员】绑定推广员 | |
| 27 | - * | |
| 28 | - * @param userId 用户编号 | |
| 29 | - * @param bindUserId 推广员编号 | |
| 30 | - * @param registerTime 用户注册时间 | |
| 31 | - * @return 是否绑定 | |
| 32 | - */ | |
| 33 | - default boolean bindUser(@NotNull Long userId, @NotNull Long bindUserId, @NotNull LocalDateTime registerTime) { | |
| 34 | - // 注册时间在30秒内的,都算新用户 | |
| 35 | - // TODO @疯狂:这个要不抽到 service 里哈? | |
| 36 | - boolean isNewUser = LocalDateTimeUtils.afterNow(registerTime.minusSeconds(30)); | |
| 37 | - return bindUser(userId, bindUserId, isNewUser); | |
| 38 | - } | |
| 39 | - | |
| 40 | - /** | |
| 41 | - * 绑定推广员 | |
| 42 | - * | |
| 43 | - * @param userId 用户编号 | |
| 44 | - * @param bindUserId 推广员编号 | |
| 45 | - * @param isNewUser 是否为新用户 | |
| 46 | - * @return 是否绑定 | |
| 47 | - */ | |
| 48 | - boolean bindUser(@NotNull(message = "用户编号不能为空") Long userId, | |
| 49 | - @NotNull(message = "推广员编号不能为空") Long bindUserId, | |
| 50 | - @NotNull Boolean isNewUser); | |
| 51 | - | |
| 52 | -} |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/api/brokerage/dto/BrokerageUserDTO.java deleted
| 1 | -package cn.iocoder.yudao.module.trade.api.brokerage.dto; | |
| 2 | - | |
| 3 | -import lombok.Data; | |
| 4 | - | |
| 5 | -import java.time.LocalDateTime; | |
| 6 | - | |
| 7 | -/** | |
| 8 | - * 分销用户 DTO | |
| 9 | - * | |
| 10 | - * @author owen | |
| 11 | - */ | |
| 12 | -@Data | |
| 13 | -public class BrokerageUserDTO { | |
| 14 | - | |
| 15 | - /** | |
| 16 | - * 用户编号 | |
| 17 | - * <p> | |
| 18 | - * 对应 MemberUserDO 的 id 字段 | |
| 19 | - */ | |
| 20 | - private Long id; | |
| 21 | - | |
| 22 | - /** | |
| 23 | - * 推广员编号 | |
| 24 | - * <p> | |
| 25 | - * 关联 MemberUserDO 的 id 字段 | |
| 26 | - */ | |
| 27 | - private Long bindUserId; | |
| 28 | - /** | |
| 29 | - * 推广员绑定时间 | |
| 30 | - */ | |
| 31 | - private LocalDateTime bindUserTime; | |
| 32 | - | |
| 33 | - /** | |
| 34 | - * 推广资格 | |
| 35 | - */ | |
| 36 | - private Boolean brokerageEnabled; | |
| 37 | - /** | |
| 38 | - * 成为分销员时间 | |
| 39 | - */ | |
| 40 | - private LocalDateTime brokerageTime; | |
| 41 | - | |
| 42 | - /** | |
| 43 | - * 可用佣金 | |
| 44 | - */ | |
| 45 | - private Integer price; | |
| 46 | - /** | |
| 47 | - * 冻结佣金 | |
| 48 | - */ | |
| 49 | - private Integer frozenPrice; | |
| 50 | - | |
| 51 | -} |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/ErrorCodeConstants.java
| ... | ... | @@ -88,4 +88,9 @@ public interface ErrorCodeConstants { |
| 88 | 88 | ErrorCode BROKERAGE_BIND_OVERRIDE = new ErrorCode(1011007006, "已绑定了推广人"); |
| 89 | 89 | ErrorCode BROKERAGE_BIND_LOOP = new ErrorCode(1011007007, "下级不能绑定自己的上级"); |
| 90 | 90 | |
| 91 | + | |
| 92 | + // ========== 分销提现 模块 1011008000 ========== | |
| 93 | + ErrorCode BROKERAGE_WITHDRAW_NOT_EXISTS = new ErrorCode(1011008000, "佣金提现记录不存在"); | |
| 94 | + ErrorCode BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING = new ErrorCode(1011008001, "佣金提现记录状态不是审核中"); | |
| 95 | + | |
| 91 | 96 | } | ... | ... |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java
| ... | ... | @@ -10,4 +10,7 @@ public interface MessageTemplateConstants { |
| 10 | 10 | |
| 11 | 11 | String ORDER_DELIVERY = "order_delivery"; // 短信模版编号 |
| 12 | 12 | |
| 13 | + String BROKERAGE_WITHDRAW_AUDIT_APPROVE = "brokerage_withdraw_audit_approve"; // 佣金提现(审核通过) | |
| 14 | + String BROKERAGE_WITHDRAW_AUDIT_REJECT = "brokerage_withdraw_audit_reject"; // 佣金提现(审核不通过) | |
| 15 | + | |
| 13 | 16 | } | ... | ... |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/brokerage/BrokerageUserTypeEnum.java deleted
| 1 | -package cn.iocoder.yudao.module.trade.enums.brokerage; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.framework.common.core.IntArrayValuable; | |
| 4 | -import lombok.AllArgsConstructor; | |
| 5 | -import lombok.Getter; | |
| 6 | - | |
| 7 | -import java.util.Arrays; | |
| 8 | - | |
| 9 | -// TODO @疯狂:是不是搞成层级,类似 level 这样?因为本质上,它是 1 级、2 级、3 级这样的关系哈 | |
| 10 | -/** | |
| 11 | - * 分销用户类型枚举 | |
| 12 | - * | |
| 13 | - * @author owen | |
| 14 | - */ | |
| 15 | -@AllArgsConstructor | |
| 16 | -@Getter | |
| 17 | -public enum BrokerageUserTypeEnum implements IntArrayValuable { | |
| 18 | - | |
| 19 | - ALL(0, "全部"), | |
| 20 | - FIRST(1, "一级推广人"), | |
| 21 | - SECOND(2, "二级推广人"), | |
| 22 | - ; | |
| 23 | - | |
| 24 | - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BrokerageUserTypeEnum::getType).toArray(); | |
| 25 | - | |
| 26 | - /** | |
| 27 | - * 类型 | |
| 28 | - */ | |
| 29 | - private final Integer type; | |
| 30 | - /** | |
| 31 | - * 名字 | |
| 32 | - */ | |
| 33 | - private final String name; | |
| 34 | - | |
| 35 | - @Override | |
| 36 | - public int[] array() { | |
| 37 | - return ARRAYS; | |
| 38 | - } | |
| 39 | - | |
| 40 | -} |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/api/brokerage/BrokerageApiImpl.java deleted
| 1 | -package cn.iocoder.yudao.module.trade.api.brokerage; | |
| 2 | - | |
| 3 | -import cn.iocoder.yudao.module.trade.api.brokerage.dto.BrokerageUserDTO; | |
| 4 | -import cn.iocoder.yudao.module.trade.convert.brokerage.user.BrokerageUserConvert; | |
| 5 | -import cn.iocoder.yudao.module.trade.service.brokerage.user.BrokerageUserService; | |
| 6 | -import org.springframework.stereotype.Service; | |
| 7 | -import org.springframework.validation.annotation.Validated; | |
| 8 | - | |
| 9 | -import javax.annotation.Resource; | |
| 10 | - | |
| 11 | -/** | |
| 12 | - * 分销 API 接口实现类 | |
| 13 | - * | |
| 14 | - * @author owen | |
| 15 | - */ | |
| 16 | -@Service | |
| 17 | -@Validated | |
| 18 | -public class BrokerageApiImpl implements BrokerageApi { | |
| 19 | - | |
| 20 | - @Resource | |
| 21 | - private BrokerageUserService brokerageUserService; | |
| 22 | - | |
| 23 | - @Override | |
| 24 | - public BrokerageUserDTO getBrokerageUser(Long userId) { | |
| 25 | - return BrokerageUserConvert.INSTANCE.convertDTO(brokerageUserService.getBrokerageUser(userId)); | |
| 26 | - } | |
| 27 | - | |
| 28 | - @Override | |
| 29 | - public boolean bindUser(Long userId, Long bindUserId, Boolean isNewUser) { | |
| 30 | - return brokerageUserService.bindBrokerageUser(userId, bindUserId, isNewUser); | |
| 31 | - } | |
| 32 | - | |
| 33 | -} |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/vo/BrokerageRecordBaseVO.java
| ... | ... | @@ -57,8 +57,8 @@ public class BrokerageRecordBaseVO { |
| 57 | 57 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 58 | 58 | private LocalDateTime unfreezeTime; |
| 59 | 59 | |
| 60 | - @Schema(description = "来源用户类型") | |
| 61 | - private Integer sourceUserType; | |
| 60 | + @Schema(description = "来源用户等级") | |
| 61 | + private Integer sourceUserLevel; | |
| 62 | 62 | |
| 63 | 63 | @Schema(description = "来源用户编号") |
| 64 | 64 | private Long sourceUserId; | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/record/vo/BrokerageRecordPageReqVO.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 4 | -import cn.iocoder.yudao.framework.common.validation.InEnum; | |
| 5 | -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageUserTypeEnum; | |
| 6 | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 7 | 5 | import lombok.Data; |
| 8 | 6 | import lombok.EqualsAndHashCode; |
| ... | ... | @@ -32,8 +30,7 @@ public class BrokerageRecordPageReqVO extends PageParam { |
| 32 | 30 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 33 | 31 | private LocalDateTime[] createTime; |
| 34 | 32 | |
| 35 | - @Schema(description = "用户类型") | |
| 36 | - @InEnum(value = BrokerageUserTypeEnum.class, message = "用户类型必须是 {value}") | |
| 37 | - private Integer sourceUserType; | |
| 33 | + @Schema(description = "用户类型", example = "1") | |
| 34 | + private Integer sourceUserLevel; | |
| 38 | 35 | |
| 39 | 36 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/BrokerageUserController.java
| ... | ... | @@ -9,7 +9,6 @@ import cn.iocoder.yudao.module.trade.convert.brokerage.user.BrokerageUserConvert |
| 9 | 9 | import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.BrokerageUserDO; |
| 10 | 10 | import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; |
| 11 | 11 | import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; |
| 12 | -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageUserTypeEnum; | |
| 13 | 12 | import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryBO; |
| 14 | 13 | import cn.iocoder.yudao.module.trade.service.brokerage.record.BrokerageRecordService; |
| 15 | 14 | import cn.iocoder.yudao.module.trade.service.brokerage.user.BrokerageUserService; |
| ... | ... | @@ -96,7 +95,7 @@ public class BrokerageUserController { |
| 96 | 95 | // 合计推广用户数量 |
| 97 | 96 | Map<Long, Long> brokerageUserCountMap = convertMap(userIds, |
| 98 | 97 | userId -> userId, |
| 99 | - userId -> brokerageUserService.getBrokerageUserCountByBindUserId(userId, BrokerageUserTypeEnum.ALL)); | |
| 98 | + userId -> brokerageUserService.getBrokerageUserCountByBindUserId(userId, null)); | |
| 100 | 99 | |
| 101 | 100 | // todo 合计提现 |
| 102 | 101 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/user/vo/BrokerageUserPageReqVO.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 4 | -import cn.iocoder.yudao.framework.common.validation.InEnum; | |
| 5 | -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageUserTypeEnum; | |
| 6 | 4 | import io.swagger.v3.oas.annotations.media.Schema; |
| 7 | 5 | import lombok.Data; |
| 8 | 6 | import lombok.EqualsAndHashCode; |
| ... | ... | @@ -22,18 +20,18 @@ public class BrokerageUserPageReqVO extends PageParam { |
| 22 | 20 | @Schema(description = "推广员编号", example = "4587") |
| 23 | 21 | private Long bindUserId; |
| 24 | 22 | |
| 25 | - @Schema(description = "推广资格") | |
| 23 | + @Schema(description = "推广资格", example = "true") | |
| 26 | 24 | private Boolean brokerageEnabled; |
| 27 | 25 | |
| 28 | 26 | @Schema(description = "创建时间") |
| 29 | 27 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 30 | 28 | private LocalDateTime[] createTime; |
| 31 | 29 | |
| 32 | - @Schema(description = "用户类型") | |
| 33 | - @InEnum(value = BrokerageUserTypeEnum.class, message = "用户类型必须是 {value}") | |
| 34 | - private Integer userType; | |
| 30 | + @Schema(description = "用户等级", example = "1") // 注意,这了不是用户的会员等级,而是过滤推广的层级 | |
| 31 | + private Integer level; | |
| 35 | 32 | |
| 36 | 33 | @Schema(description = "绑定时间") |
| 37 | 34 | @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) |
| 38 | 35 | private LocalDateTime[] bindUserTime; |
| 36 | + | |
| 39 | 37 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/withdraw/BrokerageWithdrawController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 5 | +import cn.iocoder.yudao.module.member.api.user.MemberUserApi; | |
| 6 | +import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; | |
| 7 | +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo.BrokerageWithdrawRejectReqVO; | |
| 8 | +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo.BrokerageWithdrawPageReqVO; | |
| 9 | +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo.BrokerageWithdrawRespVO; | |
| 10 | +import cn.iocoder.yudao.module.trade.convert.brokerage.withdraw.BrokerageWithdrawConvert; | |
| 11 | +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.withdraw.BrokerageWithdrawDO; | |
| 12 | +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; | |
| 13 | +import cn.iocoder.yudao.module.trade.service.brokerage.withdraw.BrokerageWithdrawService; | |
| 14 | +import io.swagger.v3.oas.annotations.Operation; | |
| 15 | +import io.swagger.v3.oas.annotations.Parameter; | |
| 16 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 17 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 18 | +import org.springframework.validation.annotation.Validated; | |
| 19 | +import org.springframework.web.bind.annotation.*; | |
| 20 | + | |
| 21 | +import javax.annotation.Resource; | |
| 22 | +import javax.validation.Valid; | |
| 23 | +import java.util.Map; | |
| 24 | + | |
| 25 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 26 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | |
| 27 | + | |
| 28 | +@Tag(name = "管理后台 - 佣金提现") | |
| 29 | +@RestController | |
| 30 | +@RequestMapping("/trade/brokerage-withdraw") | |
| 31 | +@Validated | |
| 32 | +public class BrokerageWithdrawController { | |
| 33 | + | |
| 34 | + @Resource | |
| 35 | + private BrokerageWithdrawService brokerageWithdrawService; | |
| 36 | + | |
| 37 | + @Resource | |
| 38 | + private MemberUserApi memberUserApi; | |
| 39 | + | |
| 40 | + @PutMapping("/approve") | |
| 41 | + @Operation(summary = "通过申请") | |
| 42 | + @PreAuthorize("@ss.hasPermission('trade:brokerage-withdraw:audit')") | |
| 43 | + public CommonResult<Boolean> approveBrokerageWithdraw(@RequestParam("id") Integer id) { | |
| 44 | + brokerageWithdrawService.auditBrokerageWithdraw(id, BrokerageWithdrawStatusEnum.AUDIT_SUCCESS, ""); | |
| 45 | + return success(true); | |
| 46 | + } | |
| 47 | + | |
| 48 | + @PutMapping("/reject") | |
| 49 | + @Operation(summary = "驳回申请") | |
| 50 | + @PreAuthorize("@ss.hasPermission('trade:brokerage-withdraw:audit')") | |
| 51 | + public CommonResult<Boolean> rejectBrokerageWithdraw(@Valid @RequestBody BrokerageWithdrawRejectReqVO reqVO) { | |
| 52 | + brokerageWithdrawService.auditBrokerageWithdraw(reqVO.getId(), BrokerageWithdrawStatusEnum.AUDIT_FAIL, reqVO.getAuditReason()); | |
| 53 | + return success(true); | |
| 54 | + } | |
| 55 | + | |
| 56 | + @GetMapping("/get") | |
| 57 | + @Operation(summary = "获得佣金提现") | |
| 58 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | |
| 59 | + @PreAuthorize("@ss.hasPermission('trade:brokerage-withdraw:query')") | |
| 60 | + public CommonResult<BrokerageWithdrawRespVO> getBrokerageWithdraw(@RequestParam("id") Integer id) { | |
| 61 | + BrokerageWithdrawDO brokerageWithdraw = brokerageWithdrawService.getBrokerageWithdraw(id); | |
| 62 | + return success(BrokerageWithdrawConvert.INSTANCE.convert(brokerageWithdraw)); | |
| 63 | + } | |
| 64 | + | |
| 65 | + @GetMapping("/page") | |
| 66 | + @Operation(summary = "获得佣金提现分页") | |
| 67 | + @PreAuthorize("@ss.hasPermission('trade:brokerage-withdraw:query')") | |
| 68 | + public CommonResult<PageResult<BrokerageWithdrawRespVO>> getBrokerageWithdrawPage(@Valid BrokerageWithdrawPageReqVO pageVO) { | |
| 69 | + // 分页查询 | |
| 70 | + PageResult<BrokerageWithdrawDO> pageResult = brokerageWithdrawService.getBrokerageWithdrawPage(pageVO); | |
| 71 | + | |
| 72 | + // 拼接信息 | |
| 73 | + Map<Long, MemberUserRespDTO> userMap = memberUserApi.getUserMap( | |
| 74 | + convertSet(pageResult.getList(), BrokerageWithdrawDO::getUserId)); | |
| 75 | + return success(BrokerageWithdrawConvert.INSTANCE.convertPage(pageResult, userMap)); | |
| 76 | + } | |
| 77 | + | |
| 78 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/withdraw/vo/BrokerageWithdrawBaseVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 6 | + | |
| 7 | +import javax.validation.constraints.NotNull; | |
| 8 | +import java.time.LocalDateTime; | |
| 9 | + | |
| 10 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * 佣金提现 Base VO,提供给添加、修改、详细的子 VO 使用 | |
| 14 | + * 如果子 VO 存在差异的字段,请不要添加到这里,影响 Swagger 文档生成 | |
| 15 | + */ | |
| 16 | +@Data | |
| 17 | +public class BrokerageWithdrawBaseVO { | |
| 18 | + | |
| 19 | + @Schema(description = "用户编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "11436") | |
| 20 | + @NotNull(message = "用户编号不能为空") | |
| 21 | + private Long userId; | |
| 22 | + | |
| 23 | + @Schema(description = "提现金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "18781") | |
| 24 | + @NotNull(message = "提现金额不能为空") | |
| 25 | + private Integer price; | |
| 26 | + | |
| 27 | + @Schema(description = "提现手续费", requiredMode = Schema.RequiredMode.REQUIRED, example = "11417") | |
| 28 | + @NotNull(message = "提现手续费不能为空") | |
| 29 | + private Integer feePrice; | |
| 30 | + | |
| 31 | + @Schema(description = "当前总佣金", requiredMode = Schema.RequiredMode.REQUIRED, example = "18576") | |
| 32 | + @NotNull(message = "当前总佣金不能为空") | |
| 33 | + private Integer totalPrice; | |
| 34 | + | |
| 35 | + @Schema(description = "提现类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 36 | + @NotNull(message = "提现类型不能为空") | |
| 37 | + private Integer type; | |
| 38 | + | |
| 39 | + @Schema(description = "真实姓名", example = "赵六") | |
| 40 | + private String name; | |
| 41 | + | |
| 42 | + @Schema(description = "账号", example = "88677912132") | |
| 43 | + private String accountNo; | |
| 44 | + | |
| 45 | + @Schema(description = "银行名称", example = "1") | |
| 46 | + private String bankName; | |
| 47 | + | |
| 48 | + @Schema(description = "开户地址", example = "海淀支行") | |
| 49 | + private String bankAddress; | |
| 50 | + | |
| 51 | + @Schema(description = "收款码", example = "https://www.iocoder.cn") | |
| 52 | + private String accountQrCodeUrl; | |
| 53 | + | |
| 54 | + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 55 | + @NotNull(message = "状态不能为空") | |
| 56 | + private Integer status; | |
| 57 | + | |
| 58 | + @Schema(description = "审核驳回原因", example = "不对") | |
| 59 | + private String auditReason; | |
| 60 | + | |
| 61 | + @Schema(description = "审核时间") | |
| 62 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 63 | + private LocalDateTime auditTime; | |
| 64 | + | |
| 65 | + @Schema(description = "备注", example = "随便") | |
| 66 | + private String remark; | |
| 67 | + | |
| 68 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/withdraw/vo/BrokerageWithdrawPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageParam; | |
| 4 | +import cn.iocoder.yudao.framework.common.validation.InEnum; | |
| 5 | +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; | |
| 6 | +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; | |
| 7 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 8 | +import lombok.Data; | |
| 9 | +import lombok.EqualsAndHashCode; | |
| 10 | +import lombok.ToString; | |
| 11 | +import org.springframework.format.annotation.DateTimeFormat; | |
| 12 | + | |
| 13 | +import java.time.LocalDateTime; | |
| 14 | + | |
| 15 | +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | |
| 16 | + | |
| 17 | +@Schema(description = "管理后台 - 佣金提现分页 Request VO") | |
| 18 | +@Data | |
| 19 | +@EqualsAndHashCode(callSuper = true) | |
| 20 | +@ToString(callSuper = true) | |
| 21 | +public class BrokerageWithdrawPageReqVO extends PageParam { | |
| 22 | + | |
| 23 | + @Schema(description = "用户编号", example = "11436") | |
| 24 | + private Long userId; | |
| 25 | + | |
| 26 | + @Schema(description = "提现类型", example = "1") | |
| 27 | + @InEnum(value = BrokerageWithdrawTypeEnum.class, message = "提现类型必须是 {value}") | |
| 28 | + private Integer type; | |
| 29 | + | |
| 30 | + @Schema(description = "真实姓名", example = "赵六") | |
| 31 | + private String name; | |
| 32 | + | |
| 33 | + @Schema(description = "账号", example = "886779132") | |
| 34 | + private String accountNo; | |
| 35 | + | |
| 36 | + @Schema(description = "银行名称", example = "1") | |
| 37 | + private String bankName; | |
| 38 | + | |
| 39 | + @Schema(description = "状态", example = "1") | |
| 40 | + @InEnum(value = BrokerageWithdrawStatusEnum.class, message = "状态必须是 {value}") | |
| 41 | + private Integer status; | |
| 42 | + | |
| 43 | + @Schema(description = "创建时间") | |
| 44 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | |
| 45 | + private LocalDateTime[] createTime; | |
| 46 | + | |
| 47 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/withdraw/vo/BrokerageWithdrawRejectReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.ToString; | |
| 6 | + | |
| 7 | +import javax.validation.constraints.NotEmpty; | |
| 8 | +import javax.validation.constraints.NotNull; | |
| 9 | + | |
| 10 | +@Schema(description = "管理后台 - 驳回申请 Request VO") | |
| 11 | +@Data | |
| 12 | +@ToString(callSuper = true) | |
| 13 | +public class BrokerageWithdrawRejectReqVO { | |
| 14 | + | |
| 15 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7161") | |
| 16 | + @NotNull(message = "编号不能为空") | |
| 17 | + private Integer id; | |
| 18 | + | |
| 19 | + @Schema(description = "审核驳回原因", example = "不对") | |
| 20 | + @NotEmpty(message = "审核驳回原因不能为空") | |
| 21 | + private String auditReason; | |
| 22 | + | |
| 23 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/admin/brokerage/withdraw/vo/BrokerageWithdrawRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | +import lombok.EqualsAndHashCode; | |
| 6 | +import lombok.ToString; | |
| 7 | + | |
| 8 | +import java.time.LocalDateTime; | |
| 9 | + | |
| 10 | +@Schema(description = "管理后台 - 佣金提现 Response VO") | |
| 11 | +@Data | |
| 12 | +@EqualsAndHashCode(callSuper = true) | |
| 13 | +@ToString(callSuper = true) | |
| 14 | +public class BrokerageWithdrawRespVO extends BrokerageWithdrawBaseVO { | |
| 15 | + | |
| 16 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "7161") | |
| 17 | + private Integer id; | |
| 18 | + | |
| 19 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 20 | + private LocalDateTime createTime; | |
| 21 | + | |
| 22 | + @Schema(description = "用户昵称", requiredMode = Schema.RequiredMode.REQUIRED, example = "芋艿") | |
| 23 | + private String userNickname; | |
| 24 | + | |
| 25 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/record/BrokerageRecordConvert.java
| ... | ... | @@ -35,7 +35,7 @@ public interface BrokerageRecordConvert { |
| 35 | 35 | |
| 36 | 36 | default BrokerageRecordDO convert(BrokerageUserDO user, BrokerageRecordBizTypeEnum bizType, String bizId, |
| 37 | 37 | Integer brokerageFrozenDays, int brokeragePrice, LocalDateTime unfreezeTime, |
| 38 | - String title, Long sourceUserId, Integer sourceUserType) { | |
| 38 | + String title, Long sourceUserId, Integer sourceUserLevel) { | |
| 39 | 39 | brokerageFrozenDays = ObjectUtil.defaultIfNull(brokerageFrozenDays, 0); |
| 40 | 40 | // 不冻结时,佣金直接就是结算状态 |
| 41 | 41 | Integer status = brokerageFrozenDays > 0 |
| ... | ... | @@ -47,7 +47,7 @@ public interface BrokerageRecordConvert { |
| 47 | 47 | .setTitle(title) |
| 48 | 48 | .setDescription(StrUtil.format(bizType.getDescription(), String.format("¥%.2f", brokeragePrice / 100d))) |
| 49 | 49 | .setStatus(status).setFrozenDays(brokerageFrozenDays).setUnfreezeTime(unfreezeTime) |
| 50 | - .setSourceUserType(sourceUserType).setSourceUserId(sourceUserId); | |
| 50 | + .setSourceUserLevel(sourceUserLevel).setSourceUserId(sourceUserId); | |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | default PageResult<BrokerageRecordRespVO> convertPage(PageResult<BrokerageRecordDO> pageResult, Map<Long, MemberUserRespDTO> userMap) { | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/user/BrokerageUserConvert.java
| ... | ... | @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.trade.convert.brokerage.user; |
| 3 | 3 | import cn.hutool.core.map.MapUtil; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 5 | import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; |
| 6 | -import cn.iocoder.yudao.module.trade.api.brokerage.dto.BrokerageUserDTO; | |
| 7 | 6 | import cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo.BrokerageUserRespVO; |
| 8 | 7 | import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.BrokerageUserDO; |
| 9 | 8 | import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryBO; |
| ... | ... | @@ -56,6 +55,4 @@ public interface BrokerageUserConvert { |
| 56 | 55 | user -> target.setNickname(user.getNickname()).setAvatar(user.getAvatar())); |
| 57 | 56 | return target; |
| 58 | 57 | } |
| 59 | - | |
| 60 | - BrokerageUserDTO convertDTO(BrokerageUserDO brokerageUser); | |
| 61 | 58 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/brokerage/withdraw/BrokerageWithdrawConvert.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.convert.brokerage.withdraw; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; | |
| 5 | +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo.BrokerageWithdrawRejectReqVO; | |
| 6 | +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo.BrokerageWithdrawRespVO; | |
| 7 | +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.withdraw.BrokerageWithdrawDO; | |
| 8 | +import org.mapstruct.Mapper; | |
| 9 | +import org.mapstruct.factory.Mappers; | |
| 10 | + | |
| 11 | +import java.util.List; | |
| 12 | +import java.util.Map; | |
| 13 | +import java.util.Optional; | |
| 14 | + | |
| 15 | +/** | |
| 16 | + * 佣金提现 Convert | |
| 17 | + * | |
| 18 | + * @author 芋道源码 | |
| 19 | + */ | |
| 20 | +@Mapper | |
| 21 | +public interface BrokerageWithdrawConvert { | |
| 22 | + | |
| 23 | + BrokerageWithdrawConvert INSTANCE = Mappers.getMapper(BrokerageWithdrawConvert.class); | |
| 24 | + | |
| 25 | + BrokerageWithdrawDO convert(BrokerageWithdrawRejectReqVO bean); | |
| 26 | + | |
| 27 | + BrokerageWithdrawRespVO convert(BrokerageWithdrawDO bean); | |
| 28 | + | |
| 29 | + List<BrokerageWithdrawRespVO> convertList(List<BrokerageWithdrawDO> list); | |
| 30 | + | |
| 31 | + PageResult<BrokerageWithdrawRespVO> convertPage(PageResult<BrokerageWithdrawDO> page); | |
| 32 | + | |
| 33 | + default PageResult<BrokerageWithdrawRespVO> convertPage(PageResult<BrokerageWithdrawDO> pageResult, Map<Long, MemberUserRespDTO> userMap) { | |
| 34 | + PageResult<BrokerageWithdrawRespVO> result = convertPage(pageResult); | |
| 35 | + for (BrokerageWithdrawRespVO vo : result.getList()) { | |
| 36 | + vo.setUserNickname(Optional.ofNullable(userMap.get(vo.getUserId())).map(MemberUserRespDTO::getNickname).orElse(null)); | |
| 37 | + } | |
| 38 | + return result; | |
| 39 | + } | |
| 40 | + | |
| 41 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/convert/order/TradeOrderConvert.java
| ... | ... | @@ -27,7 +27,6 @@ import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; |
| 27 | 27 | import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; |
| 28 | 28 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; |
| 29 | 29 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; |
| 30 | -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; | |
| 31 | 30 | import cn.iocoder.yudao.module.trade.enums.order.TradeOrderItemAfterSaleStatusEnum; |
| 32 | 31 | import cn.iocoder.yudao.module.trade.framework.delivery.core.client.dto.ExpressTrackRespDTO; |
| 33 | 32 | import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; |
| ... | ... | @@ -274,10 +273,10 @@ public interface TradeOrderConvert { |
| 274 | 273 | |
| 275 | 274 | TradeOrderDO convert(TradeOrderRemarkReqVO reqVO); |
| 276 | 275 | |
| 277 | - default BrokerageAddReqBO convert(TradeOrderItemDO item, ProductSkuRespDTO sku) { | |
| 276 | + default BrokerageAddReqBO convert(MemberUserRespDTO user, TradeOrderItemDO item, ProductSkuRespDTO sku) { | |
| 278 | 277 | return new BrokerageAddReqBO().setBizId(String.valueOf(item.getId())).setSourceUserId(item.getUserId()) |
| 279 | 278 | .setBasePrice(item.getPayPrice() * item.getCount()) |
| 280 | - .setTitle(BrokerageRecordBizTypeEnum.ORDER.getTitle()) // TODO @疯狂:标题类似:木晴冰雪成功购买云时代的JVM原理与实战;茫农成功购买深入拆解消息队列47讲 | |
| 279 | + .setTitle(StrUtil.format("{}成功购买{}", user.getNickname(), item.getSpuName())) | |
| 281 | 280 | .setFirstFixedPrice(sku.getFirstBrokeragePrice()).setSecondFixedPrice(sku.getSecondBrokeragePrice()); |
| 282 | 281 | } |
| 283 | 282 | |
| ... | ... | @@ -292,6 +291,7 @@ public interface TradeOrderConvert { |
| 292 | 291 | @Mapping(target = "userId", source = "userId"), |
| 293 | 292 | @Mapping(target = "payPrice", source = "tradeOrderDO.payPrice"), |
| 294 | 293 | }) |
| 295 | - TradeAfterOrderCreateReqBO convert(Long userId, AppTradeOrderCreateReqVO createReqVO, TradeOrderDO tradeOrderDO, TradeOrderItemDO orderItem); | |
| 294 | + TradeAfterOrderCreateReqBO convert(Long userId, AppTradeOrderCreateReqVO createReqVO, | |
| 295 | + TradeOrderDO tradeOrderDO, TradeOrderItemDO orderItem); | |
| 296 | 296 | |
| 297 | 297 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/record/BrokerageRecordDO.java
| ... | ... | @@ -3,7 +3,6 @@ package cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record; |
| 3 | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | 4 | import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; |
| 5 | 5 | import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; |
| 6 | -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageUserTypeEnum; | |
| 7 | 6 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 8 | 7 | import com.baomidou.mybatisplus.annotation.TableId; |
| 9 | 8 | import com.baomidou.mybatisplus.annotation.TableName; |
| ... | ... | @@ -83,11 +82,11 @@ public class BrokerageRecordDO extends BaseDO { |
| 83 | 82 | private LocalDateTime unfreezeTime; |
| 84 | 83 | |
| 85 | 84 | /** |
| 86 | - * 来源用户类型 | |
| 85 | + * 来源用户等级 | |
| 87 | 86 | * <p> |
| 88 | - * 枚举 {@link BrokerageUserTypeEnum},被推广用户和 {@link #userId} 的推广层级关系 | |
| 87 | + * 被推广用户和 {@link #userId} 的推广层级关系 | |
| 89 | 88 | */ |
| 90 | - private Integer sourceUserType; | |
| 89 | + private Integer sourceUserLevel; | |
| 91 | 90 | /** |
| 92 | 91 | * 来源用户编号 |
| 93 | 92 | * <p> | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/user/BrokerageUserDO.java
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/brokerage/withdraw/BrokerageWithdrawDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.withdraw; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; | |
| 5 | +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawTypeEnum; | |
| 6 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 7 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 8 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 9 | +import lombok.*; | |
| 10 | + | |
| 11 | +import java.time.LocalDateTime; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 佣金提现 DO | |
| 15 | + * | |
| 16 | + * @author 芋道源码 | |
| 17 | + */ | |
| 18 | +@TableName("trade_brokerage_withdraw") | |
| 19 | +@KeySequence("trade_brokerage_withdraw_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 20 | +@Data | |
| 21 | +@EqualsAndHashCode(callSuper = true) | |
| 22 | +@ToString(callSuper = true) | |
| 23 | +@Builder | |
| 24 | +@NoArgsConstructor | |
| 25 | +@AllArgsConstructor | |
| 26 | +public class BrokerageWithdrawDO extends BaseDO { | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * 编号 | |
| 30 | + */ | |
| 31 | + @TableId | |
| 32 | + private Integer id; | |
| 33 | + /** | |
| 34 | + * 用户编号 | |
| 35 | + * | |
| 36 | + * 关联 MemberUserDO 的 id 字段 | |
| 37 | + */ | |
| 38 | + private Long userId; | |
| 39 | + | |
| 40 | + /** | |
| 41 | + * 提现金额,单位:分 | |
| 42 | + */ | |
| 43 | + private Integer price; | |
| 44 | + /** | |
| 45 | + * 提现手续费,单位:分 | |
| 46 | + */ | |
| 47 | + private Integer feePrice; | |
| 48 | + /** | |
| 49 | + * 当前总佣金,单位:分 | |
| 50 | + */ | |
| 51 | + private Integer totalPrice; | |
| 52 | + /** | |
| 53 | + * 提现类型 | |
| 54 | + * <p> | |
| 55 | + * 枚举 {@link BrokerageWithdrawTypeEnum} | |
| 56 | + */ | |
| 57 | + private Integer type; | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * 真实姓名 | |
| 61 | + */ | |
| 62 | + private String name; | |
| 63 | + /** | |
| 64 | + * 账号 | |
| 65 | + */ | |
| 66 | + private String accountNo; | |
| 67 | + /** | |
| 68 | + * 银行名称 | |
| 69 | + */ | |
| 70 | + private String bankName; | |
| 71 | + /** | |
| 72 | + * 开户地址 | |
| 73 | + */ | |
| 74 | + private String bankAddress; | |
| 75 | + /** | |
| 76 | + * 收款码 | |
| 77 | + */ | |
| 78 | + private String accountQrCodeUrl; | |
| 79 | + /** | |
| 80 | + * 状态 | |
| 81 | + * <p> | |
| 82 | + * 枚举 {@link BrokerageWithdrawStatusEnum} | |
| 83 | + */ | |
| 84 | + private Integer status; | |
| 85 | + /** | |
| 86 | + * 审核驳回原因 | |
| 87 | + */ | |
| 88 | + private String auditReason; | |
| 89 | + /** | |
| 90 | + * 审核时间 | |
| 91 | + */ | |
| 92 | + private LocalDateTime auditTime; | |
| 93 | + /** | |
| 94 | + * 备注 | |
| 95 | + */ | |
| 96 | + private String remark; | |
| 97 | + | |
| 98 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/record/BrokerageRecordMapper.java
| ... | ... | @@ -5,7 +5,6 @@ import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 5 | 5 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 6 | 6 | import cn.iocoder.yudao.module.trade.controller.admin.brokerage.record.vo.BrokerageRecordPageReqVO; |
| 7 | 7 | import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.record.BrokerageRecordDO; |
| 8 | -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageUserTypeEnum; | |
| 9 | 8 | import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryBO; |
| 10 | 9 | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| 11 | 10 | import org.apache.ibatis.annotations.Mapper; |
| ... | ... | @@ -24,14 +23,12 @@ import java.util.List; |
| 24 | 23 | public interface BrokerageRecordMapper extends BaseMapperX<BrokerageRecordDO> { |
| 25 | 24 | |
| 26 | 25 | default PageResult<BrokerageRecordDO> selectPage(BrokerageRecordPageReqVO reqVO) { |
| 27 | - boolean sourceUserTypeCondition = reqVO.getSourceUserType() != null && | |
| 28 | - !BrokerageUserTypeEnum.ALL.getType().equals(reqVO.getSourceUserType()); | |
| 29 | 26 | // 分页查询 |
| 30 | 27 | return selectPage(reqVO, new LambdaQueryWrapperX<BrokerageRecordDO>() |
| 31 | 28 | .eqIfPresent(BrokerageRecordDO::getUserId, reqVO.getUserId()) |
| 32 | 29 | .eqIfPresent(BrokerageRecordDO::getBizType, reqVO.getBizType()) |
| 33 | 30 | .eqIfPresent(BrokerageRecordDO::getStatus, reqVO.getStatus()) |
| 34 | - .eq(sourceUserTypeCondition, BrokerageRecordDO::getSourceUserType, reqVO.getSourceUserType()) | |
| 31 | + .eqIfPresent(BrokerageRecordDO::getSourceUserLevel, reqVO.getSourceUserLevel()) | |
| 35 | 32 | .betweenIfPresent(BrokerageRecordDO::getCreateTime, reqVO.getCreateTime()) |
| 36 | 33 | .orderByDesc(BrokerageRecordDO::getId)); |
| 37 | 34 | } |
| ... | ... | @@ -59,4 +56,5 @@ public interface BrokerageRecordMapper extends BaseMapperX<BrokerageRecordDO> { |
| 59 | 56 | UserBrokerageSummaryBO selectCountAndSumPriceByUserIdAndBizTypeAndStatus(@Param("userId") Long userId, |
| 60 | 57 | @Param("bizType") Integer bizType, |
| 61 | 58 | @Param("status") Integer status); |
| 59 | + | |
| 62 | 60 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/user/BrokerageUserMapper.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.dal.mysql.brokerage.user; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.lang.Assert; |
| 4 | -import cn.hutool.core.util.StrUtil; | |
| 5 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 5 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 7 | 6 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 8 | 7 | import cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo.BrokerageUserPageReqVO; |
| 9 | 8 | import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.BrokerageUserDO; |
| 10 | -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageUserTypeEnum; | |
| 11 | -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | |
| 12 | 9 | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| 13 | 10 | import org.apache.ibatis.annotations.Mapper; |
| 14 | -import org.apache.ibatis.annotations.Select; | |
| 11 | + | |
| 12 | +import java.util.List; | |
| 15 | 13 | |
| 16 | 14 | /** |
| 17 | 15 | * 分销用户 Mapper |
| ... | ... | @@ -21,35 +19,16 @@ import org.apache.ibatis.annotations.Select; |
| 21 | 19 | @Mapper |
| 22 | 20 | public interface BrokerageUserMapper extends BaseMapperX<BrokerageUserDO> { |
| 23 | 21 | |
| 24 | - default PageResult<BrokerageUserDO> selectPage(BrokerageUserPageReqVO reqVO) { | |
| 22 | + default PageResult<BrokerageUserDO> selectPage(BrokerageUserPageReqVO reqVO, List<Integer> levels) { | |
| 25 | 23 | return selectPage(reqVO, new LambdaQueryWrapperX<BrokerageUserDO>() |
| 26 | 24 | .eqIfPresent(BrokerageUserDO::getBrokerageEnabled, reqVO.getBrokerageEnabled()) |
| 27 | 25 | .betweenIfPresent(BrokerageUserDO::getCreateTime, reqVO.getCreateTime()) |
| 28 | 26 | .betweenIfPresent(BrokerageUserDO::getBindUserTime, reqVO.getBindUserTime()) |
| 29 | - .and(reqVO.getBindUserId() != null, w -> buildBindUserCondition(reqVO, w)) | |
| 27 | + .findInSetIfPresent(BrokerageUserDO::getPath, reqVO.getBindUserId()) | |
| 28 | + .inIfPresent(BrokerageUserDO::getLevel, levels) | |
| 30 | 29 | .orderByDesc(BrokerageUserDO::getId)); |
| 31 | 30 | } |
| 32 | 31 | |
| 33 | - static void buildBindUserCondition(BrokerageUserPageReqVO reqVO, LambdaQueryWrapper<BrokerageUserDO> wrapper) { | |
| 34 | - if (BrokerageUserTypeEnum.FIRST.getType().equals(reqVO.getUserType())) { | |
| 35 | - buildFirstBindUserCondition(reqVO.getBindUserId(), wrapper); | |
| 36 | - } else if (BrokerageUserTypeEnum.SECOND.getType().equals(reqVO.getUserType())) { | |
| 37 | - buildSecondBindUserCondition(reqVO.getBindUserId(), wrapper); | |
| 38 | - } else { | |
| 39 | - // TODO @疯狂:要不要把这个逻辑,挪到 Service 里,算出子用户有哪些,然后 IN? | |
| 40 | - buildFirstBindUserCondition(reqVO.getBindUserId(), wrapper); | |
| 41 | - buildSecondBindUserCondition(reqVO.getBindUserId(), wrapper.or()); // 通过 or 实现多个条件 | |
| 42 | - } | |
| 43 | - } | |
| 44 | - | |
| 45 | - static void buildFirstBindUserCondition(Long bindUserId, LambdaQueryWrapper<BrokerageUserDO> wrapper) { | |
| 46 | - wrapper.eq(BrokerageUserDO::getBindUserId, bindUserId); | |
| 47 | - } | |
| 48 | - | |
| 49 | - static void buildSecondBindUserCondition(Long bindUserId, LambdaQueryWrapper<BrokerageUserDO> wrapper) { | |
| 50 | - wrapper.inSql(BrokerageUserDO::getBindUserId, StrUtil.format("SELECT id FROM trade_brokerage_user WHERE bind_user_id = {}", bindUserId)); | |
| 51 | - } | |
| 52 | - | |
| 53 | 32 | /** |
| 54 | 33 | * 更新用户可用佣金(增加) |
| 55 | 34 | * |
| ... | ... | @@ -128,7 +107,8 @@ public interface BrokerageUserMapper extends BaseMapperX<BrokerageUserDO> { |
| 128 | 107 | default void updateBindUserIdAndBindUserTimeToNull(Long id) { |
| 129 | 108 | update(null, new LambdaUpdateWrapper<BrokerageUserDO>() |
| 130 | 109 | .eq(BrokerageUserDO::getId, id) |
| 131 | - .set(BrokerageUserDO::getBindUserId, null).set(BrokerageUserDO::getBindUserTime, null)); | |
| 110 | + .set(BrokerageUserDO::getBindUserId, null).set(BrokerageUserDO::getBindUserTime, null) | |
| 111 | + .set(BrokerageUserDO::getLevel, 1).set(BrokerageUserDO::getPath, "")); | |
| 132 | 112 | } |
| 133 | 113 | |
| 134 | 114 | default void updateEnabledFalseAndBrokerageTimeToNull(Long id) { |
| ... | ... | @@ -137,11 +117,10 @@ public interface BrokerageUserMapper extends BaseMapperX<BrokerageUserDO> { |
| 137 | 117 | .set(BrokerageUserDO::getBrokerageEnabled, false).set(BrokerageUserDO::getBrokerageTime, null)); |
| 138 | 118 | } |
| 139 | 119 | |
| 140 | - default Long selectCountByBindUserId(Long bindUserId) { | |
| 141 | - return selectCount(BrokerageUserDO::getBindUserId, bindUserId); | |
| 120 | + default Long selectCountByBindUserIdAndLevelIn(Long bindUserId, List<Integer> levels) { | |
| 121 | + return selectCount(new LambdaQueryWrapperX<BrokerageUserDO>() | |
| 122 | + .findInSetIfPresent(BrokerageUserDO::getPath, bindUserId) | |
| 123 | + .inIfPresent(BrokerageUserDO::getLevel, levels)); | |
| 142 | 124 | } |
| 143 | 125 | |
| 144 | - @Select("SELECT COUNT(1) from trade_brokerage_user WHERE bind_user_id IN (SELECT id FROM trade_brokerage_user WHERE bind_user_id = #{bindUserId})") | |
| 145 | - Long selectCountByBindUserIdInBindUserId(Long bindUserId); | |
| 146 | - | |
| 147 | 126 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/withdraw/BrokerageWithdrawMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.dal.mysql.brokerage.withdraw; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 5 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 6 | +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo.BrokerageWithdrawPageReqVO; | |
| 7 | +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.withdraw.BrokerageWithdrawDO; | |
| 8 | +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | |
| 9 | +import org.apache.ibatis.annotations.Mapper; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 佣金提现 Mapper | |
| 13 | + * | |
| 14 | + * @author 芋道源码 | |
| 15 | + */ | |
| 16 | +@Mapper | |
| 17 | +public interface BrokerageWithdrawMapper extends BaseMapperX<BrokerageWithdrawDO> { | |
| 18 | + | |
| 19 | + default PageResult<BrokerageWithdrawDO> selectPage(BrokerageWithdrawPageReqVO reqVO) { | |
| 20 | + return selectPage(reqVO, new LambdaQueryWrapperX<BrokerageWithdrawDO>() | |
| 21 | + .eqIfPresent(BrokerageWithdrawDO::getUserId, reqVO.getUserId()) | |
| 22 | + .eqIfPresent(BrokerageWithdrawDO::getType, reqVO.getType()) | |
| 23 | + .likeIfPresent(BrokerageWithdrawDO::getName, reqVO.getName()) | |
| 24 | + .eqIfPresent(BrokerageWithdrawDO::getAccountNo, reqVO.getAccountNo()) | |
| 25 | + .likeIfPresent(BrokerageWithdrawDO::getBankName, reqVO.getBankName()) | |
| 26 | + .eqIfPresent(BrokerageWithdrawDO::getStatus, reqVO.getStatus()) | |
| 27 | + .betweenIfPresent(BrokerageWithdrawDO::getCreateTime, reqVO.getCreateTime()) | |
| 28 | + .orderByAsc(BrokerageWithdrawDO::getStatus).orderByDesc(BrokerageWithdrawDO::getId)); | |
| 29 | + } | |
| 30 | + | |
| 31 | + default int updateByIdAndStatus(Integer id, Integer status, BrokerageWithdrawDO updateObj) { | |
| 32 | + return update(updateObj, new LambdaUpdateWrapper<BrokerageWithdrawDO>() | |
| 33 | + .eq(BrokerageWithdrawDO::getId, id) | |
| 34 | + .eq(BrokerageWithdrawDO::getStatus, status)); | |
| 35 | + } | |
| 36 | + | |
| 37 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/record/BrokerageRecordServiceImpl.java
| ... | ... | @@ -15,7 +15,6 @@ import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; |
| 15 | 15 | import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.record.BrokerageRecordMapper; |
| 16 | 16 | import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordBizTypeEnum; |
| 17 | 17 | import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageRecordStatusEnum; |
| 18 | -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageUserTypeEnum; | |
| 19 | 18 | import cn.iocoder.yudao.module.trade.service.brokerage.bo.BrokerageAddReqBO; |
| 20 | 19 | import cn.iocoder.yudao.module.trade.service.brokerage.bo.UserBrokerageSummaryBO; |
| 21 | 20 | import cn.iocoder.yudao.module.trade.service.brokerage.user.BrokerageUserService; |
| ... | ... | @@ -29,6 +28,7 @@ import javax.annotation.Resource; |
| 29 | 28 | import java.time.LocalDateTime; |
| 30 | 29 | import java.util.ArrayList; |
| 31 | 30 | import java.util.List; |
| 31 | +import java.util.Objects; | |
| 32 | 32 | |
| 33 | 33 | /** |
| 34 | 34 | * 佣金记录 Service 实现类 |
| ... | ... | @@ -74,7 +74,7 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService { |
| 74 | 74 | } |
| 75 | 75 | // 1.2 计算一级分佣 |
| 76 | 76 | addBrokerage(firstUser, list, memberConfig.getBrokerageFrozenDays(), memberConfig.getBrokerageFirstPercent(), |
| 77 | - bizType, BrokerageUserTypeEnum.FIRST); | |
| 77 | + bizType, 1); | |
| 78 | 78 | |
| 79 | 79 | // 2.1 获得二级推广员 |
| 80 | 80 | if (firstUser.getBindUserId() == null) { |
| ... | ... | @@ -86,7 +86,7 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService { |
| 86 | 86 | } |
| 87 | 87 | // 2.2 计算二级分佣 |
| 88 | 88 | addBrokerage(secondUser, list, memberConfig.getBrokerageFrozenDays(), memberConfig.getBrokerageSecondPercent(), |
| 89 | - bizType, BrokerageUserTypeEnum.SECOND); | |
| 89 | + bizType, 2); | |
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | @Override |
| ... | ... | @@ -142,10 +142,10 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService { |
| 142 | 142 | * @param brokerageFrozenDays 冻结天数 |
| 143 | 143 | * @param brokeragePercent 佣金比例 |
| 144 | 144 | * @param bizType 业务类型 |
| 145 | - * @param sourceUserType 来源用户类型 | |
| 145 | + * @param sourceUserLevel 来源用户等级 | |
| 146 | 146 | */ |
| 147 | 147 | private void addBrokerage(BrokerageUserDO user, List<BrokerageAddReqBO> list, Integer brokerageFrozenDays, |
| 148 | - Integer brokeragePercent, BrokerageRecordBizTypeEnum bizType, BrokerageUserTypeEnum sourceUserType) { | |
| 148 | + Integer brokeragePercent, BrokerageRecordBizTypeEnum bizType, Integer sourceUserLevel) { | |
| 149 | 149 | // 1.1 处理冻结时间 |
| 150 | 150 | LocalDateTime unfreezeTime = null; |
| 151 | 151 | if (brokerageFrozenDays != null && brokerageFrozenDays > 0) { |
| ... | ... | @@ -157,12 +157,12 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService { |
| 157 | 157 | for (BrokerageAddReqBO item : list) { |
| 158 | 158 | // 计算金额 |
| 159 | 159 | Integer fixedPrice; |
| 160 | - if (BrokerageUserTypeEnum.FIRST.equals(sourceUserType)) { | |
| 160 | + if (Objects.equals(sourceUserLevel, 1)) { | |
| 161 | 161 | fixedPrice = item.getFirstFixedPrice(); |
| 162 | - } else if (BrokerageUserTypeEnum.SECOND.equals(sourceUserType)) { | |
| 162 | + } else if (Objects.equals(sourceUserLevel, 2)) { | |
| 163 | 163 | fixedPrice = item.getSecondFixedPrice(); |
| 164 | 164 | } else { |
| 165 | - throw new IllegalArgumentException(StrUtil.format("来源用户({}) 不合法", sourceUserType)); | |
| 165 | + throw new IllegalArgumentException(StrUtil.format("用户等级({}) 不合法", sourceUserLevel)); | |
| 166 | 166 | } |
| 167 | 167 | int brokeragePrice = calculatePrice(item.getBasePrice(), brokeragePercent, fixedPrice); |
| 168 | 168 | if (brokeragePrice <= 0) { |
| ... | ... | @@ -172,7 +172,7 @@ public class BrokerageRecordServiceImpl implements BrokerageRecordService { |
| 172 | 172 | // 创建记录实体 |
| 173 | 173 | records.add(BrokerageRecordConvert.INSTANCE.convert(user, bizType, item.getBizId(), |
| 174 | 174 | brokerageFrozenDays, brokeragePrice, unfreezeTime, item.getTitle(), |
| 175 | - item.getSourceUserId(), sourceUserType.getType())); | |
| 175 | + item.getSourceUserId(), sourceUserLevel)); | |
| 176 | 176 | } |
| 177 | 177 | if (CollUtil.isEmpty(records)) { |
| 178 | 178 | return; | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/user/BrokerageUserService.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.service.brokerage.user; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | +import cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils; | |
| 4 | 5 | import cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo.BrokerageUserPageReqVO; |
| 5 | 6 | import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.BrokerageUserDO; |
| 6 | -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageUserTypeEnum; | |
| 7 | 7 | |
| 8 | +import javax.validation.constraints.NotNull; | |
| 9 | +import java.time.LocalDateTime; | |
| 8 | 10 | import java.util.Collection; |
| 9 | 11 | import java.util.List; |
| 10 | 12 | |
| ... | ... | @@ -91,10 +93,24 @@ public interface BrokerageUserService { |
| 91 | 93 | * 获得推广用户数量 |
| 92 | 94 | * |
| 93 | 95 | * @param bindUserId 绑定的推广员编号 |
| 94 | - * @param userType 用户类型 | |
| 96 | + * @param level 推广用户等级 | |
| 95 | 97 | * @return 推广用户数量 |
| 96 | 98 | */ |
| 97 | - Long getBrokerageUserCountByBindUserId(Long bindUserId, BrokerageUserTypeEnum userType); | |
| 99 | + Long getBrokerageUserCountByBindUserId(Long bindUserId, Integer level); | |
| 100 | + | |
| 101 | + /** | |
| 102 | + * 【会员】绑定推广员 | |
| 103 | + * | |
| 104 | + * @param userId 用户编号 | |
| 105 | + * @param bindUserId 推广员编号 | |
| 106 | + * @param registerTime 用户注册时间 | |
| 107 | + * @return 是否绑定 | |
| 108 | + */ | |
| 109 | + default boolean bindBrokerageUser(@NotNull Long userId, @NotNull Long bindUserId, @NotNull LocalDateTime registerTime) { | |
| 110 | + // 注册时间在30秒内的,都算新用户 | |
| 111 | + boolean isNewUser = LocalDateTimeUtils.afterNow(registerTime.minusSeconds(30)); | |
| 112 | + return bindBrokerageUser(userId, bindUserId, isNewUser); | |
| 113 | + } | |
| 98 | 114 | |
| 99 | 115 | /** |
| 100 | 116 | * 【会员】绑定推广员 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/user/BrokerageUserServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.service.brokerage.user; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 3 | 4 | import cn.hutool.core.lang.Assert; |
| 4 | 5 | import cn.hutool.core.util.BooleanUtil; |
| 6 | +import cn.hutool.core.util.ObjectUtil; | |
| 7 | +import cn.hutool.core.util.StrUtil; | |
| 5 | 8 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | 9 | import cn.iocoder.yudao.module.trade.controller.admin.brokerage.user.vo.BrokerageUserPageReqVO; |
| 7 | 10 | import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.user.BrokerageUserDO; |
| ... | ... | @@ -9,17 +12,13 @@ import cn.iocoder.yudao.module.trade.dal.dataobject.config.TradeConfigDO; |
| 9 | 12 | import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.user.BrokerageUserMapper; |
| 10 | 13 | import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageBindModeEnum; |
| 11 | 14 | import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageEnabledConditionEnum; |
| 12 | -import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageUserTypeEnum; | |
| 13 | 15 | import cn.iocoder.yudao.module.trade.service.config.TradeConfigService; |
| 14 | 16 | import org.springframework.stereotype.Service; |
| 15 | 17 | import org.springframework.validation.annotation.Validated; |
| 16 | 18 | |
| 17 | 19 | import javax.annotation.Resource; |
| 18 | 20 | import java.time.LocalDateTime; |
| 19 | -import java.util.Collection; | |
| 20 | -import java.util.List; | |
| 21 | -import java.util.Objects; | |
| 22 | -import java.util.Optional; | |
| 21 | +import java.util.*; | |
| 23 | 22 | |
| 24 | 23 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 25 | 24 | import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; |
| ... | ... | @@ -51,7 +50,8 @@ public class BrokerageUserServiceImpl implements BrokerageUserService { |
| 51 | 50 | |
| 52 | 51 | @Override |
| 53 | 52 | public PageResult<BrokerageUserDO> getBrokerageUserPage(BrokerageUserPageReqVO pageReqVO) { |
| 54 | - return brokerageUserMapper.selectPage(pageReqVO); | |
| 53 | + List<Integer> levels = buildUserQueryLevels(pageReqVO.getBindUserId(), pageReqVO.getLevel()); | |
| 54 | + return brokerageUserMapper.selectPage(pageReqVO, levels); | |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | @Override |
| ... | ... | @@ -66,10 +66,15 @@ public class BrokerageUserServiceImpl implements BrokerageUserService { |
| 66 | 66 | return; |
| 67 | 67 | } |
| 68 | 68 | |
| 69 | + // 绑定关系未发生变化 | |
| 70 | + // TODO @疯狂:这个放到“情况一”之前,貌似也没关系? | |
| 71 | + if (Objects.equals(brokerageUser.getBindUserId(), bindUserId)) { | |
| 72 | + return; | |
| 73 | + } | |
| 74 | + | |
| 69 | 75 | // 情况二:修改推广员 |
| 70 | 76 | validateCanBindUser(brokerageUser, bindUserId); |
| 71 | - brokerageUserMapper.updateById(new BrokerageUserDO().setId(id) | |
| 72 | - .setBindUserId(bindUserId).setBindUserTime(LocalDateTime.now())); | |
| 77 | + brokerageUserMapper.updateById(fillBindUserData(bindUserId, new BrokerageUserDO().setId(id))); | |
| 73 | 78 | } |
| 74 | 79 | |
| 75 | 80 | @Override |
| ... | ... | @@ -132,19 +137,12 @@ public class BrokerageUserServiceImpl implements BrokerageUserService { |
| 132 | 137 | } |
| 133 | 138 | |
| 134 | 139 | @Override |
| 135 | - public Long getBrokerageUserCountByBindUserId(Long bindUserId, BrokerageUserTypeEnum userType) { | |
| 136 | - switch (userType) { | |
| 137 | - case ALL: // TODO @疯狂:ALL 是不是不用搞个枚举,默认为空就是不过滤哈~ | |
| 138 | - Long firstCount = brokerageUserMapper.selectCountByBindUserId(bindUserId); | |
| 139 | - Long secondCount = brokerageUserMapper.selectCountByBindUserIdInBindUserId(bindUserId); | |
| 140 | - return firstCount + secondCount; | |
| 141 | - case FIRST: | |
| 142 | - return brokerageUserMapper.selectCountByBindUserId(bindUserId); | |
| 143 | - case SECOND: | |
| 144 | - return brokerageUserMapper.selectCountByBindUserIdInBindUserId(bindUserId); | |
| 145 | - default: | |
| 146 | - return 0L; | |
| 140 | + public Long getBrokerageUserCountByBindUserId(Long bindUserId, Integer level) { | |
| 141 | + List<Integer> levels = buildUserQueryLevels(bindUserId, level); | |
| 142 | + if (CollUtil.isEmpty(levels)) { | |
| 143 | + return 0L; | |
| 147 | 144 | } |
| 145 | + return brokerageUserMapper.selectCountByBindUserIdAndLevelIn(bindUserId, levels); | |
| 148 | 146 | } |
| 149 | 147 | |
| 150 | 148 | @Override |
| ... | ... | @@ -171,14 +169,30 @@ public class BrokerageUserServiceImpl implements BrokerageUserService { |
| 171 | 169 | brokerageUser.setBrokerageEnabled(true).setBrokerageTime(LocalDateTime.now()); |
| 172 | 170 | } |
| 173 | 171 | brokerageUser.setBindUserId(bindUserId).setBindUserTime(LocalDateTime.now()); |
| 174 | - brokerageUserMapper.insert(brokerageUser); | |
| 172 | + brokerageUserMapper.insert(fillBindUserData(bindUserId, brokerageUser)); | |
| 175 | 173 | } else { |
| 176 | - brokerageUserMapper.updateById(new BrokerageUserDO().setId(userId) | |
| 177 | - .setBindUserId(bindUserId).setBindUserTime(LocalDateTime.now())); | |
| 174 | + brokerageUserMapper.updateById(fillBindUserData(bindUserId, new BrokerageUserDO().setId(userId))); | |
| 178 | 175 | } |
| 179 | 176 | return true; |
| 180 | 177 | } |
| 181 | 178 | |
| 179 | + private BrokerageUserDO fillBindUserData(Long bindUserId, BrokerageUserDO brokerageUser) { | |
| 180 | + BrokerageUserDO bindUser = getBrokerageUser(bindUserId); | |
| 181 | + | |
| 182 | + Integer bindUserLevel = 0; | |
| 183 | + String bindUserPath = ""; | |
| 184 | + if (bindUser != null) { | |
| 185 | + bindUserLevel = ObjectUtil.defaultIfNull(bindUser.getLevel(), 0); | |
| 186 | + bindUserPath = bindUser.getPath(); | |
| 187 | + } | |
| 188 | + | |
| 189 | + String path = StrUtil.isEmpty(bindUserPath) | |
| 190 | + ? String.valueOf(bindUserId) | |
| 191 | + : String.format("%s,%s", bindUserPath, bindUserId); | |
| 192 | + return brokerageUser.setBindUserId(bindUserId).setBindUserTime(LocalDateTime.now()) | |
| 193 | + .setLevel(bindUserLevel + 1).setPath(path); | |
| 194 | + } | |
| 195 | + | |
| 182 | 196 | @Override |
| 183 | 197 | public Boolean getUserBrokerageEnabled(Long userId) { |
| 184 | 198 | // 全局分销功能是否开启 |
| ... | ... | @@ -231,11 +245,30 @@ public class BrokerageUserServiceImpl implements BrokerageUserService { |
| 231 | 245 | throw exception(BROKERAGE_BIND_SELF); |
| 232 | 246 | } |
| 233 | 247 | |
| 234 | - // TODO @疯狂:这块是不是一直查询到根节点,中间不允许出现自己;就是不能形成环。虽然目前是 2 级,但是未来可能会改多级; = = 环的话,就会存在问题哈 | |
| 235 | - // A->B->A:下级不能绑定自己的上级, A->B->C->A可以!! | |
| 236 | - if (Objects.equals(user.getId(), bindUser.getBindUserId())) { | |
| 248 | + // 下级不能绑定自己的上级 | |
| 249 | + if (StrUtil.split(bindUser.getPath(), ",").contains(String.valueOf(user.getId()))) { | |
| 237 | 250 | throw exception(BROKERAGE_BIND_LOOP); |
| 238 | 251 | } |
| 239 | 252 | } |
| 240 | 253 | |
| 254 | + // TODO @芋艿:这个层级,要微信讨论下; | |
| 255 | + private List<Integer> buildUserQueryLevels(Long bindUserId, Integer level) { | |
| 256 | + List<Integer> levels = new ArrayList<>(2); | |
| 257 | + | |
| 258 | + BrokerageUserDO bindUser = getBrokerageUser(bindUserId); | |
| 259 | + if (bindUser == null) { | |
| 260 | + return levels; | |
| 261 | + } | |
| 262 | + | |
| 263 | + if (level == null) { | |
| 264 | + // 默认查两层 | |
| 265 | + levels.add(bindUser.getLevel() + 1); | |
| 266 | + levels.add(bindUser.getLevel() + 2); | |
| 267 | + } else { | |
| 268 | + levels.add(bindUser.getLevel() + level); | |
| 269 | + } | |
| 270 | + return levels; | |
| 271 | + | |
| 272 | + } | |
| 273 | + | |
| 241 | 274 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/withdraw/BrokerageWithdrawService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.service.brokerage.withdraw; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo.BrokerageWithdrawPageReqVO; | |
| 5 | +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.withdraw.BrokerageWithdrawDO; | |
| 6 | +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * 佣金提现 Service 接口 | |
| 10 | + * | |
| 11 | + * @author 芋道源码 | |
| 12 | + */ | |
| 13 | +public interface BrokerageWithdrawService { | |
| 14 | + | |
| 15 | + /** | |
| 16 | + * 审核佣金提现 | |
| 17 | + * | |
| 18 | + * @param id 佣金编号 | |
| 19 | + * @param status 审核状态 | |
| 20 | + * @param auditReason 驳回原因 | |
| 21 | + */ | |
| 22 | + | |
| 23 | + void auditBrokerageWithdraw(Integer id, BrokerageWithdrawStatusEnum status, String auditReason); | |
| 24 | + | |
| 25 | + /** | |
| 26 | + * 获得佣金提现 | |
| 27 | + * | |
| 28 | + * @param id 编号 | |
| 29 | + * @return 佣金提现 | |
| 30 | + */ | |
| 31 | + BrokerageWithdrawDO getBrokerageWithdraw(Integer id); | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * 获得佣金提现分页 | |
| 35 | + * | |
| 36 | + * @param pageReqVO 分页查询 | |
| 37 | + * @return 佣金提现分页 | |
| 38 | + */ | |
| 39 | + PageResult<BrokerageWithdrawDO> getBrokerageWithdrawPage(BrokerageWithdrawPageReqVO pageReqVO); | |
| 40 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/withdraw/BrokerageWithdrawServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.service.brokerage.withdraw; | |
| 2 | + | |
| 3 | +import cn.hutool.core.date.LocalDateTimeUtil; | |
| 4 | +import cn.hutool.core.map.MapUtil; | |
| 5 | +import cn.hutool.core.util.ObjectUtil; | |
| 6 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 7 | +import cn.iocoder.yudao.module.system.api.notify.NotifyMessageSendApi; | |
| 8 | +import cn.iocoder.yudao.module.system.api.notify.dto.NotifySendSingleToUserReqDTO; | |
| 9 | +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo.BrokerageWithdrawPageReqVO; | |
| 10 | +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.withdraw.BrokerageWithdrawDO; | |
| 11 | +import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.withdraw.BrokerageWithdrawMapper; | |
| 12 | +import cn.iocoder.yudao.module.trade.enums.MessageTemplateConstants; | |
| 13 | +import cn.iocoder.yudao.module.trade.enums.brokerage.BrokerageWithdrawStatusEnum; | |
| 14 | +import cn.iocoder.yudao.module.trade.service.brokerage.record.BrokerageRecordService; | |
| 15 | +import org.springframework.stereotype.Service; | |
| 16 | +import org.springframework.transaction.annotation.Transactional; | |
| 17 | +import org.springframework.validation.annotation.Validated; | |
| 18 | + | |
| 19 | +import javax.annotation.Resource; | |
| 20 | +import java.time.LocalDateTime; | |
| 21 | +import java.util.Map; | |
| 22 | + | |
| 23 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 24 | +import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.BROKERAGE_WITHDRAW_NOT_EXISTS; | |
| 25 | +import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING; | |
| 26 | + | |
| 27 | +/** | |
| 28 | + * 佣金提现 Service 实现类 | |
| 29 | + * | |
| 30 | + * @author 芋道源码 | |
| 31 | + */ | |
| 32 | +@Service | |
| 33 | +@Validated | |
| 34 | +public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService { | |
| 35 | + | |
| 36 | + @Resource | |
| 37 | + private BrokerageWithdrawMapper brokerageWithdrawMapper; | |
| 38 | + | |
| 39 | + @Resource | |
| 40 | + private BrokerageRecordService brokerageRecordService; | |
| 41 | + | |
| 42 | + @Resource | |
| 43 | + private NotifyMessageSendApi notifyMessageSendApi; | |
| 44 | + | |
| 45 | + @Override | |
| 46 | + @Transactional(rollbackFor = Exception.class) | |
| 47 | + public void auditBrokerageWithdraw(Integer id, BrokerageWithdrawStatusEnum status, String auditReason) { | |
| 48 | + // 1.1 校验存在 | |
| 49 | + BrokerageWithdrawDO withdraw = validateBrokerageWithdrawExists(id); | |
| 50 | + // 1.2 校验状态为审核中 | |
| 51 | + if (ObjectUtil.notEqual(BrokerageWithdrawStatusEnum.AUDITING.getStatus(), withdraw.getStatus())) { | |
| 52 | + throw exception(BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING); | |
| 53 | + } | |
| 54 | + | |
| 55 | + // 2. 更新 | |
| 56 | + BrokerageWithdrawDO updateObj = new BrokerageWithdrawDO() | |
| 57 | + .setStatus(status.getStatus()) | |
| 58 | + .setAuditReason(auditReason) | |
| 59 | + .setAuditTime(LocalDateTime.now()); | |
| 60 | + int rows = brokerageWithdrawMapper.updateByIdAndStatus(id, BrokerageWithdrawStatusEnum.AUDITING.getStatus(), updateObj); | |
| 61 | + if (rows == 0) { | |
| 62 | + throw exception(BROKERAGE_WITHDRAW_STATUS_NOT_AUDITING); | |
| 63 | + } | |
| 64 | + | |
| 65 | + // 3. 驳回时需要退还用户佣金 | |
| 66 | + String templateCode = MessageTemplateConstants.BROKERAGE_WITHDRAW_AUDIT_APPROVE; | |
| 67 | + if (BrokerageWithdrawStatusEnum.AUDIT_FAIL.equals(status)) { | |
| 68 | + templateCode = MessageTemplateConstants.BROKERAGE_WITHDRAW_AUDIT_REJECT; | |
| 69 | + | |
| 70 | + // todo @owen | |
| 71 | +// brokerageRecordService.addBrokerage(withdraw.getUserId(), BrokerageRecordBizTypeEnum.WITHDRAW, withdraw.getPrice(), ""); | |
| 72 | + } | |
| 73 | + | |
| 74 | + // 4. 通知用户 | |
| 75 | + Map<String, Object> templateParams = MapUtil.<String, Object>builder() | |
| 76 | + .put("createTime", LocalDateTimeUtil.formatNormal(withdraw.getCreateTime())) | |
| 77 | + .put("price", String.format("%.2f", withdraw.getPrice() / 100d)) | |
| 78 | + .put("reason", withdraw.getAuditReason()) | |
| 79 | + .build(); | |
| 80 | + NotifySendSingleToUserReqDTO reqDTO = new NotifySendSingleToUserReqDTO() | |
| 81 | + .setUserId(withdraw.getUserId()) | |
| 82 | + .setTemplateCode(templateCode).setTemplateParams(templateParams); | |
| 83 | + notifyMessageSendApi.sendSingleMessageToMember(reqDTO); | |
| 84 | + } | |
| 85 | + | |
| 86 | + private BrokerageWithdrawDO validateBrokerageWithdrawExists(Integer id) { | |
| 87 | + BrokerageWithdrawDO withdraw = brokerageWithdrawMapper.selectById(id); | |
| 88 | + if (withdraw == null) { | |
| 89 | + throw exception(BROKERAGE_WITHDRAW_NOT_EXISTS); | |
| 90 | + } | |
| 91 | + return withdraw; | |
| 92 | + } | |
| 93 | + | |
| 94 | + @Override | |
| 95 | + public BrokerageWithdrawDO getBrokerageWithdraw(Integer id) { | |
| 96 | + return brokerageWithdrawMapper.selectById(id); | |
| 97 | + } | |
| 98 | + | |
| 99 | + @Override | |
| 100 | + public PageResult<BrokerageWithdrawDO> getBrokerageWithdrawPage(BrokerageWithdrawPageReqVO pageReqVO) { | |
| 101 | + return brokerageWithdrawMapper.selectPage(pageReqVO); | |
| 102 | + } | |
| 103 | + | |
| 104 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java
| ... | ... | @@ -12,6 +12,8 @@ import cn.iocoder.yudao.module.member.api.address.AddressApi; |
| 12 | 12 | import cn.iocoder.yudao.module.member.api.address.dto.AddressRespDTO; |
| 13 | 13 | import cn.iocoder.yudao.module.member.api.level.MemberLevelApi; |
| 14 | 14 | import cn.iocoder.yudao.module.member.api.point.MemberPointApi; |
| 15 | +import cn.iocoder.yudao.module.member.api.user.MemberUserApi; | |
| 16 | +import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; | |
| 15 | 17 | import cn.iocoder.yudao.module.member.enums.MemberExperienceBizTypeEnum; |
| 16 | 18 | import cn.iocoder.yudao.module.member.enums.point.MemberPointBizTypeEnum; |
| 17 | 19 | import cn.iocoder.yudao.module.pay.api.order.PayOrderApi; |
| ... | ... | @@ -115,6 +117,8 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 115 | 117 | @Resource |
| 116 | 118 | private BargainRecordApi bargainRecordApi; |
| 117 | 119 | @Resource |
| 120 | + private MemberUserApi memberUserApi; | |
| 121 | + @Resource | |
| 118 | 122 | private MemberLevelApi memberLevelApi; |
| 119 | 123 | @Resource |
| 120 | 124 | private MemberPointApi memberPointApi; |
| ... | ... | @@ -782,9 +786,12 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 782 | 786 | |
| 783 | 787 | @Async |
| 784 | 788 | protected void addBrokerageAsync(Long userId, Long orderId) { |
| 789 | + MemberUserRespDTO user = memberUserApi.getUser(userId); | |
| 790 | + Assert.notNull(user); | |
| 791 | + | |
| 785 | 792 | List<TradeOrderItemDO> orderItems = tradeOrderItemMapper.selectListByOrderId(orderId); |
| 786 | 793 | List<BrokerageAddReqBO> list = convertList(orderItems, |
| 787 | - item -> TradeOrderConvert.INSTANCE.convert(item, productSkuApi.getSku(item.getSkuId()))); | |
| 794 | + item -> TradeOrderConvert.INSTANCE.convert(user, item, productSkuApi.getSku(item.getSkuId()))); | |
| 788 | 795 | brokerageRecordService.addBrokerage(userId, BrokerageRecordBizTypeEnum.ORDER, list); |
| 789 | 796 | } |
| 790 | 797 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/bo/TradeBeforeOrderCreateReqBO.java
yudao-module-mall/yudao-module-trade-biz/src/test/java/cn/iocoder/yudao/module/trade/service/withdraw/BrokerageWithdrawServiceImplTest.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.service.withdraw; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | |
| 4 | +import cn.iocoder.yudao.framework.test.core.ut.BaseDbUnitTest; | |
| 5 | +import cn.iocoder.yudao.module.trade.controller.admin.brokerage.withdraw.vo.BrokerageWithdrawPageReqVO; | |
| 6 | +import cn.iocoder.yudao.module.trade.dal.dataobject.brokerage.withdraw.BrokerageWithdrawDO; | |
| 7 | +import cn.iocoder.yudao.module.trade.dal.mysql.brokerage.withdraw.BrokerageWithdrawMapper; | |
| 8 | +import cn.iocoder.yudao.module.trade.service.brokerage.withdraw.BrokerageWithdrawServiceImpl; | |
| 9 | +import org.junit.jupiter.api.Disabled; | |
| 10 | +import org.junit.jupiter.api.Test; | |
| 11 | +import org.springframework.context.annotation.Import; | |
| 12 | + | |
| 13 | +import javax.annotation.Resource; | |
| 14 | + | |
| 15 | +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.buildBetweenTime; | |
| 16 | +import static cn.iocoder.yudao.framework.common.util.object.ObjectUtils.cloneIgnoreId; | |
| 17 | +import static cn.iocoder.yudao.framework.test.core.util.AssertUtils.assertPojoEquals; | |
| 18 | +import static cn.iocoder.yudao.framework.test.core.util.RandomUtils.randomPojo; | |
| 19 | +import static org.junit.jupiter.api.Assertions.assertEquals; | |
| 20 | + | |
| 21 | +// TODO 芋艿:后续 review | |
| 22 | +/** | |
| 23 | + * {@link BrokerageWithdrawServiceImpl} 的单元测试类 | |
| 24 | + * | |
| 25 | + * @author 芋道源码 | |
| 26 | + */ | |
| 27 | +@Import(BrokerageWithdrawServiceImpl.class) | |
| 28 | +public class BrokerageWithdrawServiceImplTest extends BaseDbUnitTest { | |
| 29 | + | |
| 30 | + @Resource | |
| 31 | + private BrokerageWithdrawServiceImpl brokerageWithdrawService; | |
| 32 | + | |
| 33 | + @Resource | |
| 34 | + private BrokerageWithdrawMapper brokerageWithdrawMapper; | |
| 35 | + | |
| 36 | + @Test | |
| 37 | + @Disabled // TODO 请修改 null 为需要的值,然后删除 @Disabled 注解 | |
| 38 | + public void testGetBrokerageWithdrawPage() { | |
| 39 | + // mock 数据 | |
| 40 | + BrokerageWithdrawDO dbBrokerageWithdraw = randomPojo(BrokerageWithdrawDO.class, o -> { // 等会查询到 | |
| 41 | + o.setUserId(null); | |
| 42 | + o.setType(null); | |
| 43 | + o.setName(null); | |
| 44 | + o.setAccountNo(null); | |
| 45 | + o.setBankName(null); | |
| 46 | + o.setStatus(null); | |
| 47 | + o.setCreateTime(null); | |
| 48 | + }); | |
| 49 | + brokerageWithdrawMapper.insert(dbBrokerageWithdraw); | |
| 50 | + // 测试 userId 不匹配 | |
| 51 | + brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setUserId(null))); | |
| 52 | + // 测试 type 不匹配 | |
| 53 | + brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setType(null))); | |
| 54 | + // 测试 name 不匹配 | |
| 55 | + brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setName(null))); | |
| 56 | + // 测试 accountNo 不匹配 | |
| 57 | + brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setAccountNo(null))); | |
| 58 | + // 测试 bankName 不匹配 | |
| 59 | + brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setBankName(null))); | |
| 60 | + // 测试 status 不匹配 | |
| 61 | + brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setStatus(null))); | |
| 62 | + // 测试 auditReason 不匹配 | |
| 63 | + brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setAuditReason(null))); | |
| 64 | + // 测试 auditTime 不匹配 | |
| 65 | + brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setAuditTime(null))); | |
| 66 | + // 测试 remark 不匹配 | |
| 67 | + brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setRemark(null))); | |
| 68 | + // 测试 createTime 不匹配 | |
| 69 | + brokerageWithdrawMapper.insert(cloneIgnoreId(dbBrokerageWithdraw, o -> o.setCreateTime(null))); | |
| 70 | + // 准备参数 | |
| 71 | + BrokerageWithdrawPageReqVO reqVO = new BrokerageWithdrawPageReqVO(); | |
| 72 | + reqVO.setUserId(null); | |
| 73 | + reqVO.setType(null); | |
| 74 | + reqVO.setName(null); | |
| 75 | + reqVO.setAccountNo(null); | |
| 76 | + reqVO.setBankName(null); | |
| 77 | + reqVO.setStatus(null); | |
| 78 | + reqVO.setCreateTime(buildBetweenTime(2023, 2, 1, 2023, 2, 28)); | |
| 79 | + | |
| 80 | + // 调用 | |
| 81 | + PageResult<BrokerageWithdrawDO> pageResult = brokerageWithdrawService.getBrokerageWithdrawPage(reqVO); | |
| 82 | + // 断言 | |
| 83 | + assertEquals(1, pageResult.getTotal()); | |
| 84 | + assertEquals(1, pageResult.getList().size()); | |
| 85 | + assertPojoEquals(dbBrokerageWithdraw, pageResult.getList().get(0)); | |
| 86 | + } | |
| 87 | + | |
| 88 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/clean.sql
yudao-module-mall/yudao-module-trade-biz/src/test/resources/sql/create_tables.sql
| ... | ... | @@ -163,4 +163,29 @@ CREATE TABLE IF NOT EXISTS "trade_brokerage_record" |
| 163 | 163 | "deleted" bit NOT NULL DEFAULT FALSE, |
| 164 | 164 | "tenant_id" bigint not null default '0', |
| 165 | 165 | PRIMARY KEY ("id") |
| 166 | -) COMMENT '佣金记录'; | |
| 167 | 166 | \ No newline at end of file |
| 167 | +) COMMENT '佣金记录'; | |
| 168 | +CREATE TABLE IF NOT EXISTS "trade_brokerage_withdraw" | |
| 169 | +( | |
| 170 | + "id" int NOT NULL GENERATED BY DEFAULT AS IDENTITY, | |
| 171 | + "user_id" bigint NOT NULL, | |
| 172 | + "price" int NOT NULL, | |
| 173 | + "fee_price" int NOT NULL, | |
| 174 | + "total_price" int NOT NULL, | |
| 175 | + "type" varchar NOT NULL, | |
| 176 | + "name" varchar, | |
| 177 | + "account_no" varchar, | |
| 178 | + "bank_name" varchar, | |
| 179 | + "bank_address" varchar, | |
| 180 | + "account_qr_code_url" varchar, | |
| 181 | + "status" varchar NOT NULL, | |
| 182 | + "audit_reason" varchar, | |
| 183 | + "audit_time" varchar, | |
| 184 | + "remark" varchar, | |
| 185 | + "creator" varchar DEFAULT '', | |
| 186 | + "create_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, | |
| 187 | + "updater" varchar DEFAULT '', | |
| 188 | + "update_time" datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, | |
| 189 | + "deleted" bit NOT NULL DEFAULT FALSE, | |
| 190 | + "tenant_id" bigint not null default '0',目 | |
| 191 | + PRIMARY KEY ("id") | |
| 192 | +) COMMENT '佣金提现'; | |
| 168 | 193 | \ No newline at end of file | ... | ... |
yudao-server/src/main/resources/application-local.yaml
| ... | ... | @@ -44,31 +44,31 @@ spring: |
| 44 | 44 | primary: master |
| 45 | 45 | datasource: |
| 46 | 46 | master: |
| 47 | - name: mall | |
| 48 | - url: jdbc:mysql://10.211.55.5:3308/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 | |
| 47 | + name: ruoyi-vue-pro | |
| 48 | + url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 | |
| 49 | 49 | # url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例 |
| 50 | 50 | # url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.master.name} # PostgreSQL 连接的示例 |
| 51 | 51 | # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 |
| 52 | 52 | # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.master.name} # SQLServer 连接的示例 |
| 53 | 53 | username: root |
| 54 | - password: 1qaz!QAZ | |
| 54 | + password: 123456 | |
| 55 | 55 | # username: sa |
| 56 | 56 | # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W |
| 57 | 57 | slave: # 模拟从库,可根据自己需要修改 |
| 58 | - name: mall | |
| 59 | - url: jdbc:mysql://10.211.55.5:3308/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 | |
| 58 | + name: ruoyi-vue-pro | |
| 59 | + url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 | |
| 60 | 60 | # url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例 |
| 61 | 61 | # url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.slave.name} # PostgreSQL 连接的示例 |
| 62 | 62 | # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 |
| 63 | 63 | # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.slave.name} # SQLServer 连接的示例 |
| 64 | 64 | username: root |
| 65 | - password: 1qaz!QAZ | |
| 65 | + password: 123456 | |
| 66 | 66 | # username: sa |
| 67 | 67 | # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W |
| 68 | 68 | |
| 69 | 69 | # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 |
| 70 | 70 | redis: |
| 71 | - host: 10.211.55.5 # 地址 | |
| 71 | + host: 127.0.0.1 # 地址 | |
| 72 | 72 | port: 6379 # 端口 |
| 73 | 73 | database: 0 # 数据库索引 |
| 74 | 74 | # password: dev # 密码,建议生产环境开启 | ... | ... |