liang
lsy 2024-05-03 19:27:11 +08:00
parent dda1842b69
commit 9dd5d11e80
141 changed files with 3030 additions and 415 deletions

View File

@ -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>

13
.idea/misc.xml 100644
View File

@ -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>

View File

@ -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>

6
.idea/vcs.xml 100644
View File

@ -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

View File

@ -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);
}
}

View File

@ -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.'
*
* 3IP
* String ip_ = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
*/
}

View File

@ -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);
}
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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>{
}

View File

@ -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);
}

View File

@ -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+"删除成功");
}
}

View File

@ -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

View File

@ -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

View File

@ -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);
}
}

View File

@ -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 015
*/
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;
}
}

View File

@ -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>
* 1longJava01id0<br>
* 41()41 - )
* id使IdWorkerstartTime41使69T = (1L << 41) / (1000L * 60 * 60 * 24 * 365) = 69<br>
* 1010245datacenterId5workerId<br>
* 1212()4096ID<br>
* 64Long<br>
* SnowFlakeID(IDID)SnowFlake26ID
*/
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);
}
}
}

View File

@ -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());
}
}

View File

@ -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);
}
}

View File

@ -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());
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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;
/**
* (0123)
* */
private Integer bargainStaus;
/**
* id(02)
* */
private Integer bargainDelid;
/**
* (())
* */
private String bargainIntroduce;
/**
* (())
* */
private Integer bargainAltogether;
/**
* (())
* */
private Integer bargainSurplus;
/**
* (())
* */
private Date bargainStopTime;
/**
* (())
* */
private Date bargainSendTime;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
/**
* id0
* */
private Integer spikesId;
/**
* id0
* */
private Integer bargainId;
/**
* id0
* */
private Integer groupId;
}

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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;
/**
* (0123)
* */
private Integer bargainStaus;
}

View File

@ -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;
/**
* id0
* */
private Integer bargainId;
}

View File

@ -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> {
}

View File

@ -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> {
}

View File

@ -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> {
}

View File

@ -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> {
}

View File

@ -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> {
}

View File

@ -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);
}

View File

@ -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();
}

View File

@ -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);
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -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}

Some files were not shown because too many files have changed in this diff Show More