liang
parent
dda1842b69
commit
9dd5d11e80
|
@ -0,0 +1,16 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Encoding">
|
||||
<file url="file://$PROJECT_DIR$/mall_auth/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/mall_common/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/mall_gateway/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/mall_modules/mall_back/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/mall_modules/mall_client/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/mall_modules/mall_server/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/mall_modules/mall_system/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/mall_modules/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/mall_modules/src/main/resources" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,13 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
<option name="workspaceImportForciblyTurnedOn" value="true" />
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="17" project-jdk-type="JavaSDK" />
|
||||
</project>
|
|
@ -0,0 +1,124 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,11 @@
|
|||
package com.mall;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class ColonelApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ColonelApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,78 @@
|
|||
package com.mall.config;
|
||||
|
||||
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* xxl-job config
|
||||
*
|
||||
* @author xuxueli 2017-04-28
|
||||
*/
|
||||
@Configuration
|
||||
public class XxlJobConfig {
|
||||
private Logger logger = LoggerFactory.getLogger(XxlJobConfig.class);
|
||||
|
||||
@Value("${xxl.job.admin.addresses}")
|
||||
private String adminAddresses;
|
||||
|
||||
@Value("${xxl.job.accessToken}")
|
||||
private String accessToken;
|
||||
|
||||
@Value("${xxl.job.executor.appname}")
|
||||
private String appname;
|
||||
|
||||
@Value("${xxl.job.executor.address}")
|
||||
private String address;
|
||||
|
||||
@Value("${xxl.job.executor.ip}")
|
||||
private String ip;
|
||||
|
||||
@Value("${xxl.job.executor.port}")
|
||||
private int port;
|
||||
|
||||
@Value("${xxl.job.executor.logpath}")
|
||||
private String logPath;
|
||||
|
||||
@Value("${xxl.job.executor.logretentiondays}")
|
||||
private int logRetentionDays;
|
||||
|
||||
|
||||
@Bean
|
||||
public XxlJobSpringExecutor xxlJobExecutor() {
|
||||
logger.info(">>>>>>>>>>> xxl-job config init.");
|
||||
XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
|
||||
xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
|
||||
xxlJobSpringExecutor.setAppname(appname);
|
||||
xxlJobSpringExecutor.setAddress(address);
|
||||
xxlJobSpringExecutor.setIp(ip);
|
||||
xxlJobSpringExecutor.setPort(port);
|
||||
xxlJobSpringExecutor.setAccessToken(accessToken);
|
||||
xxlJobSpringExecutor.setLogPath(logPath);
|
||||
xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
|
||||
|
||||
return xxlJobSpringExecutor;
|
||||
}
|
||||
|
||||
/**
|
||||
* 针对多网卡、容器内部署等情况,可借助 "spring-cloud-commons" 提供的 "InetUtils" 组件灵活定制注册IP;
|
||||
*
|
||||
* 1、引入依赖:
|
||||
* <dependency>
|
||||
* <groupId>org.springframework.cloud</groupId>
|
||||
* <artifactId>spring-cloud-commons</artifactId>
|
||||
* <version>${version}</version>
|
||||
* </dependency>
|
||||
*
|
||||
* 2、配置文件,或者容器启动变量
|
||||
* spring.cloud.inetutils.preferred-networks: 'xxx.xxx.xxx.'
|
||||
*
|
||||
* 3、获取IP
|
||||
* String ip_ = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
|
||||
*/
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.mall.controller;
|
||||
|
||||
import com.mall.common.result.Result;
|
||||
import com.mall.domain.Colonel;
|
||||
import com.mall.service.ServiceColonel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RestController
|
||||
public class ColonelController {
|
||||
|
||||
@Autowired
|
||||
private ServiceColonel serviceColonel;
|
||||
|
||||
@PostMapping("/add/Colonel")
|
||||
public Result addColonel(Colonel colonel){
|
||||
Result result= serviceColonel.addColonel(colonel);
|
||||
return Result.success(result);
|
||||
}
|
||||
|
||||
@PostMapping("/update/Colonel")
|
||||
public Result updateColonel(Colonel colonel){
|
||||
Result result= serviceColonel.updateColonel(colonel);
|
||||
return Result.success(result);
|
||||
}
|
||||
|
||||
@PostMapping("/delete/Colonel")
|
||||
public Result deleteColonel(Integer colonelId){
|
||||
Result result= serviceColonel.deleteColonel(colonelId);
|
||||
return Result.success(result);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,74 @@
|
|||
package com.mall.domain;
|
||||
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 团长表
|
||||
* */
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Colonel {
|
||||
|
||||
/**
|
||||
* id
|
||||
* */
|
||||
private Integer colonelId;
|
||||
/**
|
||||
* 用户id
|
||||
* */
|
||||
private Integer userId;
|
||||
/**
|
||||
* 公告/标题
|
||||
* */
|
||||
private String colonelTitle;
|
||||
/**
|
||||
* 开始时间
|
||||
* */
|
||||
private Date colonelStartTime;
|
||||
/**
|
||||
* 结束时间
|
||||
* */
|
||||
private Date colonelSendTime;
|
||||
/**
|
||||
* 团长申请海报
|
||||
* */
|
||||
private String colonelOneTmage;
|
||||
/**
|
||||
* 休市海报
|
||||
* */
|
||||
private String colonelTowTmage;
|
||||
/**
|
||||
* 供应商申请海报
|
||||
* */
|
||||
private String colonelThreeTmage;
|
||||
/**
|
||||
* 自定义团长名称
|
||||
* */
|
||||
private String colonelName;
|
||||
/**
|
||||
* 覆盖范围/公里
|
||||
* */
|
||||
private Integer colonelRadius;
|
||||
/**
|
||||
* 提现手续费/%
|
||||
* */
|
||||
private Double handlingCharge;
|
||||
/**
|
||||
* 最低提现金额/元
|
||||
* */
|
||||
private BigDecimal withdrawalAmount;
|
||||
/**
|
||||
* 团长佣金
|
||||
* */
|
||||
private Double colonelBrokerage;
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.mall.domain;
|
||||
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.Data;
|
||||
import org.bouncycastle.jcajce.provider.symmetric.SM4;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 团长流水
|
||||
* */
|
||||
@Data
|
||||
public class RunningWater {
|
||||
|
||||
/**
|
||||
* 团长流水id
|
||||
* */
|
||||
private Integer waterId;
|
||||
/**
|
||||
* 头像
|
||||
* */
|
||||
private String avatar;
|
||||
/**
|
||||
* 团长属性id
|
||||
* */
|
||||
private Integer colonelId;
|
||||
/**
|
||||
* 佣金类型
|
||||
* */
|
||||
private String commissionType;
|
||||
/**
|
||||
* 所得佣金
|
||||
* */
|
||||
private BigDecimal commissionEarned;
|
||||
/**
|
||||
* 状态
|
||||
* */
|
||||
private Integer waterStasus;
|
||||
/**
|
||||
* 结束时间
|
||||
* */
|
||||
private Date stopTime;
|
||||
/**
|
||||
* 创建时间
|
||||
* */
|
||||
private Integer waterStasusOne;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.mall.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mall.domain.Colonel;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface ColonelMapper extends BaseMapper<Colonel>{
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.mall.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mall.common.result.Result;
|
||||
import com.mall.domain.Colonel;
|
||||
|
||||
|
||||
public interface ServiceColonel extends IService<Colonel> {
|
||||
|
||||
|
||||
Result addColonel(Colonel colonel);
|
||||
|
||||
Result updateColonel(Colonel colonel);
|
||||
|
||||
Result deleteColonel(Integer colonelId);
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package com.mall.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mall.common.result.Result;
|
||||
import com.mall.domain.Colonel;
|
||||
import com.mall.mapper.ColonelMapper;
|
||||
import com.mall.service.ServiceColonel;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class ServiceColonelimpl extends ServiceImpl<ColonelMapper, Colonel>
|
||||
implements ServiceColonel {
|
||||
@Autowired
|
||||
private ColonelMapper colonelMapper;
|
||||
@Override
|
||||
public Result addColonel(Colonel colonel) {
|
||||
if (colonel.getColonelId() != null){
|
||||
return Result.error("添加失败");
|
||||
}
|
||||
boolean save = this.save(colonel);
|
||||
return Result.success(save);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result updateColonel(Colonel colonel) {
|
||||
if (colonel.getColonelId() == null){
|
||||
return Result.error("修改失败");
|
||||
}
|
||||
boolean update = this.updateById(colonel);
|
||||
return Result.success(update+"修改成功");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result deleteColonel(Integer colonelId) {
|
||||
if (colonelId == null){
|
||||
return Result.error("删除失败");
|
||||
}
|
||||
boolean delect = this.removeById(colonelId);
|
||||
return Result.success(delect+"删除成功");
|
||||
}
|
||||
|
||||
}
|
|
@ -26,4 +26,22 @@ spring:
|
|||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
# xxl-job admin address list, such as "http://address" or "http://address01,http://address02"
|
||||
xxl:
|
||||
job:
|
||||
admin:
|
||||
addresses: http://127.0.0.1:8080/xxl-job-admin
|
||||
|
||||
# xxl-job, access token
|
||||
accessToken: gtt_token
|
||||
|
||||
# xxl-job executor appname
|
||||
executor:
|
||||
appname: xxl-job-executor-sample
|
||||
address:
|
||||
server-info:
|
||||
ip:
|
||||
port: 9999
|
||||
log-path: /data/applogs/xxl-job/jobhandler
|
||||
log-retention-days: 30
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9004
|
||||
# Spring
|
||||
spring:
|
||||
main:
|
||||
allow-circular-references: true
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
||||
application:
|
||||
# 应用名称
|
||||
name: czk-back
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 42.192.106.69:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 42.192.106.69:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||
# xxl-job admin address list, such as "http://address" or "http://address01,http://address02"
|
||||
xxl:
|
||||
job:
|
||||
admin:
|
||||
addresses: http://127.0.0.1:8080/xxl-job-admin
|
||||
|
||||
# xxl-job, access token
|
||||
accessToken: gtt_token
|
||||
|
||||
# xxl-job executor appname
|
||||
executor:
|
||||
appname: xxl-job-executor-sample
|
||||
address:
|
||||
server-info:
|
||||
ip:
|
||||
port: 9999
|
||||
log-path: /data/applogs/xxl-job/jobhandler
|
||||
log-retention-days: 30
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -0,0 +1,13 @@
|
|||
package com.mall;
|
||||
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
|
||||
@SpringBootApplication
|
||||
public class CllentApplication {
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(CllentApplication.class, args);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,250 @@
|
|||
package com.mall.config;
|
||||
|
||||
import org.apache.tomcat.util.codec.binary.Base64;
|
||||
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.Key;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.security.spec.AlgorithmParameterSpec;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.CipherInputStream;
|
||||
import javax.crypto.CipherOutputStream;
|
||||
import javax.crypto.KeyGenerator;
|
||||
import javax.crypto.spec.IvParameterSpec;
|
||||
|
||||
/**
|
||||
* DES加密算法工具类
|
||||
*/
|
||||
public class DesUtil {
|
||||
|
||||
/**
|
||||
* CFB
|
||||
*/
|
||||
public static final String CFB = "CFB";
|
||||
|
||||
/**
|
||||
* OFB
|
||||
*/
|
||||
public static final String OFB = "OFB";
|
||||
|
||||
/**
|
||||
* CBC
|
||||
*/
|
||||
public static final String CBC = "CBC";
|
||||
|
||||
/**
|
||||
* iv向量
|
||||
*/
|
||||
private static final byte[] DESIV = {(byte) 0xCE, (byte) 0x35, (byte) 0x5,
|
||||
(byte) 0xD, (byte) 0x98, (byte) 0x91, (byte) 0x8, (byte) 0xA};
|
||||
|
||||
/**
|
||||
* AlgorithmParameterSpec
|
||||
*/
|
||||
private static AlgorithmParameterSpec IV = null;
|
||||
|
||||
/**
|
||||
* SHA1PRNG
|
||||
*/
|
||||
private static final String SHA1PRNG = "SHA1PRNG";
|
||||
|
||||
/**
|
||||
* DES默认模式
|
||||
*/
|
||||
private static final String DES = "DES";
|
||||
|
||||
/**
|
||||
* CBC加密模式
|
||||
*/
|
||||
private static final String DES_CBC_PKCS5PADDING = "DES/CBC/PKCS5Padding";
|
||||
|
||||
/**
|
||||
* OFB加密模式
|
||||
*/
|
||||
private static final String DES_OFB_PKCS5PADDING = "DES/OFB/PKCS5Padding";
|
||||
|
||||
/**
|
||||
* CFB加密模式
|
||||
*/
|
||||
private static final String DES_CFB_PKCS5_PADDING = "DES/CFB/PKCS5Padding";
|
||||
|
||||
/**
|
||||
* 加密模式
|
||||
*/
|
||||
private static final int ENCRYPT_MODE = 1;
|
||||
|
||||
/**
|
||||
* 解密模式
|
||||
*/
|
||||
private static final int DECRYPT_MODE = 2;
|
||||
|
||||
/**
|
||||
* 密钥
|
||||
*/
|
||||
private Key key;
|
||||
|
||||
public void DesUtil(String str) {
|
||||
getKey(str);
|
||||
}
|
||||
|
||||
public Key getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(Key key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过密钥获得key
|
||||
*
|
||||
* @param secretKey 密钥
|
||||
*/
|
||||
public void getKey(String secretKey) {
|
||||
try {
|
||||
SecureRandom secureRandom = SecureRandom.getInstance(SHA1PRNG);
|
||||
secureRandom.setSeed(secretKey.getBytes());
|
||||
KeyGenerator generator;
|
||||
try {
|
||||
generator = KeyGenerator.getInstance(DES);
|
||||
generator.init(secureRandom);
|
||||
IV = new IvParameterSpec(DESIV);
|
||||
this.key = generator.generateKey();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException("Error in getKey(String secretKey), Cause: " + e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串des加密
|
||||
*
|
||||
* @param data 需要加密的字符串
|
||||
* @param encryptType 加密模式 (ECB/CBC/OFB/CFB)
|
||||
* @return 加密结果
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
public String encrypt(String data, String encryptType) throws Exception {
|
||||
Cipher cipher = getPattern(encryptType, ENCRYPT_MODE);
|
||||
byte[] pasByte = cipher.doFinal(data.getBytes(StandardCharsets.UTF_8));
|
||||
return Base64.encodeBase64String(pasByte);
|
||||
}
|
||||
|
||||
/**
|
||||
* 字符串des解密
|
||||
*
|
||||
* @param data 需要解密的字符串
|
||||
* @param decryptType 解密模式 (ECB/CBC/OFB/CFB)
|
||||
* @return 解密结果
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
public String decrypt(String data, String decryptType) throws Exception {
|
||||
Cipher cipher = getPattern(decryptType, DECRYPT_MODE);
|
||||
byte[] pasByte = cipher.doFinal(Base64.decodeBase64(data));
|
||||
return new String(pasByte, StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化cipher
|
||||
*
|
||||
* @param type 加密/解密模式 (ECB/CBC/OFB/CFB)
|
||||
* @param cipherMode cipher工作模式 1:加密; 2:解密
|
||||
* @return cipher
|
||||
* @throws Exception 异常
|
||||
*/
|
||||
private Cipher getPattern(String type, int cipherMode) throws Exception {
|
||||
Cipher cipher;
|
||||
switch (type) {
|
||||
case CBC:
|
||||
cipher = Cipher.getInstance(DES_CBC_PKCS5PADDING);
|
||||
cipher.init(cipherMode, key, IV);
|
||||
break;
|
||||
case OFB:
|
||||
cipher = Cipher.getInstance(DES_OFB_PKCS5PADDING);
|
||||
cipher.init(cipherMode, key, IV);
|
||||
break;
|
||||
case CFB:
|
||||
cipher = Cipher.getInstance(DES_CFB_PKCS5_PADDING);
|
||||
cipher.init(cipherMode, key, IV);
|
||||
break;
|
||||
default:
|
||||
cipher = Cipher.getInstance(DES);
|
||||
cipher.init(cipherMode, key);
|
||||
break;
|
||||
}
|
||||
return cipher;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件 file 进行加密并保存目标文件 destFile 中
|
||||
*
|
||||
* @param file 要加密的文件 如 c:/test/file.txt
|
||||
* @param destFile 加密后存放的文件名 如 c:/ 加密后文件 .txt
|
||||
* @param encryptType 加密模式 (ECB/CBC/OFB/CFB)
|
||||
* @return 加密结果 0:异常 1:加密成功; 5:未找到需要加密的文件
|
||||
*/
|
||||
public int encryptFile(String file, String destFile, String encryptType) {
|
||||
int result = 0;
|
||||
try {
|
||||
Cipher cipher = getPattern(encryptType, ENCRYPT_MODE);
|
||||
InputStream is = new FileInputStream(file);
|
||||
OutputStream out = new FileOutputStream(destFile);
|
||||
CipherInputStream cis = new CipherInputStream(is, cipher);
|
||||
byte[] buffer = new byte[1024];
|
||||
int r;
|
||||
while ((r = cis.read(buffer)) > 0) {
|
||||
out.write(buffer, 0, r);
|
||||
}
|
||||
cis.close();
|
||||
is.close();
|
||||
out.close();
|
||||
result = 1;
|
||||
} catch (FileNotFoundException e) {
|
||||
result = 5;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文件 file 进行解密并保存目标文件 destFile 中
|
||||
*
|
||||
* @param file 要解密的文件 如 c:/test/file.txt
|
||||
* @param destFile 解密后存放的文件名 如 c:/ 解密后文件 .txt
|
||||
* @param decryptType 解密模式 (ECB/CBC/OFB/CFB)
|
||||
* @return 解密结果 0:解密异常;1:解密正常;5:未找到需要解密的文件
|
||||
*/
|
||||
public int decryptFile(String file, String destFile, String decryptType) {
|
||||
int result = 0;
|
||||
try {
|
||||
Cipher cipher = getPattern(decryptType, DECRYPT_MODE);
|
||||
InputStream is = new FileInputStream(file);
|
||||
OutputStream out = new FileOutputStream(destFile);
|
||||
CipherOutputStream cos = new CipherOutputStream(out, cipher);
|
||||
byte[] buffer = new byte[1024];
|
||||
int r;
|
||||
while ((r = is.read(buffer)) >= 0) {
|
||||
cos.write(buffer, 0, r);
|
||||
}
|
||||
cos.close();
|
||||
out.close();
|
||||
is.close();
|
||||
result = 1;
|
||||
} catch (FileNotFoundException e) {
|
||||
result = 5;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,158 @@
|
|||
package com.mall.config;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @author ChenYanbing
|
||||
* @title: UniqueOrderGenerate
|
||||
* @projectName tencent-demo
|
||||
* @description: TODO
|
||||
* @date 2019/8/19:39
|
||||
*/
|
||||
|
||||
/**
|
||||
* 雪花算法
|
||||
*
|
||||
* Twitter_Snowflake<br>
|
||||
* SnowFlake的结构如下(每部分用-分开):<br>
|
||||
* 0 - 0000000000 0000000000 0000000000 0000000000 0 - 00000 - 00000 - 000000000000 <br>
|
||||
* 1位标识,由于long基本类型在Java中是带符号的,最高位是符号位,正数是0,负数是1,所以id一般是正数,最高位是0<br>
|
||||
* 41位时间截(毫秒级),注意,41位时间截不是存储当前时间的时间截,而是存储时间截的差值(当前时间截 - 开始时间截)
|
||||
* 得到的值),这里的的开始时间截,一般是我们的id生成器开始使用的时间,由我们程序来指定的(如下下面程序IdWorker类的startTime属性)。41位的时间截,可以使用69年,年T = (1L << 41) / (1000L * 60 * 60 * 24 * 365) = 69<br>
|
||||
* 10位的数据机器位,可以部署在1024个节点,包括5位datacenterId和5位workerId<br>
|
||||
* 12位序列,毫秒内的计数,12位的计数顺序号支持每个节点每毫秒(同一机器,同一时间截)产生4096个ID序号<br>
|
||||
* 加起来刚好64位,为一个Long型。<br>
|
||||
* SnowFlake的优点是,整体上按照时间自增排序,并且整个分布式系统内不会产生ID碰撞(由数据中心ID和机器ID作区分),并且效率较高,经测试,SnowFlake每秒能够产生26万ID左右。
|
||||
*/
|
||||
public class SnowFlakeUtil {
|
||||
// ==============================Fields===========================================
|
||||
/** 开始时间截 (2019-08-01) */
|
||||
|
||||
private final long twepoch = 1564625329000L;
|
||||
|
||||
/** 机器id所占的位数 */
|
||||
private final long workerIdBits = 5L;
|
||||
|
||||
/** 数据标识id所占的位数 */
|
||||
private final long datacenterIdBits = 5L;
|
||||
|
||||
/** 支持的最大机器id,结果是31 (这个移位算法可以很快的计算出几位二进制数所能表示的最大十进制数) */
|
||||
private final long maxWorkerId = -1L ^ (-1L << workerIdBits);
|
||||
|
||||
/** 支持的最大数据标识id,结果是31 */
|
||||
private final long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);
|
||||
|
||||
/** 序列在id中占的位数 */
|
||||
private final long sequenceBits = 12L;
|
||||
|
||||
/** 机器ID向左移12位 */
|
||||
private final long workerIdShift = sequenceBits;
|
||||
|
||||
/** 数据标识id向左移17位(12+5) */
|
||||
private final long datacenterIdShift = sequenceBits + workerIdBits;
|
||||
|
||||
/** 时间截向左移22位(5+5+12) */
|
||||
private final long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;
|
||||
|
||||
/** 生成序列的掩码,这里为4095 (0b111111111111=0xfff=4095) */
|
||||
private final long sequenceMask = -1L ^ (-1L << sequenceBits);
|
||||
|
||||
/** 工作机器ID(0~31) */
|
||||
private long workerId;
|
||||
|
||||
/** 数据中心ID(0~31) */
|
||||
private long datacenterId;
|
||||
|
||||
/** 毫秒内序列(0~4095) */
|
||||
private long sequence = 0L;
|
||||
|
||||
/** 上次生成ID的时间截 */
|
||||
private long lastTimestamp = -1L;
|
||||
|
||||
//==============================Constructors=====================================
|
||||
/**
|
||||
* 构造函数
|
||||
* @param workerId 工作ID (0~31)
|
||||
* @param datacenterId 数据中心ID (0~31)
|
||||
*/
|
||||
public SnowFlakeUtil(long workerId, long datacenterId) {
|
||||
if (workerId > maxWorkerId || workerId < 0) {
|
||||
throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId));
|
||||
}
|
||||
if (datacenterId > maxDatacenterId || datacenterId < 0) {
|
||||
throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId));
|
||||
}
|
||||
this.workerId = workerId;
|
||||
this.datacenterId = datacenterId;
|
||||
}
|
||||
|
||||
// ==============================Methods==========================================
|
||||
/**
|
||||
* 获得下一个ID (该方法是线程安全的)
|
||||
* @return SnowflakeId
|
||||
*/
|
||||
public synchronized long nextId() {
|
||||
long timestamp = timeGen();
|
||||
|
||||
//如果当前时间小于上一次ID生成的时间戳,说明系统时钟回退过这个时候应当抛出异常
|
||||
if (timestamp < lastTimestamp) {
|
||||
throw new RuntimeException(
|
||||
String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
|
||||
}
|
||||
|
||||
//如果是同一时间生成的,则进行毫秒内序列
|
||||
if (lastTimestamp == timestamp) {
|
||||
sequence = (sequence + 1) & sequenceMask;
|
||||
//毫秒内序列溢出
|
||||
if (sequence == 0) {
|
||||
//阻塞到下一个毫秒,获得新的时间戳
|
||||
timestamp = tilNextMillis(lastTimestamp);
|
||||
}
|
||||
}
|
||||
//时间戳改变,毫秒内序列重置
|
||||
else {
|
||||
sequence = 0L;
|
||||
}
|
||||
|
||||
//上次生成ID的时间截
|
||||
lastTimestamp = timestamp;
|
||||
|
||||
//移位并通过或运算拼到一起组成64位的ID
|
||||
return (((timestamp - twepoch) << timestampLeftShift) //
|
||||
| (datacenterId << datacenterIdShift) //
|
||||
| (workerId << workerIdShift) //
|
||||
| sequence);
|
||||
}
|
||||
|
||||
/**
|
||||
* 阻塞到下一个毫秒,直到获得新的时间戳
|
||||
* @param lastTimestamp 上次生成ID的时间截
|
||||
* @return 当前时间戳
|
||||
*/
|
||||
protected long tilNextMillis(long lastTimestamp) {
|
||||
long timestamp = timeGen();
|
||||
while (timestamp <= lastTimestamp) {
|
||||
timestamp = timeGen();
|
||||
}
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回以毫秒为单位的当前时间
|
||||
* @return 当前时间(毫秒)
|
||||
*/
|
||||
protected long timeGen() {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
|
||||
//==============================Test=============================================
|
||||
/** 测试 */
|
||||
public static void main(String[] args) {
|
||||
SnowFlakeUtil idWorker = new SnowFlakeUtil(0, 0);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
long id = idWorker.nextId();
|
||||
//System.out.println(Long.toBinaryString(id));
|
||||
System.out.println(id);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
package com.mall.config;
|
||||
|
||||
/**
|
||||
* 雪花算法
|
||||
* */
|
||||
public class Snowflake {
|
||||
// 起始时间戳
|
||||
private final static long START_TIMESTAMP = 1480166465631L;
|
||||
|
||||
// 机器ID所占的位数
|
||||
private final static long MACHINE_BIT = 5;
|
||||
|
||||
// 序列号所占的位数
|
||||
private final static long SEQUENCE_BIT = 12;
|
||||
|
||||
// 机器ID最大值
|
||||
private final static long MAX_MACHINE_NUM = -1L ^ (-1L << MACHINE_BIT);
|
||||
|
||||
// 序列号最大值
|
||||
private final static long MAX_SEQUENCE_NUM = -1L ^ (-1L << SEQUENCE_BIT);
|
||||
|
||||
// 机器ID左移位数
|
||||
private final static long MACHINE_LEFT_SHIFT = SEQUENCE_BIT;
|
||||
|
||||
// 时间戳左移位数
|
||||
private final static long TIMESTAMP_LEFT_SHIFT = MACHINE_LEFT_SHIFT + MACHINE_BIT;
|
||||
|
||||
// 上一个时间戳
|
||||
private static long lastTimestamp = -1L;
|
||||
|
||||
// 序列号
|
||||
private static long sequenceNum = 0L;
|
||||
|
||||
// 机器ID
|
||||
private long machineId;
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
*/
|
||||
public Snowflake() {
|
||||
if (machineId > MAX_MACHINE_NUM || machineId < 0) {
|
||||
throw new IllegalArgumentException("machineId can't be greater than " + MAX_MACHINE_NUM + " or less than 0");
|
||||
}
|
||||
this.machineId = machineId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取下一个唯一ID
|
||||
* @return 唯一ID
|
||||
*/
|
||||
public synchronized long getNextId() {
|
||||
long timestamp = System.currentTimeMillis();
|
||||
if (timestamp < lastTimestamp) {
|
||||
throw new RuntimeException("Clock moved backwards. Refusing to generate id");
|
||||
}
|
||||
if (timestamp == lastTimestamp) {
|
||||
sequenceNum = (sequenceNum + 1) & MAX_SEQUENCE_NUM;
|
||||
if (sequenceNum == 0) {
|
||||
timestamp = waitNextMillis(lastTimestamp);
|
||||
}
|
||||
} else {
|
||||
sequenceNum = 0L;
|
||||
}
|
||||
lastTimestamp = timestamp;
|
||||
return ((timestamp - START_TIMESTAMP) << TIMESTAMP_LEFT_SHIFT) | (machineId << MACHINE_LEFT_SHIFT) | sequenceNum;
|
||||
}
|
||||
|
||||
/**
|
||||
* 等待下一个毫秒
|
||||
* @param lastTimestamp 上一个时间戳
|
||||
* @return 当前时间戳
|
||||
*/
|
||||
private long waitNextMillis(long lastTimestamp) {
|
||||
long timestamp = System.currentTimeMillis();
|
||||
while (timestamp <= lastTimestamp) {
|
||||
timestamp = System.currentTimeMillis();
|
||||
}
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
Snowflake snowflake = new Snowflake();
|
||||
System.out.println(snowflake.getNextId());
|
||||
SnowFlakeUtil snowFlakeUtil = new SnowFlakeUtil(0, 1);
|
||||
System.out.println(snowFlakeUtil.nextId());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package com.mall.controller;
|
||||
|
||||
|
||||
import com.mall.common.result.Result;
|
||||
import com.mall.domin.PmsBargain;
|
||||
import com.mall.domin.PmsBargainRecord;
|
||||
import com.mall.domin.PmsSku;
|
||||
import com.mall.service.BargainService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
/**
|
||||
* 砍价
|
||||
* */
|
||||
@RestController
|
||||
public class BargainController {
|
||||
|
||||
@Autowired
|
||||
private BargainService bargainService;
|
||||
|
||||
@PostMapping("/select/bargain")
|
||||
public Result<List<PmsBargain>> selectBargain(){
|
||||
return bargainService.selectBargain();
|
||||
}
|
||||
|
||||
@PostMapping("/add/bargain")
|
||||
public Result addBargain(PmsBargain pmsBargain){
|
||||
return bargainService.addBargain(pmsBargain);
|
||||
}
|
||||
|
||||
@PostMapping("/update/bargain")
|
||||
public Result updateBargain(PmsBargain pmsBargain){
|
||||
return bargainService.updateBargain(pmsBargain);
|
||||
}
|
||||
|
||||
@PostMapping("/delete/bargain")
|
||||
public Result deleteBargain(Integer bargainId){
|
||||
return bargainService.deleteBargain(bargainId);
|
||||
}
|
||||
|
||||
@PostMapping("/select/cut/")
|
||||
public Result<List<PmsBargain>> selectCut(PmsSku pmsSku){
|
||||
List<PmsBargain> pmsBargains=bargainService.selectCut(pmsSku);
|
||||
return Result.success(pmsBargains);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping("/initiate")
|
||||
public Result initiateBargain(@RequestParam Long userId, @RequestParam Long productId) {
|
||||
String bargainLink = bargainService.initiateBargain(userId, productId);
|
||||
return Result.success(bargainLink);
|
||||
}
|
||||
|
||||
@GetMapping("/records")
|
||||
public Result getBargainRecords(@RequestParam Long userId) {
|
||||
List<PmsBargainRecord> records = bargainService.getBargainRecords(userId);
|
||||
return Result.success(records);
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.mall.controller;
|
||||
|
||||
import com.mall.common.result.Result;
|
||||
import com.mall.domin.PmsBargainRecord;
|
||||
import com.mall.service.BargainRecordServie;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 砍价记录
|
||||
* */
|
||||
@RestController
|
||||
public class BargainRecordController {
|
||||
|
||||
@Autowired
|
||||
private BargainRecordServie bargainRecordService;
|
||||
|
||||
|
||||
@PostMapping("/select/bargain/record/")
|
||||
public Result<List<PmsBargainRecord>> selectBargainRecord() {
|
||||
return Result.success(bargainRecordService.list());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
package com.mall.controller;
|
||||
|
||||
import com.mall.common.result.Result;
|
||||
import com.mall.domin.PmsCategory;
|
||||
import com.mall.service.CategoryService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 三级分类
|
||||
* */
|
||||
@RestController
|
||||
public class CategoryController {
|
||||
|
||||
@Autowired
|
||||
private CategoryService categoryService;
|
||||
|
||||
|
||||
/**
|
||||
* 三级分类
|
||||
* */
|
||||
@RequestMapping("/list/tree")
|
||||
public Result list(){
|
||||
List<PmsCategory> categories=categoryService.listWithTree();
|
||||
return Result.success(categories);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,32 @@
|
|||
package com.mall.controller;
|
||||
|
||||
import com.mall.common.result.Result;
|
||||
import com.mall.domin.PmsBargain;
|
||||
import com.mall.domin.PmsSku;
|
||||
import com.mall.service.SkuService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品
|
||||
* */
|
||||
@RestController
|
||||
public class SkuController {
|
||||
@Autowired
|
||||
private SkuService skuService;
|
||||
|
||||
@PostMapping("/select/sku")
|
||||
public Result<List<PmsSku>> selectSku() {
|
||||
return Result.success(skuService.list());
|
||||
}
|
||||
|
||||
@PostMapping("/select/sku/bargain")
|
||||
public Result<List<PmsSku>> selectSkuBargain(PmsBargain pmsBargain) {
|
||||
List<PmsSku> skuList = skuService.selectSkuBargain(pmsBargain);
|
||||
return Result.success(skuList);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
package com.mall.domin;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
/**
|
||||
* 砍价
|
||||
* */
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PmsBargain{
|
||||
|
||||
/**
|
||||
* 砍价表id
|
||||
* */
|
||||
private Integer id;
|
||||
/**
|
||||
* 砍价图片
|
||||
* */
|
||||
private String bargainImg;
|
||||
/**
|
||||
* 砍价名称(加(梁))
|
||||
* */
|
||||
private String bargainName;
|
||||
/**
|
||||
* 砍价价格(改(梁))
|
||||
* */
|
||||
private BigDecimal bargainPrice;
|
||||
/**
|
||||
* 最低价
|
||||
* */
|
||||
private BigDecimal bargainMinPrice;
|
||||
/**
|
||||
* 参与人数
|
||||
* */
|
||||
private Integer bargainNum;
|
||||
/**
|
||||
* 帮忙砍价人数
|
||||
* */
|
||||
private Integer bargainHelpNum;
|
||||
/**
|
||||
* 参加成功人数
|
||||
* */
|
||||
private Integer bargainSuccessNum;
|
||||
/**
|
||||
* 限量
|
||||
* */
|
||||
private Integer bargainLimited;
|
||||
/**
|
||||
* 限量剩余
|
||||
* */
|
||||
private Integer bargainLimitedRemainder;
|
||||
/**
|
||||
* 结束时间
|
||||
* */
|
||||
private Date bargainEndTime;
|
||||
/**
|
||||
* 砍价状态(0未砍价1砍价中2砍价成功3已放弃)
|
||||
* */
|
||||
private Integer bargainStaus;
|
||||
/**
|
||||
* id删除(0未删除2已删除)
|
||||
* */
|
||||
private Integer bargainDelid;
|
||||
/**
|
||||
* 商品介绍(加(梁))
|
||||
* */
|
||||
private String bargainIntroduce;
|
||||
/**
|
||||
* 总共砍次数(加(梁))
|
||||
* */
|
||||
private Integer bargainAltogether;
|
||||
/**
|
||||
* 剩余砍次数(加(梁))
|
||||
* */
|
||||
private Integer bargainSurplus;
|
||||
/**
|
||||
* 砍价开始时间(加(梁))
|
||||
* */
|
||||
private Date bargainStopTime;
|
||||
/**
|
||||
* 砍价结束时间(加(梁))
|
||||
* */
|
||||
private Date bargainSendTime;
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package com.mall.domin;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 砍价记录
|
||||
* */
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PmsBargainRecord {
|
||||
|
||||
/**
|
||||
* id
|
||||
* */
|
||||
private Integer id;
|
||||
/**
|
||||
* 砍价id
|
||||
* */
|
||||
private Integer bargainId;
|
||||
/**
|
||||
* 商品id
|
||||
* */
|
||||
private Integer skuId;
|
||||
/**
|
||||
* 用户id
|
||||
* */
|
||||
private Integer userId;
|
||||
/**
|
||||
* 砍价比率
|
||||
* */
|
||||
private Integer bargainRatio;
|
||||
/**
|
||||
* 砍价金额
|
||||
* */
|
||||
private Integer bargainAmount;
|
||||
/**
|
||||
* 砍价时间
|
||||
* */
|
||||
private Date bargainingTime;
|
||||
/**
|
||||
* 是否为砍价发起人(0发起人 1帮砍人)
|
||||
* */
|
||||
private Integer state;
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package com.mall.domin;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 三级分类递归
|
||||
* */
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PmsCategory {
|
||||
|
||||
/**
|
||||
* 分类id
|
||||
* */
|
||||
private Integer id;
|
||||
/**
|
||||
* 分类名称
|
||||
* */
|
||||
private String name;
|
||||
/**
|
||||
* 父分类id
|
||||
* */
|
||||
private Integer parentId;
|
||||
/**
|
||||
* 是否显示[0-不显示,1显示]
|
||||
* */
|
||||
private Integer status;
|
||||
/**
|
||||
* 排序
|
||||
* */
|
||||
private Integer sort;
|
||||
/**
|
||||
* 图标地址
|
||||
* */
|
||||
private String icon;
|
||||
/**
|
||||
* 计量单位
|
||||
* */
|
||||
private String unit;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<PmsCategory> children;
|
||||
|
||||
}
|
|
@ -0,0 +1,84 @@
|
|||
package com.mall.domin;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
*sku信息表
|
||||
* */
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PmsSku {
|
||||
|
||||
/**
|
||||
* skuId
|
||||
* */
|
||||
private Integer id;
|
||||
/**
|
||||
* spuId
|
||||
* */
|
||||
private Integer spuId;
|
||||
/**
|
||||
* sku名称
|
||||
* */
|
||||
private String name;
|
||||
/**
|
||||
* 所属分类id
|
||||
* */
|
||||
private Integer categoryId;
|
||||
/**
|
||||
* 品牌id
|
||||
* */
|
||||
private Integer brandId;
|
||||
/**
|
||||
* 默认图片
|
||||
* */
|
||||
private String defaultImage;
|
||||
/**
|
||||
* 标题
|
||||
* */
|
||||
private String title;
|
||||
/**
|
||||
* 副标题
|
||||
* */
|
||||
private String subtitle;
|
||||
/**
|
||||
* 价格
|
||||
* */
|
||||
private BigDecimal price;
|
||||
/**
|
||||
* 活动价格
|
||||
* */
|
||||
private BigDecimal activityPrice;
|
||||
/**
|
||||
* 重量(克)
|
||||
* */
|
||||
private Integer weight;
|
||||
/**
|
||||
* 库存
|
||||
* */
|
||||
private Integer inventory;
|
||||
/**
|
||||
* 库存限制量
|
||||
* */
|
||||
private Integer inventoryRestrict;
|
||||
/**
|
||||
* 秒杀id(0未开启秒杀)
|
||||
* */
|
||||
private Integer spikesId;
|
||||
/**
|
||||
* 砍价id(0未开启砍价)
|
||||
* */
|
||||
private Integer bargainId;
|
||||
/**
|
||||
* 拼团id(0未开启拼团)
|
||||
* */
|
||||
private Integer groupId;
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package com.mall.domin;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* sku图片信息表
|
||||
* */
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PmsSkuImage {
|
||||
|
||||
/**
|
||||
* id
|
||||
* */
|
||||
private Integer id;
|
||||
/**
|
||||
* sku_id
|
||||
* */
|
||||
private Integer skuId;
|
||||
/**
|
||||
* 图片地址
|
||||
* */
|
||||
private String url;
|
||||
/**
|
||||
* 排序
|
||||
* */
|
||||
private Integer sort;
|
||||
/**
|
||||
* 默认图[0 - 不是默认图,1 - 是默认图]
|
||||
* */
|
||||
private Integer defaulStatus;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
package com.mall.domin;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* spu信息表
|
||||
* */
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PmsSpu {
|
||||
|
||||
/**
|
||||
* 商品id
|
||||
* */
|
||||
private Integer id;
|
||||
/**
|
||||
* 商品名称
|
||||
* */
|
||||
private String name;
|
||||
/**
|
||||
* 所属分类id
|
||||
* */
|
||||
private Integer categoryId;
|
||||
/**
|
||||
* 品牌id
|
||||
* */
|
||||
private Integer brandId;
|
||||
/**
|
||||
* 上架状态[0 - 下架,1 - 上架]
|
||||
* */
|
||||
private Integer publishStatus;
|
||||
/**
|
||||
* 创建时间
|
||||
* */
|
||||
private Date createTime;
|
||||
/**
|
||||
* 更新时间
|
||||
* */
|
||||
private Date updateTime;
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
package com.mall.domin.vo;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class PmsBargainVo {
|
||||
|
||||
|
||||
/**
|
||||
* 砍价图片
|
||||
* */
|
||||
private String bargainImg;
|
||||
/**
|
||||
* 砍价名称(加(梁))
|
||||
* */
|
||||
private String bargainName;
|
||||
/**
|
||||
* 商品介绍(加(梁))
|
||||
* */
|
||||
private String bargainIntroduce;
|
||||
/**
|
||||
* 砍价价格(改(梁))
|
||||
* */
|
||||
private BigDecimal bargainPrice;
|
||||
/**
|
||||
* 总共砍次数(加(梁))
|
||||
* */
|
||||
private Integer bargainAltogether;
|
||||
/**
|
||||
* 剩余砍次数(加(梁))
|
||||
* */
|
||||
private Integer bargainSurplus;
|
||||
/**
|
||||
* 砍价开始时间(加(梁))
|
||||
* */
|
||||
private Date bargainStopTime;
|
||||
/**
|
||||
* 砍价结束时间(加(梁))
|
||||
* */
|
||||
private Date bargainSendTime;
|
||||
/**
|
||||
* 砍价状态(0未砍价1砍价中2砍价成功3已放弃)
|
||||
* */
|
||||
private Integer bargainStaus;
|
||||
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.mall.domin.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SkuVo {
|
||||
|
||||
/**
|
||||
* 商品名称
|
||||
* */
|
||||
private String name;
|
||||
/**
|
||||
* 标题
|
||||
* */
|
||||
private String title;
|
||||
/**
|
||||
* 副标题
|
||||
* */
|
||||
private String subtitle;
|
||||
/**
|
||||
* 砍价id(0未开启砍价)
|
||||
* */
|
||||
private Integer bargainId;
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.mall.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mall.domin.PmsBargain;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface BargainMapper extends BaseMapper<PmsBargain> {
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.mall.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mall.domin.PmsBargainRecord;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface BargainRecordMapper extends BaseMapper<PmsBargainRecord> {
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.mall.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mall.domin.PmsCategory;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface CategoryMapper extends BaseMapper<PmsCategory> {
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
package com.mall.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.mall.domin.PmsSku;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface PamSkuMapper extends BaseMapper<PmsSku> {
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.mall.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mall.domin.PmsBargain;
|
||||
import com.mall.domin.PmsBargainRecord;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface BargainRecordServie extends IService<PmsBargainRecord> {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.mall.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mall.common.result.Result;
|
||||
import com.mall.domin.PmsBargain;
|
||||
import com.mall.domin.PmsBargainRecord;
|
||||
import com.mall.domin.PmsSku;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public interface BargainService extends IService<PmsBargain> {
|
||||
|
||||
Result<List<PmsBargain>> selectBargain();
|
||||
|
||||
Result addBargain(PmsBargain pmsBargain);
|
||||
|
||||
Result updateBargain(PmsBargain pmsBargain);
|
||||
|
||||
Result deleteBargain(Integer bargainId);
|
||||
|
||||
|
||||
List<PmsBargain> selectCut(PmsSku pmsSku);
|
||||
|
||||
String initiateBargain(Long userId, Long productId);
|
||||
|
||||
List<PmsBargainRecord> getBargainRecords(Long userId);
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.mall.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mall.domin.PmsCategory;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CategoryService extends IService<PmsCategory> {
|
||||
|
||||
|
||||
List<PmsCategory> listWithTree();
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.mall.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.mall.domin.PmsBargain;
|
||||
import com.mall.domin.PmsSku;
|
||||
import com.mall.service.impl.SkuServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface SkuService extends IService<PmsSku> {
|
||||
|
||||
|
||||
List<PmsSku> selectSkuBargain(PmsBargain pmsBargain);
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.mall.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mall.domin.PmsBargainRecord;
|
||||
import com.mall.mapper.BargainRecordMapper;
|
||||
import com.mall.service.BargainRecordServie;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class BargainRecordServieimpl extends ServiceImpl<BargainRecordMapper, PmsBargainRecord>
|
||||
implements BargainRecordServie {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public List<PmsBargainRecord> findByUserId(Long userId) {
|
||||
LambdaQueryWrapper<PmsBargainRecord> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(PmsBargainRecord::getUserId,userId);
|
||||
List<PmsBargainRecord> list = this.list(wrapper);
|
||||
return list;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,118 @@
|
|||
package com.mall.service.impl;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mall.common.result.Result;
|
||||
import com.mall.config.DesUtil;
|
||||
import com.mall.config.Snowflake;
|
||||
import com.mall.domin.PmsBargain;
|
||||
import com.mall.domin.PmsBargainRecord;
|
||||
import com.mall.domin.PmsSku;
|
||||
import com.mall.mapper.BargainMapper;
|
||||
import com.mall.service.BargainService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Service
|
||||
public class BargainServiceimpl extends ServiceImpl<BargainMapper, PmsBargain>
|
||||
implements BargainService {
|
||||
|
||||
@Autowired
|
||||
private BargainMapper bargainMapper;
|
||||
|
||||
|
||||
@Override
|
||||
public Result<List<PmsBargain>> selectBargain() {
|
||||
List<PmsBargain> bargainList = this.list();
|
||||
return Result.success(bargainList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result addBargain(PmsBargain pmsBargain) {
|
||||
boolean save = this.save(pmsBargain);
|
||||
return Result.success(save);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result updateBargain(PmsBargain pmsBargain) {
|
||||
boolean update = this.updateById(pmsBargain);
|
||||
return Result.success(update);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result deleteBargain(Integer bargainId) {
|
||||
boolean b = this.removeById(bargainId);
|
||||
return Result.success(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PmsBargain> selectCut(PmsSku pmsSku) {
|
||||
LambdaQueryWrapper<PmsBargain> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(PmsBargain::getId, pmsSku.getBargainId());
|
||||
List<PmsBargain> bargainList = this.list();
|
||||
return bargainList;
|
||||
}
|
||||
|
||||
|
||||
@Autowired
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
@Autowired
|
||||
private BargainRecordServieimpl bargainRecordServieimpl;
|
||||
|
||||
public String initiateBargain(Long userId, Long productId) {
|
||||
// 生成砍价订单
|
||||
String orderNumber = generateOrderNumber(userId, productId);
|
||||
// 生成砍价链接
|
||||
String bargainLink = generateBargainLink(orderNumber);
|
||||
// 将砍价订单信息存入Redis
|
||||
redisTemplate.opsForValue().set(orderNumber, getBasePrice(productId));
|
||||
|
||||
return bargainLink;
|
||||
}
|
||||
|
||||
public List<PmsBargainRecord> getBargainRecords(Long userId) {
|
||||
//从数据库或缓存中获取用户的砍价记录
|
||||
return bargainRecordServieimpl.findByUserId(userId);
|
||||
}
|
||||
|
||||
private String generateOrderNumber(Long userId, Long productId) {
|
||||
// 生成唯一订单号,可以使用Snowflake算法
|
||||
Snowflake snowflake = new Snowflake();
|
||||
long nextId = snowflake.getNextId();
|
||||
|
||||
// 省略具体实现
|
||||
return "202306090001";
|
||||
}
|
||||
|
||||
private BigDecimal getBasePrice(Long productId) {
|
||||
// 从数据库中获取商品底价
|
||||
// 省略具体实现
|
||||
return new BigDecimal("100");
|
||||
}
|
||||
|
||||
private String generateBargainLink(String orderNumber) {
|
||||
// 生成砍价链接,可以加入签名等安全机制
|
||||
DesUtil desUtil = new DesUtil();
|
||||
try {
|
||||
String encryptStr = desUtil.encrypt("https://yourdomain.com/bargain/link?orderNumber","DEC");
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
return "https://yourdomain.com/bargain/link?orderNumber=" + orderNumber;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
package com.mall.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mall.domin.PmsCategory;
|
||||
import com.mall.mapper.CategoryMapper;
|
||||
import com.mall.service.CategoryService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
@Service
|
||||
public class CategoryServiceimpl extends ServiceImpl<CategoryMapper, PmsCategory>
|
||||
implements CategoryService {
|
||||
|
||||
|
||||
public List<PmsCategory> listWithTree() {
|
||||
// 1、一条sql 查询出所有分类商品列表
|
||||
List<PmsCategory> entities = baseMapper.selectList(null);
|
||||
|
||||
List<PmsCategory> level1Menus = entities.stream().filter(pmsCategory ->
|
||||
// 2、过滤出所有的 一级 类目
|
||||
pmsCategory.getParentId() == 0
|
||||
).map((menu) -> {
|
||||
// 3、递归找出所有的 子类目
|
||||
menu.setChildren(getChildrens(menu, entities));
|
||||
return menu;
|
||||
}).sorted((menu1, menu2) -> {
|
||||
// 4、将两个类目前后的排序之差作为排序规则
|
||||
return (menu1.getSort() == null ? 0 : menu1.getSort()) - (menu2.getSort() == null ? 0 : menu2.getSort());
|
||||
}).collect(Collectors.toList()); // 5、收集整理好的三级分类列表数据集合
|
||||
return level1Menus;
|
||||
}
|
||||
|
||||
private List<PmsCategory> getChildrens(PmsCategory currentMenu, List<PmsCategory> allMenus) {
|
||||
List<PmsCategory> children = allMenus.stream().filter(pmsCategory -> {
|
||||
// 父子关系:下一页的父分类id == 当前页的分类id
|
||||
return pmsCategory.getParentId() == currentMenu.getId();
|
||||
}).map(categoryEntity -> {
|
||||
// 递归遍历是否还有下一级
|
||||
categoryEntity.setChildren(getChildrens(categoryEntity, allMenus));
|
||||
return categoryEntity;
|
||||
}).sorted((menu1, menu2) -> {
|
||||
return (menu1.getSort() == null ? 0 : menu1.getSort()) - (menu2.getSort() == null ? 0 : menu2.getSort());
|
||||
}).collect(Collectors.toList());
|
||||
return children;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,27 @@
|
|||
package com.mall.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.mall.domin.PmsBargain;
|
||||
import com.mall.domin.PmsSku;
|
||||
import com.mall.mapper.PamSkuMapper;
|
||||
import com.mall.service.BargainService;
|
||||
import com.mall.service.SkuService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class SkuServiceImpl extends ServiceImpl<PamSkuMapper, PmsSku>
|
||||
implements SkuService {
|
||||
@Autowired
|
||||
private BargainService bargainService;
|
||||
@Override
|
||||
public List<PmsSku> selectSkuBargain(PmsBargain pmsBargain) {
|
||||
LambdaQueryWrapper<PmsSku> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(PmsSku::getBargainId, pmsBargain.getId());
|
||||
List<PmsSku> list = this.list(wrapper);
|
||||
return list;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
# Tomcat
|
||||
server:
|
||||
port: 9003
|
||||
# Spring
|
||||
spring:
|
||||
main:
|
||||
allow-circular-references: true
|
||||
jackson:
|
||||
date-format: yyyy-MM-dd HH:mm:ss
|
||||
time-zone: GMT+8
|
||||
application:
|
||||
# 应用名称
|
||||
name: czk-client
|
||||
profiles:
|
||||
# 环境配置
|
||||
active: dev
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
# 服务注册地址
|
||||
server-addr: 42.192.106.69:8848
|
||||
config:
|
||||
# 配置中心地址
|
||||
server-addr: 42.192.106.69:8848
|
||||
# 配置文件格式
|
||||
file-extension: yml
|
||||
# 共享配置
|
||||
shared-configs:
|
||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue