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,7 +36,8 @@ public class SendSmsUtil {
//phone:要发送的手机号
//templateCode:申请的短信模板
//paramsJson:模板里面的参数和对应的值,处理成json字符串直接传进来
public Boolean sendSms(String phone, String templateCode, String paramsJson) throws ClientException {
public Boolean sendSms(String phone, String templateCode, String paramsJson) {
try {
// 超时时间
System.setProperty("sun.net.client.defaultConnectTimeout", "10000");
System.setProperty("sun.net.client.defaultReadTimeout", "10000");
......@@ -75,5 +76,9 @@ public class SendSmsUtil {
log.error("短信发送失败!异常信息:" + sendSmsResponse.getMessage());
}
return result;
}catch (Exception e){
log.error("发送短信失败",e);
}
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