订单管理--修改

pull/2/head
小小张 2023-05-12 10:19:46 +08:00
parent 693839a486
commit 29e43885c5
16 changed files with 54 additions and 489 deletions

View File

@ -75,17 +75,5 @@
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-member-biz</artifactId>
<version>1.7.2-snapshot</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-module-system-biz</artifactId>
<version>1.7.2-snapshot</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.shop.service.order.impl;
import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrderInfo;
import cn.iocoder.yudao.module.shop.dal.mysql.order.StoreOrderInfoMapper;
import cn.iocoder.yudao.module.shop.service.order.StoreOrderInfoService;
@ -7,7 +8,6 @@ import cn.iocoder.yudao.module.shop.service.product.StoreProductReplyService;
import cn.iocoder.yudao.module.shop.vo.order.OrderInfoDetailVo;
import cn.iocoder.yudao.module.shop.vo.order.StoreOrderInfoOldVo;
import cn.iocoder.yudao.module.shop.vo.order.StoreOrderInfoVo;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@ -58,7 +58,7 @@ public class StoreOrderInfoServiceImpl extends ServiceImpl<StoreOrderInfoMapper,
//解析商品详情JSON
StoreOrderInfoOldVo StoreOrderInfoVo = new StoreOrderInfoOldVo();
BeanUtils.copyProperties(storeOrderInfo, StoreOrderInfoVo, "info");
StoreOrderInfoVo.setInfo(JSON.parseObject(storeOrderInfo.getInfo(), OrderInfoDetailVo.class));
StoreOrderInfoVo.setInfo(JSONUtil.toBean(storeOrderInfo.getInfo(), OrderInfoDetailVo.class));
if(map.containsKey(storeOrderInfo.getOrderId())){
map.get(storeOrderInfo.getOrderId()).add(StoreOrderInfoVo);
}else{
@ -84,7 +84,7 @@ public class StoreOrderInfoServiceImpl extends ServiceImpl<StoreOrderInfoMapper,
//解析商品详情JSON
StoreOrderInfoOldVo storeOrderInfoVo = new StoreOrderInfoOldVo();
BeanUtils.copyProperties(storeOrderInfo, storeOrderInfoVo, "info");
storeOrderInfoVo.setInfo(JSON.parseObject(storeOrderInfo.getInfo(), OrderInfoDetailVo.class));
storeOrderInfoVo.setInfo(JSONUtil.toBean(storeOrderInfo.getInfo(), OrderInfoDetailVo.class));
storeOrderInfoVo.getInfo().setIsReply(
storeProductReplyService.isReply(storeOrderInfoVo.getUnique(), storeOrderInfoVo.getOrderId()) ? 1 : 0
);
@ -140,7 +140,7 @@ public class StoreOrderInfoServiceImpl extends ServiceImpl<StoreOrderInfoMapper,
//解析商品详情JSON
StoreOrderInfoVo storeOrderInfoVo = new StoreOrderInfoVo();
BeanUtils.copyProperties(storeOrderInfo, storeOrderInfoVo, "info");
storeOrderInfoVo.setInfo(JSON.parseObject(storeOrderInfo.getInfo(), OrderInfoDetailVo.class));
storeOrderInfoVo.setInfo(JSONUtil.toBean(storeOrderInfo.getInfo(), OrderInfoDetailVo.class));
storeOrderInfoVoList.add(storeOrderInfoVo);
}
return storeOrderInfoVoList;

View File

@ -2,20 +2,14 @@ package cn.iocoder.yudao.module.shop.service.order.impl;
import cn.iocoder.yudao.framework.common.enums.Constants;
import cn.iocoder.yudao.module.infra.api.config.ApiConfigApi;
import cn.iocoder.yudao.module.shop.constants.PayConstants;
import cn.iocoder.yudao.module.shop.controller.admin.order.vo.WxRefundVo;
import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrder;
import cn.iocoder.yudao.module.shop.dal.mysql.order.StoreOrderMapper;
import cn.iocoder.yudao.module.shop.request.order.StoreOrderRefundRequest;
import cn.iocoder.yudao.module.shop.service.order.StoreOrderRefundService;
import cn.iocoder.yudao.module.shop.service.wechat.WechatNewService;
import cn.iocoder.yudao.module.shop.utils.WxPayUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
/**
* StoreOrderServiceImpl
* +----------------------------------------------------------------------
@ -34,9 +28,6 @@ public class StoreOrderRefundServiceImpl extends ServiceImpl<StoreOrderMapper, S
@Autowired
private ApiConfigApi apiConfigApi;
@Autowired
private WechatNewService wechatNewService;
@Override
public void refund(StoreOrderRefundRequest request, StoreOrder storeOrder) {
refundWx(request, storeOrder);
@ -78,20 +69,7 @@ public class StoreOrderRefundServiceImpl extends ServiceImpl<StoreOrderMapper, S
String apiDomain = apiConfigApi.getConfigKey(Constants.CONFIG_KEY_API_URL).toString();
//统一下单数据
WxRefundVo wxRefundVo = new WxRefundVo();
wxRefundVo.setAppid(appId);
wxRefundVo.setMch_id(mchId);
wxRefundVo.setNonce_str(WxPayUtil.getNonceStr());
wxRefundVo.setOut_trade_no(storeOrder.getOutTradeNo());
wxRefundVo.setOut_refund_no(storeOrder.getOrderId());
wxRefundVo.setTotal_fee(storeOrder.getPayPrice().multiply(BigDecimal.TEN).multiply(BigDecimal.TEN).intValue());
wxRefundVo.setRefund_fee(request.getAmount().multiply(BigDecimal.TEN).multiply(BigDecimal.TEN).intValue());
wxRefundVo.setNotify_url(apiDomain + PayConstants.WX_PAY_REFUND_NOTIFY_API_URI);
String sign = WxPayUtil.getSign(wxRefundVo, signKey);
wxRefundVo.setSign(sign);
wechatNewService.payRefund(wxRefundVo, path);
// TODO 微信退款
}

View File

@ -9,8 +9,8 @@ import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.framework.common.pojo.DateLimitUtilVo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
import cn.iocoder.yudao.module.member.service.user.MemberUserService;
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrder;
import cn.iocoder.yudao.module.shop.dal.mysql.order.StoreOrderMapper;
import cn.iocoder.yudao.module.shop.request.order.StoreOrderRefundRequest;
@ -28,7 +28,6 @@ import cn.iocoder.yudao.module.shop.utils.RedisUtil;
import cn.iocoder.yudao.module.shop.vo.order.LogisticsResultVo;
import cn.iocoder.yudao.module.shop.vo.order.StoreDateRangeSqlPram;
import cn.iocoder.yudao.module.shop.vo.order.StoreOrderInfoOldVo;
import cn.iocoder.yudao.module.system.service.sms.SmsTemplateService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@ -73,7 +72,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
private StoreOrderInfoService StoreOrderInfoService;
@Autowired
private MemberUserService userService;
private MemberUserApi userService;
@Autowired
private StoreOrderStatusService storeOrderStatusService;
@ -93,9 +92,6 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
@Autowired
private StoreOrderInfoService storeOrderInfoService;
@Autowired
private SmsTemplateService smsTemplateService;
/**
* PC
*
@ -241,7 +237,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
}
request.setOrderId(storeOrder.getId());
//用户
MemberUserDO user = userService.getUser(storeOrder.getUid());
MemberUserRespDTO user = userService.getUser(storeOrder.getUid());
//退款
if (storeOrder.getPayType().equals(Constants.PAY_TYPE_WE_CHAT) && request.getAmount().compareTo(BigDecimal.ZERO) > 0) {
@ -303,7 +299,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
// }
//用户信息
MemberUserDO user = userService.getUser(storeOrder.getUid());
MemberUserRespDTO user = userService.getUser(storeOrder.getUid());
storeOrderInfoResponse.setNikeName(user.getNickname());
storeOrderInfoResponse.setPhone(user.getMobile());
@ -371,7 +367,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
storeOrder.setRefundReason(reason);
storeOrder.setRefundStatus(0);
MemberUserDO user = userService.getUser(storeOrder.getUid());
MemberUserRespDTO user = userService.getUser(storeOrder.getUid());
Boolean execute = transactionTemplate.execute(e -> {
updateById(storeOrder);
@ -1266,7 +1262,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
* @param storeOrder
*/
private void sendGoodsNotify(StoreOrder storeOrder) {
MemberUserDO user = userService.getUser(storeOrder.getUid());
MemberUserRespDTO user = userService.getUser(storeOrder.getUid());
//TODO 发送发货短信提醒
// 发送消息通知
@ -1314,7 +1310,7 @@ public class StoreOrderServiceImpl extends ServiceImpl<StoreOrderMapper, StoreOr
});
if (!execute) throw new ServiceException("订单更新送货失败");
MemberUserDO user = userService.getUser(storeOrder.getUid());
MemberUserRespDTO user = userService.getUser(storeOrder.getUid());
// TODO 发送消息通知
// pushMessageDeliveryOrder(storeOrder, user, request, productNameList);
}

View File

@ -9,8 +9,8 @@ import cn.iocoder.yudao.framework.common.enums.Constants;
import cn.iocoder.yudao.framework.common.exception.ServerException;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.module.infra.api.config.ApiConfigApi;
import cn.iocoder.yudao.module.member.dal.dataobject.user.MemberUserDO;
import cn.iocoder.yudao.module.member.dal.mysql.user.MemberUserMapper;
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO;
import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrder;
import cn.iocoder.yudao.module.shop.dal.dataobject.order.StoreOrderInfo;
import cn.iocoder.yudao.module.shop.service.order.StoreOrderInfoService;
@ -19,7 +19,6 @@ import cn.iocoder.yudao.module.shop.service.order.StoreOrderStatusService;
import cn.iocoder.yudao.module.shop.service.order.StoreOrderTaskService;
import cn.iocoder.yudao.module.shop.service.product.StoreProductAttrValueService;
import cn.iocoder.yudao.module.shop.service.product.StoreProductService;
import cn.iocoder.yudao.module.system.service.sms.SmsTemplateService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
@ -61,11 +60,12 @@ public class StoreOrderTaskServiceImpl implements StoreOrderTaskService {
private StoreOrderStatusService storeOrderStatusService;
@Autowired
private MemberUserMapper memberUserMapper;
private MemberUserApi memberUserApi;
@Autowired
private TransactionTemplate transactionTemplate;
@Autowired
private ApiConfigApi apiConfigApi;
@Autowired
@ -74,9 +74,6 @@ public class StoreOrderTaskServiceImpl implements StoreOrderTaskService {
@Autowired
private StoreProductAttrValueService attrValueService;
@Autowired
private SmsTemplateService smsTemplateService;
@Override
@Transactional(rollbackFor = {RuntimeException.class, Error.class, ServerException.class})
public Boolean cancelByUser(StoreOrder storeOrder) {
@ -144,7 +141,7 @@ public class StoreOrderTaskServiceImpl implements StoreOrderTaskService {
* 2-5user+userBill
*/
// 获取用户对象
MemberUserDO user = memberUserMapper.selectById(storeOrder.getUid());
MemberUserRespDTO user = memberUserApi.getUser(storeOrder.getUid());
if (ObjectUtil.isNull(user)) {
logger.error("订单退款处理,对应的用户不存在,storeOrder===>" + storeOrder);
return Boolean.FALSE;
@ -159,7 +156,7 @@ public class StoreOrderTaskServiceImpl implements StoreOrderTaskService {
storeOrderStatusService.saveRefund(storeOrder.getId(), storeOrder.getRefundPrice(), "成功");
// 更新用户数据
memberUserMapper.updateById(user);
memberUserApi.updateById(user);
// 回滚库存
rollbackStock(storeOrder);

View File

@ -1,28 +0,0 @@
package cn.iocoder.yudao.module.shop.service.wechat;
import cn.iocoder.yudao.module.shop.controller.admin.order.vo.WxRefundResponseVo;
import cn.iocoder.yudao.module.shop.controller.admin.order.vo.WxRefundVo;
/**
*
* +----------------------------------------------------------------------
* | CRMEB [ CRMEB ]
* +----------------------------------------------------------------------
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
* +----------------------------------------------------------------------
* | Licensed CRMEBCRMEB
* +----------------------------------------------------------------------
* | Author: CRMEB Team <admin@crmeb.com>
* +----------------------------------------------------------------------
*/
public interface WechatNewService {
/**
* 退
* @param wxRefundVo 退
* @param path p12
* @return 退
*/
WxRefundResponseVo payRefund(WxRefundVo wxRefundVo, String path);
}

View File

@ -1,102 +0,0 @@
package cn.iocoder.yudao.module.shop.service.wechat.impl;
import cn.iocoder.yudao.framework.common.exception.ServiceException;
import cn.iocoder.yudao.module.shop.constants.WeChatConstants;
import cn.iocoder.yudao.module.shop.controller.admin.order.vo.WxRefundResponseVo;
import cn.iocoder.yudao.module.shop.controller.admin.order.vo.WxRefundVo;
import cn.iocoder.yudao.module.shop.service.wechat.WechatNewService;
import cn.iocoder.yudao.module.shop.utils.CrmebUtil;
import cn.iocoder.yudao.module.shop.utils.RedisUtil;
import cn.iocoder.yudao.module.shop.utils.RestTemplateUtil;
import cn.iocoder.yudao.module.shop.utils.XmlUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
/**
*
* +----------------------------------------------------------------------
* | CRMEB [ CRMEB ]
* +----------------------------------------------------------------------
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
* +----------------------------------------------------------------------
* | Licensed CRMEBCRMEB
* +----------------------------------------------------------------------
* | Author: CRMEB Team <admin@crmeb.com>
* +----------------------------------------------------------------------
*/
@Service
public class WechatNewServiceImpl implements WechatNewService {
private static final Logger logger = LoggerFactory.getLogger(WechatNewServiceImpl.class);
@Autowired
private RedisUtil redisUtil;
@Autowired
private RestTemplateUtil restTemplateUtil;
/**
* 退
* @param wxRefundVo 退
* @param path p12
* @return 退
*/
@Override
public WxRefundResponseVo payRefund(WxRefundVo wxRefundVo, String path) {
String xmlStr = XmlUtil.objectToXml(wxRefundVo);
String url = WeChatConstants.PAY_API_URL + WeChatConstants.PAY_REFUND_API_URI_WECHAT;
HashMap<String, Object> map = new HashMap<>();
String xml = "";
try {
xml = restTemplateUtil.postWXRefundXml(url, xmlStr, wxRefundVo.getMch_id(), path);
map = XmlUtil.xmlToMap(xml);
} catch (Exception e) {
e.printStackTrace();
throw new ServiceException("xmlToMap错误xml = " + xml);
}
if (null == map) {
throw new ServiceException("微信无信息返回,微信申请退款失败!");
}
WxRefundResponseVo responseVo = CrmebUtil.mapToObj(map, WxRefundResponseVo.class);
if (responseVo.getReturnCode().toUpperCase().equals("FAIL")) {
// wxPayExceptionDispose(map, "微信申请退款异常1");
throw new ServiceException("微信申请退款失败1" + responseVo.getReturnMsg());
}
if (responseVo.getResultCode().toUpperCase().equals("FAIL")) {
// wxPayExceptionDispose(map, "微信申请退款业务异常");
throw new ServiceException("微信申请退款失败2" + responseVo.getErrCodeDes());
}
System.out.println("================微信申请退款结束=========================");
return responseVo;
}
/**
*
* @param map
* @param remark
*/
// private void wxPayExceptionDispose(HashMap<String, Object> map, String remark) {
// WechatExceptions wechatExceptions = new WechatExceptions();
// String returnCode = (String) map.get("return_code");
// if (returnCode.toUpperCase().equals("FAIL")) {
// wechatExceptions.setErrcode("-100");
// wechatExceptions.setErrmsg(map.get("return_msg").toString());
// } else {
// wechatExceptions.setErrcode(map.get("err_code").toString());
// wechatExceptions.setErrmsg(map.get("err_code_des").toString());
// }
// wechatExceptions.setData(JSONObject.toJSONString(map));
// wechatExceptions.setRemark(remark);
// wechatExceptions.setCreateTime(DateUtil.date());
// wechatExceptions.setUpdateTime(DateUtil.date());
// wechatExceptionsService.save(wechatExceptions);
// }
}

View File

@ -2,8 +2,8 @@ package cn.iocoder.yudao.module.shop.utils;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.json.JSONUtil;
import cn.iocoder.yudao.framework.common.enums.Constants;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.lang3.StringUtils;
import javax.crypto.Cipher;
@ -62,7 +62,7 @@ public class CrmebUtil {
*/
public static <T> T mapToObj(HashMap<String,Object> map, Class<T> clz){
if (map == null) return null;
return JSONObject.parseObject(JSONObject.toJSONString(map), clz);
return JSONUtil.toBean(JSONUtil.toJsonStr(map), clz);
}
/**

View File

@ -1,111 +0,0 @@
package cn.iocoder.yudao.module.shop.utils;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.config.RegistryBuilder;
import org.apache.http.conn.socket.ConnectionSocketFactory;
import org.apache.http.conn.socket.PlainConnectionSocketFactory;
import org.apache.http.conn.ssl.DefaultHostnameVerifier;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.conn.BasicHttpClientConnectionManager;
import org.apache.http.util.EntityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;
import javax.net.ssl.KeyManagerFactory;
import javax.net.ssl.SSLContext;
import java.io.FileInputStream;
import java.security.KeyStore;
import java.security.SecureRandom;
/**
* +----------------------------------------------------------------------
* | CRMEB [ CRMEB ]
* +----------------------------------------------------------------------
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
* +----------------------------------------------------------------------
* | Licensed CRMEBCRMEB
* +----------------------------------------------------------------------
* | Author: CRMEB Team <admin@crmeb.com>
* +----------------------------------------------------------------------
* httpClient
*/
@Component
public class RestTemplateUtil {
@Autowired
private RestTemplate restTemplate;
public static final String WXPAYSDK_VERSION = "WXPaySDK/3.0.9";
public static final String USER_AGENT = WXPAYSDK_VERSION +
" (" + System.getProperty("os.arch") + " " + System.getProperty("os.name") + " " + System.getProperty("os.version") +
") Java/" + System.getProperty("java.version") + " HttpClient/" + HttpClient.class.getPackage().getImplementationVersion();
/**
* POST-JSON(退)
*
* @param url
* @return
*/
public String postWXRefundXml(String url, String xml, String mchId, String path) throws Exception {
KeyStore clientStore = KeyStore.getInstance("PKCS12");
// 读取本机存放的PKCS12证书文件
FileInputStream instream = new FileInputStream(path);
try {
// 指定PKCS12的密码(商户ID)
clientStore.load(instream, mchId.toCharArray());
} finally {
instream.close();
}
// 实例化密钥库 & 初始化密钥工厂
KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
kmf.init(clientStore, mchId.toCharArray());
// 创建 SSLContext
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(kmf.getKeyManagers(), null, new SecureRandom());
SSLConnectionSocketFactory sslConnectionSocketFactory = new SSLConnectionSocketFactory(
sslContext,
// new String[]{"TLSv1"},
// null,
new DefaultHostnameVerifier());
BasicHttpClientConnectionManager connManager = new BasicHttpClientConnectionManager(
RegistryBuilder.<ConnectionSocketFactory>create()
.register("http", PlainConnectionSocketFactory.getSocketFactory())
.register("https", sslConnectionSocketFactory)
.build(),
null,
null,
null
);
HttpClient httpClient = HttpClientBuilder.create()
.setConnectionManager(connManager)
.build();
HttpPost httpPost = new HttpPost(url);
RequestConfig requestConfig = RequestConfig.custom().setSocketTimeout(8*1000).setConnectTimeout(6*1000).build();
httpPost.setConfig(requestConfig);
StringEntity postEntity = new StringEntity(xml, "UTF-8");
httpPost.addHeader("Content-Type", "text/xml");
httpPost.addHeader("User-Agent", USER_AGENT + " " + mchId);
httpPost.setEntity(postEntity);
HttpResponse httpResponse = httpClient.execute(httpPost);
org.apache.http.HttpEntity httpEntity = httpResponse.getEntity();
return EntityUtils.toString(httpEntity, "UTF-8");
}
}

View File

@ -1,88 +0,0 @@
package cn.iocoder.yudao.module.shop.utils;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.crypto.SecureUtil;
import cn.iocoder.yudao.module.shop.constants.PayConstants;
import cn.iocoder.yudao.module.shop.controller.admin.order.vo.WxRefundVo;
import com.alibaba.fastjson.JSONObject;
import org.apache.commons.codec.digest.DigestUtils;
import java.util.Arrays;
import java.util.Map;
import java.util.Set;
/**
*
* +----------------------------------------------------------------------
* | CRMEB [ CRMEB ]
* +----------------------------------------------------------------------
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
* +----------------------------------------------------------------------
* | Licensed CRMEBCRMEB
* +----------------------------------------------------------------------
* | Author: CRMEB Team <admin@crmeb.com>
* +----------------------------------------------------------------------
*/
public class WxPayUtil {
/**
* sign
* @param wxRefundVo 退
* @param signKey key
* @return String
*/
public static String getSign(WxRefundVo wxRefundVo, String signKey) {
// 对象转map
Map<String, Object> map = JSONObject.parseObject(JSONObject.toJSONString(wxRefundVo), Map.class);
// map排序
Set<String> keySet = map.keySet();
String[] keyArray = keySet.toArray(new String[keySet.size()]);
Arrays.sort(keyArray);
StringBuilder sb = new StringBuilder();
for (String k : keyArray) {
if (k.equals(PayConstants.FIELD_SIGN)) {
continue;
}
if (ObjectUtil.isNotNull(map.get(k))) // 参数值为空,则不参与签名
sb.append(k).append("=").append(map.get(k)).append("&");
}
sb.append("key=").append(signKey);
String sign = SecureUtil.md5(sb.toString()).toUpperCase();
System.out.println("sign ========== " + sign);
return sign;
}
/**
* sign
* @param map
* @param signKey key
* @return String
*/
public static String getSign(Map<String, String> map, String signKey) {
// map排序
Set<String> keySet = map.keySet();
String[] keyArray = keySet.toArray(new String[keySet.size()]);
Arrays.sort(keyArray);
StringBuilder sb = new StringBuilder();
for (String k : keyArray) {
if (k.equals(PayConstants.FIELD_SIGN)) {
continue;
}
if (StrUtil.isNotBlank(map.get(k)) && map.get(k).trim().length() > 0) // 参数值为空,则不参与签名
sb.append(k).append("=").append(map.get(k).trim()).append("&");
}
sb.append("key=").append(signKey);
String sign = SecureUtil.md5(sb.toString()).toUpperCase();
System.out.println("sign ========== " + sign);
return sign;
}
/**
* 32
*/
public static String getNonceStr() {
return DigestUtils.md5Hex(CrmebUtil.getUuid() + CrmebUtil.randomCount(111111, 666666));
}
}

View File

@ -1,95 +0,0 @@
package cn.iocoder.yudao.module.shop.utils;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.naming.NoNameCoder;
import com.thoughtworks.xstream.io.xml.Xpp3Driver;
import org.apache.commons.lang3.StringUtils;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import javax.servlet.http.HttpServletRequest;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* XML
* +----------------------------------------------------------------------
* | CRMEB [ CRMEB ]
* +----------------------------------------------------------------------
* | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
* +----------------------------------------------------------------------
* | Licensed CRMEBCRMEB
* +----------------------------------------------------------------------
* | Author: CRMEB Team <admin@crmeb.com>
* +----------------------------------------------------------------------
*/
public class XmlUtil {
public static Map<String, String> xmlToMap(HttpServletRequest request) {
Map<String, String> map = new HashMap<>();
SAXReader reader = new SAXReader();
InputStream in = null;
try {
in = request.getInputStream();
Document doc = reader.read(in);
Element root = doc.getRootElement();
List<Element> list = root.elements();
for (Element element : list) {
map.put(element.getName(), element.getText());
}
} catch (IOException | DocumentException e) {
e.printStackTrace();
} finally {
try {
assert in != null;
in.close();
} catch (IOException e) {
e.printStackTrace();
}
}
return map;
}
/**
* xml
*/
public static HashMap<String, Object> xmlToMap(String strxml) throws Exception {
strxml = strxml.replaceFirst("encoding=\".*\"", "encoding=\"UTF-8\"");
HashMap<String, Object> map = new HashMap<>();
SAXReader reader = new SAXReader();
InputStream inputStream = new ByteArrayInputStream(strxml.getBytes(StandardCharsets.UTF_8));
if (StringUtils.isBlank(strxml)) {
return null;
}
Document document = reader.read(inputStream);
Element root = document.getRootElement();
List<Element> list = root.elements();
for (Element e : list) {
map.put(e.getName(), e.getText());
}
inputStream.close();
return map;
}
/**
* xml
*/
public static String objectToXml(Object object) {
XStream xstream = new XStream(new Xpp3Driver(new NoNameCoder())); //不需要转义
xstream.alias("xml", object.getClass());
return xstream.toXML(object);
}
}

View File

@ -57,4 +57,11 @@ public interface MemberUserApi {
*/
MemberUserRespDTO getUserByMobile(String mobile);
/**
* ID
* @param member
* @return
*/
int updateById(MemberUserRespDTO member);
}

View File

@ -44,4 +44,9 @@ public class MemberUserApiImpl implements MemberUserApi {
return UserConvert.INSTANCE.convert2(userService.getUserByMobile(mobile));
}
@Override
public int updateById(MemberUserRespDTO member) {
return userService.updateById(UserConvert.INSTANCE.convert3(member));
}
}

View File

@ -17,6 +17,7 @@ public interface UserConvert {
AppUserInfoRespVO convert(MemberUserDO bean);
AdminUserInfoRespVO convertAdmin(MemberUserDO bean);
MemberUserRespDTO convert2(MemberUserDO bean);
MemberUserDO convert3(MemberUserRespDTO bean);
List<MemberUserRespDTO> convertList2(List<MemberUserDO> list);

View File

@ -109,4 +109,11 @@ public interface MemberUserService {
*/
PageResult<MemberUserDO> findPageList(AdminUserQueryDTO queryDTO);
/**
* ID
* @param member
* @return
*/
int updateById(MemberUserDO member);
}

View File

@ -21,10 +21,9 @@ import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.io.InputStream;
import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP;
@ -159,6 +158,17 @@ public class MemberUserServiceImpl implements MemberUserService {
PageResult<MemberUserDO> commonLableEntityList = memberUserMapper.selectPage(queryDTO);
return commonLableEntityList;
}
/**
* ID
* @param member
* @return
*/
@Override
public int updateById(MemberUserDO member) {
return memberUserMapper.updateById(member);
}
/**
*
*