Commit c6e5b0f2 by 张新旗

增加退款失败,和发送短信接入

parent 771078ff
......@@ -8,6 +8,7 @@ import com.soss.system.mapper.OrderMapper;
import com.soss.system.service.impl.AppServiceImpl;
import com.soss.system.service.impl.OrderServiceImpl;
import com.soss.system.service.impl.OrderTakingServiceImpl;
import com.soss.system.utils.SendSmsUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
......@@ -112,4 +113,6 @@ public class WeixinController {
return weixinService.refundNotify(xmlData);
}
}
......@@ -171,6 +171,7 @@ public class WeixinServiceImpl {
LoginUser loginUser = new LoginUser(user,null);
loginUser.setLoginTime(System.currentTimeMillis());
loginUser.setOpenId(customer.getId());
user.setPhonenumber(customer.getPhone());
return loginUser;
}
......@@ -524,6 +525,30 @@ public class WeixinServiceImpl {
// */
// return WxPayNotifyResponse.success("退款成功!");
// }
}else{
WxPayRefundNotifyResult.ReqInfo reqInfo = wxPayRefundNotifyResult.getReqInfo();
String outRefundNo = reqInfo.getOutRefundNo();
OrderRefund orderRefund = new OrderRefund();
orderRefund.setRefundNo(outRefundNo);
List<OrderRefund> orderRefunds = orderRefundMapper.selectOrderRefundList(orderRefund);
if(orderRefunds.isEmpty()){
log.error("找不到该退款订单:【{}】",outRefundNo);
return WxPayNotifyResponse.fail("退款失败");
}
OrderRefund orderRefund1 = orderRefunds.get(0);
Order order = orderService.selectById(orderRefund1.getOrderId());
if("1".equals(orderRefund1.getState())){
orderRefund1.setState("3");
orderRefundMapper.updateOrderRefund(orderRefund1);
OrderOperationLog orderOperationLog = new OrderOperationLog();
orderOperationLog.setOrderId(orderRefund1.getOrderId());
order.setState(OrderStatusConstant.refundFailed);
orderRefund1.setOrder(order);
orderService.updateOrder(order);
orderOperationLogService.insertOrderOperationLog(orderRefund1);
return WxPayNotifyResponse.success("");
}
}
return WxPayNotifyResponse.fail("回调有误!");
}
......
......@@ -24,6 +24,7 @@ import com.soss.system.jiguang.impl.JiGuangPushServiceImpl;
import com.soss.system.service.IOrderService;
import com.soss.system.domain.vo.OrderQuery;
import com.soss.system.mapper.*;
import com.soss.system.utils.SendSmsUtil;
import com.soss.system.weixin.util.SendMessageUtils;
import org.aspectj.weaver.ast.Or;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -72,7 +73,8 @@ public class OrderServiceImpl implements IOrderService
@Autowired
private CustomerMapper customerMapper;
@Autowired
SendSmsUtil sendSmsUtil;
/**
* 查询订单
......@@ -137,6 +139,7 @@ public class OrderServiceImpl implements IOrderService
order.setState(OrderStatusConstant.Unpaid);
order.setUserId(loginUser.getOpenId());
order.setUserName(loginUser.getUsername());
order.setUserPhone(loginUser.getUser().getPhonenumber());
order.setCreatedAt(new Date());
order.setOrderNum(getOrderNum(order.getShopId()));
order.setOrderNo(getOrderNo(order.getSource()));
......@@ -245,11 +248,8 @@ public class OrderServiceImpl implements IOrderService
order.setFinishTime(new Date());
orderOperationLogService.insertOrderOperationLog(order);
jiGuangPushService.pushOrderState(order);
Customer customer = customerMapper.selectCustomerById(order.getUserId());
sendMessageUtils.sendWxMsg(order);
if(!"1".equals(customer.getAllow())){
}
}
......@@ -301,6 +301,10 @@ public class OrderServiceImpl implements IOrderService
jiGuangPushService.pushOrderState(order);
wechatMessageService.insertWechatMessage(order.getUserId(),"制作完成,您的订单已经制作完成,现在可以去取餐啦!");
sendMessageUtils.sendWxMsg(order);
Customer customer = customerMapper.selectCustomerById(order.getUserId());
if(!"1".equals(customer.getAllow())){
sendSmsUtil.sendSms(order.getUserPhone(),"SMS_243650242",null);
}
}
......
......@@ -36,44 +36,49 @@ public class SendSmsUtil {
//phone:要发送的手机号
//templateCode:申请的短信模板
//paramsJson:模板里面的参数和对应的值,处理成json字符串直接传进来
public Boolean sendSms(String phone, String templateCode, String paramsJson) throws ClientException {
// 超时时间
System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
System.setProperty("sun.net.client.defaultReadTimeout", "10000");
public Boolean sendSms(String phone, String templateCode, String paramsJson) {
try {
// 超时时间
System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
System.setProperty("sun.net.client.defaultReadTimeout", "10000");
// 初始化acsClient,暂不支持region化
IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret);
DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
IAcsClient acsClient = new DefaultAcsClient(profile);
// 初始化acsClient,暂不支持region化
IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", accessKeyId, accessKeySecret);
DefaultProfile.addEndpoint("cn-hangzhou", "cn-hangzhou", product, domain);
IAcsClient acsClient = new DefaultAcsClient(profile);
// 组装请求对象-具体描述见控制台-文档部分内容
SendSmsRequest request = new SendSmsRequest();
// 必填:待发送手机号
request.setPhoneNumbers(phone);
// 必填:短信签名-可在短信控制台中找到
request.setSignName(signName);
// 必填:短信模板code-可在短信控制台中找到
request.setTemplateCode(templateCode);
// 可选:模板中的变量替换JSON串
request.setTemplateParam(paramsJson);
// 组装请求对象-具体描述见控制台-文档部分内容
SendSmsRequest request = new SendSmsRequest();
// 必填:待发送手机号
request.setPhoneNumbers(phone);
// 必填:短信签名-可在短信控制台中找到
request.setSignName(signName);
// 必填:短信模板code-可在短信控制台中找到
request.setTemplateCode(templateCode);
// 可选:模板中的变量替换JSON串
request.setTemplateParam(paramsJson);
//可能会抛出异常,try catch一下
SendSmsResponse sendSmsResponse;
try {
//调用阿里云短信服务
sendSmsResponse = acsClient.getAcsResponse(request);
} catch (Exception e) {
e.printStackTrace();
log.error("调用阿里云短信服务异常!异常信息:" + e.getMessage());
return false;
}
//可能会抛出异常,try catch一下
SendSmsResponse sendSmsResponse;
try {
//调用阿里云短信服务
sendSmsResponse = acsClient.getAcsResponse(request);
} catch (Exception e) {
e.printStackTrace();
log.error("调用阿里云短信服务异常!异常信息:" + e.getMessage());
return false;
}
Boolean result;
if (result = sendSmsResponse.getCode() != null && sendSmsResponse.getCode().equals("OK")) {
log.info("短信发送成功!内容:" + sendSmsResponse.getMessage());
} else {
log.error("短信发送失败!异常信息:" + sendSmsResponse.getMessage());
Boolean result;
if (result = sendSmsResponse.getCode() != null && sendSmsResponse.getCode().equals("OK")) {
log.info("短信发送成功!内容:" + sendSmsResponse.getMessage());
} else {
log.error("短信发送失败!异常信息:" + sendSmsResponse.getMessage());
}
return result;
}catch (Exception e){
log.error("发送短信失败",e);
}
return result;
return null;
}
}
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