修改商户列表

This commit is contained in:
韩鹏辉 2023-08-02 11:28:41 +08:00
parent ebc23c4dc7
commit df87c47b95
16 changed files with 451 additions and 18 deletions

View File

@ -11,11 +11,13 @@ import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.client.RestTemplate;
/**
@ -43,6 +45,7 @@ public class Shell {
ctx.getBean(ExceptionUtil.class).initException();
};
}
@Bean
public static PropertySourcesPlaceholderConfigurer placeholderConfigurer() {
PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();

View File

@ -1,14 +1,23 @@
package com.chaozhanggui.admin.system.controller;
import com.alibaba.fastjson.JSONObject;
import com.chaozhanggui.admin.system.model.CreateAgencyReq;
import com.chaozhanggui.admin.system.service.AgencyService;
import com.chaozhanggui.admin.system.util.MD5Util;
import com.chaozhanggui.admin.system.util.SignUtils;
import com.chaozhanggui.common.system.config.RespBody;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.util.*;
/**
@ -223,7 +232,4 @@ return null;
}

View File

@ -22,6 +22,6 @@ public class AdminWebConfig implements WebMvcConfigurer {
registry.addInterceptor(new LoginInterceptor(redisUtil))
.addPathPatterns()
// 如果有静态资源的时候可以在这个地方放行
.excludePathPatterns("/","/user/doLogin","/agency/mytest","/agency/queryAgency","/promotion/testRequest");
.excludePathPatterns("/","/user/doLogin","/agency/mytest","/agency/queryAgency","/promotion/testRequest","/agency/sendmessage");
}
}

View File

@ -5,12 +5,8 @@ import com.chaozhanggui.admin.system.model.CreateAgencyReq;
import com.chaozhanggui.admin.system.util.MD5Util;
import com.chaozhanggui.admin.system.util.StringUtil;
import com.chaozhanggui.common.system.config.RespBody;
import com.chaozhanggui.dao.system.dao.TbPlussUserAppMapper;
import com.chaozhanggui.dao.system.dao.TbPlussUserInfoMapper;
import com.chaozhanggui.dao.system.dao.TbPlussUserPromotionMapper;
import com.chaozhanggui.dao.system.entity.TbPlussUserApp;
import com.chaozhanggui.dao.system.entity.TbPlussUserInfo;
import com.chaozhanggui.dao.system.entity.TbPlussUserPromotion;
import com.chaozhanggui.dao.system.dao.*;
import com.chaozhanggui.dao.system.entity.*;
import com.chaozhanggui.dao.system.model.CashStatus;
import com.chaozhanggui.dao.system.model.ProfitPO;
import com.chaozhanggui.dao.system.util.N;
@ -40,6 +36,15 @@ public class AgencyService {
@Autowired
TbPlussUserAppMapper userAppMapper;
@Autowired
TbPlussMerchantChannelMapper tbPlussMerchantChannelMapper;
@Autowired
TbPlussMerchantChannelStatusMapper tbPlussMerchantChannelStatusMapper;
@Autowired
TbPlussMerchantBackLklMapper tbPlussMerchantBackLklMapper;
@ -164,11 +169,30 @@ public class AgencyService {
it.put("sumfansShareMoney",0);
it.put("yestedayShareMoney",0);
}
List<Map<String,Object>> list1=new ArrayList<>();
List<TbPlussMerchantChannel> channels= tbPlussMerchantChannelMapper.selectAll();
if(ObjectUtil.isNotEmpty(channels)&&channels.size()>0){
for (TbPlussMerchantChannel channel : channels) {
Map<String,Object> hashMap=new HashMap<>();
hashMap.put("channelname",channel.getChannelname());
hashMap.put("channelcode",channel.getChannelcode());
hashMap.put("channel",channel.getId());
Map<String,Object> baseInfo=tbPlussMerchantChannelStatusMapper.selectByUserId(id,channel.getId().toString());
if(ObjectUtil.isNotEmpty(baseInfo)&&baseInfo.size()>0){
if(5==channel.getId()&&"3".equals(baseInfo.get("status").toString())&&ObjectUtil.isNotEmpty(baseInfo.get("merchantId"))){
TbPlussMerchantBackLkl backLkl= tbPlussMerchantBackLklMapper.selectByMercdeMerId(it.get("merchantCode").toString(),baseInfo.get("merchantId").toString());
if(ObjectUtil.isNotEmpty(backLkl)){
baseInfo.put("merchantId",backLkl.getExternalCustomerNo());
}
}
switch ("channel"){
}
hashMap.put("baseInfo",baseInfo);
list1.add(hashMap);
}
}
it.put("merchantChannel",list1);
}
);
}

View File

@ -0,0 +1,157 @@
package com.chaozhanggui.admin.system.util;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSONObject;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriComponents;
import org.springframework.web.util.UriComponentsBuilder;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.List;
import java.util.Map;
import java.util.UUID;
/**
* @author admin
* @date 2021/3/18 14:28
*/
public class HttpUtils extends HttpRequest {
public HttpUtils(String url) {
super(url);
}
public static String post(String url,String param){
if(ObjectUtil.isNotEmpty(param)){
return HttpRequest.post(url).header("Content-type","application/x-www-form-urlencoded").body(param).execute().body();
}
return HttpRequest.post(url).header("Content-type","application/x-www-form-urlencoded").execute().body();
}
public static String get(String url,String param){
if(ObjectUtil.isNotEmpty(param)){
return HttpRequest.get(url).header("Content-type","application/json").body(param).execute().body();
}
return HttpRequest.get(url).execute().body();
}
/**
* 向指定URL发送GET方法的请求
*
* @param url 发送请求的URL
* @param param 请求参数请求参数应该是 name1=value1&name2=value2 的形式
* @return URL 所代表远程资源的响应结果
*/
public static String sendGet(String url, String param) {
String result = "";
BufferedReader in = null;
try {
String urlNameString = url + "?" + param;
URL realUrl = new URL(urlNameString);
// 打开和URL之间的连接
URLConnection connection = realUrl.openConnection();
// 设置通用的请求属性
connection.setRequestProperty("accept", "*/*");
connection.setRequestProperty("connection", "Keep-Alive");
connection.setRequestProperty("user-agent",
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
// 建立实际的连接
connection.connect();
// 获取所有响应头字段
Map<String, List<String>> map = connection.getHeaderFields();
// 遍历所有的响应头字段
for (String key : map.keySet()) {
System.out.println(key + "--->" + map.get(key));
}
// 定义 BufferedReader输入流来读取URL的响应
in = new BufferedReader(new InputStreamReader(
connection.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result += line;
}
} catch (Exception e) {
System.out.println("发送GET请求出现异常" + e);
e.printStackTrace();
}
// 使用finally块来关闭输入流
finally {
try {
if (in != null) {
in.close();
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
return result;
}
private static JSONObject get4GCommonMessageParams() {
JSONObject params = new JSONObject();
params.put("appId", "ZF544");
params.put("timestamp", System.currentTimeMillis());
String requestId = UUID.randomUUID().toString();
params.put("requestId", requestId);
params.put("userCode", "ZF544");
String signContent = SignUtils.getSignContent1(params, "2022bsjZF544GAH");
String token = MD5Util.MD5Encode(signContent, "UTF-8").toUpperCase();
params.put("token", token);
return params;
}
public static void main(String[] args){
// JSONObject body= get4GCommonMessageParams();
//
//// body.put("devName", "ZF544CG02S00001");
//// body.put("cloudType","2");
//// UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("https://ioe.car900.com/v1/openApi/dev/registerCloud.json");
//// body.forEach((s, o) -> {
//// try {
//// builder.queryParam(s, URLEncoder.encode(o.toString(), "UTF-8"));
//// } catch (UnsupportedEncodingException e) {
//// e.printStackTrace();
//// }
//// });
//// UriComponents uriComponents = builder.build(true);
//// String response =new RestTemplate().getForObject(uriComponents.toUri(), String.class);
//// System.out.println(response);
//
//
// body= get4GCommonMessageParams();
// body.put("devName", "ZF544CG02S00001");
// body.put("biz_type", "2");
// body.put("money", "哈哈哈哈哈哈哈哈哈哈");
// body.put("content","哈哈哈哈哈哈哈哈哈哈");
// body.put("broadCastType", "16");
//
//
//// System.out.println(sendGet("https://ioe.car900.com/v1/openApi/dev/controlDevice.json",body.toJSONString()));
//
//
// UriComponentsBuilder builder = UriComponentsBuilder.fromHttpUrl("https://ioe.car900.com/v1/openApi/dev/controlDevice.json");
// body.forEach((s, o) -> {
// try {
// builder.queryParam(s, URLEncoder.encode(o.toString(), "UTF-8"));
// } catch (UnsupportedEncodingException e) {
// e.printStackTrace();
// }
// });
// UriComponents uriComponents = builder.build(true);
// String response =new RestTemplate().getForObject(uriComponents.toUri(), String.class);
// System.out.println(response);
}
}

View File

@ -0,0 +1,158 @@
package com.chaozhanggui.admin.system.util;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.digest.DigestUtils;
import javax.crypto.Mac;
import javax.crypto.spec.SecretKeySpec;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.util.Map;
import java.util.TreeMap;
/**
* 签名工具类
*/
@Slf4j
public class SignUtils {
/**
* 获取签名之前的源串 按照ASCII 排序
*
* @param object
* @return
*/
public static String getSignContent(JSONObject object) {
TreeMap<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(object), TreeMap.class);
StringBuilder sb = new StringBuilder();
for (Map.Entry<String, Object> o : map.entrySet()) {
String key = o.getKey();
Object value = o.getValue();
if ("sign".contains(key)) {
continue;
}
if (value != null) {
sb.append(key).append("=").append(value).append("&");
// if(value instanceof ArrayList || value instanceof Map){
// sb.append(key).append("=").append(JSON.toJSONString(value)).append("&");
// }else{
// sb.append(key).append("=").append(value).append("&");
// }
}
}
sb.deleteCharAt(sb.length() - 1);
return sb.toString();
}
public static String wapGetSign(JSONObject object,String key) {
String checkSign = MD5Util.MD5Encode(getSignContent(object) + "&key=" + key, "UTF-8");
return checkSign;
}
/**
* 获取签名之前的源串 按照ASCII 排序
*
* @param object
* @return
*/
public static String getYSSignContent(JSONObject object) {
String s = JSONObject.toJSONString(object);
TreeMap<String, Object> map = JSONObject.parseObject(s, TreeMap.class);
StringBuilder sb = new StringBuilder();
for (Map.Entry<String, Object> o : map.entrySet()) {
String key = o.getKey();
Object value = o.getValue();
if ("sign".contains(key)) {
continue;
}
if (StringUtil.isNotEmpty(value)) {
sb.append(key).append("=").append(value).append("&");
}
}
sb.deleteCharAt(sb.length() - 1);
return sb.toString();
}
public static String getSignContent1(JSONObject object,String appSerct) {
TreeMap<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(object), TreeMap.class);
StringBuilder sb = new StringBuilder();
for (Map.Entry<String, Object> o : map.entrySet()) {
String key = o.getKey();
Object value = o.getValue();
if ("sign".contains(key)) {
continue;
}
if (StringUtil.isNotEmpty(value)) {
sb.append(key).append(value);
}
}
sb.append(appSerct);
return sb.toString();
}
public static String sha1Encrypt(String str) {
if (str == null || str.length() == 0) {
return null;
}
char[] hexDigits = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
'a', 'b', 'c', 'd', 'e', 'f' };
try {
MessageDigest mdTemp = MessageDigest.getInstance("SHA1");
mdTemp.update(str.getBytes(StandardCharsets.UTF_8));
byte[] md = mdTemp.digest();
int j = md.length;
char[] buf = new char[j * 2];
int k = 0;
for (byte byte0 : md) {
buf[k++] = hexDigits[byte0 >>> 4 & 0xf];
buf[k++] = hexDigits[byte0 & 0xf];
}
return new String(buf);
} catch (Exception e) {
return null;
}
}
public static String HMACSHA256BYTE(String data, String key) {
String hash = "";
try {
Mac sha256_HMAC = Mac.getInstance("HmacSHA256");
SecretKeySpec secret_key = new SecretKeySpec(key.getBytes(), "HmacSHA256");
sha256_HMAC.init(secret_key);
byte[] array = sha256_HMAC.doFinal(data.getBytes());
hash = Base64.encodeBase64String(array);
} catch (Exception e) {
e.printStackTrace();
}
return hash;
}
public static String getSignSha256(JSONObject params, String accessKeySecret) {
return HMACSHA256BYTE(getSignContent(params),accessKeySecret);
}
/**
* 获取圆通签名
* @date: 2022/2/24 17:00
* @param param:
* @param secret:
* @param method:
* @param version:
* @return java.lang.String
*/
public static String getYtSign(String param, String secret,String method,String version) {
String data = param + method + version;
String sign;
try {
byte[] signByte = DigestUtils.md5(data + secret);
sign = Base64.encodeBase64String(signByte);
} catch (Throwable e) {
log.error("加密失败.e:{}.", e.toString());
sign = "ERROR";
}
return sign;
}
}

View File

@ -1,7 +1,7 @@
spring:
datasource:
url: jdbc:mysql://60.205.224.68:3306/chaozhanggui?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=CTT&useSSL=false
username: root
url: jdbc:mysql://101.37.12.135:3306/ysk_test?useUnicode=true&characterEncoding=utf8&characterSetResults=utf8&useJDBCCompliantTimezoneShift=true&serverTimezone=CTT&useSSL=false
username: ysk_test
password: CZGmysqlroot@123
driver-class-name: com.mysql.cj.jdbc.Driver
initialSize: 5
@ -12,7 +12,7 @@ spring:
# redis数据库索引默认为0我们使用索引为3的数据库避免和其他数据库冲突
database: 0
# redis服务器地址默认为localhost
host: 127.0.0.1
host: 101.37.12.135
# redis端口默认为6379
port: 6379
# redis访问密码默认为空

View File

@ -1,6 +1,6 @@
spring:
profiles:
active: prod
active: dev
server:
port: 18071
servlet:

View File

@ -3,6 +3,7 @@ package com.chaozhanggui.dao.system.dao;
import com.chaozhanggui.dao.system.entity.TbPlussMerchantBackLkl;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
@Component
@ -19,4 +20,7 @@ public interface TbPlussMerchantBackLklMapper {
int updateByPrimaryKeySelective(TbPlussMerchantBackLkl record);
int updateByPrimaryKey(TbPlussMerchantBackLkl record);
TbPlussMerchantBackLkl selectByMercdeMerId(@Param("merchantCode") String merchantCode, @Param("merchantId") String merchantId);
}

View File

@ -5,6 +5,8 @@ import com.chaozhanggui.dao.system.entity.TbPlussMerchantChannel;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Component;
import java.util.List;
@Component
@Mapper
public interface TbPlussMerchantChannelMapper {
@ -19,4 +21,6 @@ public interface TbPlussMerchantChannelMapper {
int updateByPrimaryKeySelective(TbPlussMerchantChannel record);
int updateByPrimaryKey(TbPlussMerchantChannel record);
List<TbPlussMerchantChannel> selectAll();
}

View File

@ -3,8 +3,12 @@ package com.chaozhanggui.dao.system.dao;
import com.chaozhanggui.dao.system.entity.TbPlussMerchantChannelStatus;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
@Component
@Mapper
public interface TbPlussMerchantChannelStatusMapper {
@ -21,4 +25,9 @@ public interface TbPlussMerchantChannelStatusMapper {
int updateByPrimaryKeyWithBLOBs(TbPlussMerchantChannelStatus record);
int updateByPrimaryKey(TbPlussMerchantChannelStatus record);
Map<String,Object> selectByUserId(@Param("userId") String userId, @Param("channel") String channel);
}

View File

@ -1,5 +1,7 @@
package com.chaozhanggui.dao.system.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import java.util.Date;
@ -52,6 +54,16 @@ public class TbPlussMerchantChannelStatus implements Serializable {
private String extra;
@TableField(exist = false)
private String userId;
@TableField(exist = false)
private String channelCode;
@TableField(exist = false)
private String channelName;
private static final long serialVersionUID = 1L;
public Integer getId() {
@ -245,4 +257,28 @@ public class TbPlussMerchantChannelStatus implements Serializable {
public void setExtra(String extra) {
this.extra = extra == null ? null : extra.trim();
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getChannelCode() {
return channelCode;
}
public void setChannelCode(String channelCode) {
this.channelCode = channelCode;
}
public String getChannelName() {
return channelName;
}
public void setChannelName(String channelName) {
this.channelName = channelName;
}
}

View File

@ -196,4 +196,9 @@
update_time = #{updateTime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectByMercdeMerId" resultMap="BaseResultMap">
select * from tb_pluss_merchant_back_lkl where merchant_code=#{merchantCode} and merchant_id=#{merchantId}
</select>
</mapper>

View File

@ -90,4 +90,8 @@
wxCertImg = #{wxcertimg,jdbcType=VARCHAR}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectAll" resultMap="BaseResultMap">
select * from tb_pluss_merchant_channel where `status`=1
</select>
</mapper>

View File

@ -349,4 +349,27 @@
auditSuccessTime = #{auditsuccesstime,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=INTEGER}
</update>
<select id="selectByUserId" resultType="java.util.Map">
SELECT
b.userId,
b.merchantType,
case b.merchantType when '1' then '小微'
when '2' then '个体'
when '3' then '企业'
end as merchantTypeName,
b.alias,
c.channelCode,
c.channelName ,
s.`status`,
s.merchantId,
s.updateTime
FROM
tb_pluss_merchant_channel_status s
LEFT JOIN tb_pluss_merchant_base_info b ON s.merchantCode = b.merchantCode
left join tb_pluss_merchant_channel c on s.channel=c.id
where b.userId=#{userId} and s.channel=#{channel}
</select>
</mapper>

View File

@ -332,8 +332,8 @@
<select id="selectOrderByUserIdOrAgecyCode" resultType="java.util.Map">
SELECT
DISTINCT s.merchantCode,
p.user_id AS id,
u.loginName AS agencyCode,
a.userName AS agencyName,
@ -362,6 +362,7 @@
LEFT JOIN tb_pluss_user_info pr ON p.parent_user_id = pr.id
left join tb_pluss_user_app a on p.user_id=a.userId
left join tb_pluss_user_app pa on p.parent_user_id=pa.userId
left join tb_pluss_merchant_channel_status s on a.merchantCode=s.merchantCode
LEFT JOIN (
SELECT
i.userId,
@ -376,7 +377,6 @@
FIND_IN_SET( p.user_id, ID._ids )
AND p.type_code = 'MC'
AND p.user_id != #{userId}
<if test="agencyCode != null and agencyCode!=''">
and u.loginName = #{agencyCode}
</if>