Commit a107b998 authored by 黎博's avatar 黎博

新增电商购物流程方法

parent 03e9ccd0
package cn.qg.qaplatform.controller.zdata.yxm;
import cn.qg.qaplatform.config.SwitchDataSource;
import cn.qg.qaplatform.mapper.zdata.KdspMapper;
import cn.qg.qaplatform.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@CrossOrigin
@RestController
@RequestMapping("/kdsp")
public class KdspController {
@Autowired
KdspMapper kdspMapper;
@GetMapping("/sku/list")
public JsonResult getSkuList(String namespace, Integer skuSource, Double salePriceLimit) {
SwitchDataSource.dataSourceSwitch(namespace, "kdsp");
return JsonResult.success(kdspMapper.getSelfSupportSkuNoList(skuSource, salePriceLimit));
}
}
...@@ -158,4 +158,4 @@ public class RSA { ...@@ -158,4 +158,4 @@ public class RSA {
System.out.println(publicKey); System.out.println(publicKey);
} }
} }
\ No newline at end of file
package cn.qg.qaplatform.encrypt.yxm;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
public class DESUtils {
private static final String DES = "DES";
private static final String PADDING = "DES/ECB/PKCS5Padding";
private static byte[] encrypt(byte[] src, byte[] key) throws Exception {
SecureRandom sr = new SecureRandom();
DESKeySpec dks = new DESKeySpec(key);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(DES);
SecretKey secretKey = keyFactory.generateSecret(dks);
Cipher cipher = Cipher.getInstance(PADDING);
cipher.init(Cipher.ENCRYPT_MODE, secretKey, sr);
return cipher.doFinal(src);
}
private static byte[] decrypt(byte[] src, byte[] key) throws Exception {
SecureRandom sr = new SecureRandom();
DESKeySpec dks = new DESKeySpec(key);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance(DES);
SecretKey secretKey = keyFactory.generateSecret(dks);
Cipher cipher = Cipher.getInstance(PADDING);
cipher.init(Cipher.DECRYPT_MODE, secretKey, sr);
return cipher.doFinal(src);
}
private static String byte2hex(byte[] b) {
String hs = "";
String temp = "";
for (int n = 0; n < b.length; n++) {
temp = (Integer.toHexString(b[n] & 0XFF));
if (temp.length() == 1) {
hs = hs + "0" + temp;
} else {
hs = hs + temp;
}
}
return hs.toUpperCase();
}
private static byte[] hex2byte(byte[] b) {
if ((b.length % 2) != 0) {
throw new IllegalArgumentException("length not even");
}
byte[] b2 = new byte[b.length / 2];
for (int n = 0; n < b.length; n += 2) {
String item = new String(b, n, 2);
b2[n / 2] = (byte) Integer.parseInt(item, 16);
}
return b2;
}
/**
* 解密
* @param src
* @param key
* @return
*/
public static String decrypt(String src, String key) {
String decryptStr = "";
try {
byte[] decrypt = decrypt(hex2byte(src.getBytes()), key.getBytes());
decryptStr = new String(decrypt);
} catch (Exception e) {
e.printStackTrace();
}
return decryptStr;
}
/**
* 加密
* @param src
* @param key
* @return
*/
public static String encrypt(String src, String key) {
byte[] bytes = null;
String encryptStr = "";
try {
bytes = encrypt(src.getBytes(), key.getBytes());
} catch (Exception ex) {
ex.printStackTrace();
}
if (bytes != null) {
encryptStr = byte2hex(bytes);
}
return encryptStr;
}
// public static void main(String[] args) {
// String pwd = "123123123";
// String str = encrypt(pwd, "VCC_DFDO&WEK1E0I2S3");
// String str1 = decrypt(str, "VCC_DFDO&WEK1E0I2S3");
// System.out.println(str + "_" + str1);
// }
}
package cn.qg.qaplatform.mapper.zdata;
import java.util.List;
import java.util.Map;
public interface KdspMapper {
List<Map> getSelfSupportSkuNoList(Integer skuSource, Double salePriceLimit);
}
package cn.qg.qaplatform.service.zdata.yxm;
public interface PurchaseService {
boolean quotaPurchase(String namespace, String phoneNo);
}
package cn.qg.qaplatform.service.zdata.yxm.impl;
import cn.qg.qaplatform.service.zdata.yxm.PurchaseService;
import org.springframework.stereotype.Service;
/**
* @author libo
* 2021-08-04
*/
@Service
public class PurchaseServiceImpl implements PurchaseService {
/**
* 电商额度购买全流程
* @param namespace 环境
* @param phoneNo 手机号
* @return
*/
@Override
public boolean quotaPurchase(String namespace, String phoneNo) {
return false;
}
}
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="cn.qg.qaplatform.mapper.zdata.KdspMapper">
<select id="getSelfSupportSkuNoList" resultType="java.util.Map">
SELECT
*
FROM t_sku_info
<where>
stock > 0
<if test="skuSource != null and skuSource != ''">
AND `sku_source` = #{skuSource}
</if>
<if test="salePriceLimit != null and salePriceLimit != ''">
AND `sale_price` &lt;= #{salePriceLimit}
</if>
</where>
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment