退款功能增加
This commit is contained in:
parent
4fd5d1dbaa
commit
c095746fba
|
|
@ -25,6 +25,9 @@ import cn.pluss.platform.yt.YtLogistHandler;
|
||||||
import cn.pluss.platform.yt.YtStatusEnum;
|
import cn.pluss.platform.yt.YtStatusEnum;
|
||||||
import cn.pluss.platform.yt.constant.YtConstant;
|
import cn.pluss.platform.yt.constant.YtConstant;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.aliyun.dysmsapi20170525.Client;
|
||||||
|
import com.aliyun.dysmsapi20170525.models.SendSmsResponse;
|
||||||
|
import com.aliyun.teaopenapi.models.Config;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||||
|
|
@ -35,6 +38,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
|
@ -91,30 +95,43 @@ public class MercOrderDetailServiceImpl extends ServiceImpl<MercOrderDetailMappe
|
||||||
@Resource
|
@Resource
|
||||||
private OpenAccountRecordService openAccountRecordService;
|
private OpenAccountRecordService openAccountRecordService;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 阿里云key
|
||||||
|
*/
|
||||||
|
@Value("${aliyun.keyid}")
|
||||||
|
private String ACCESSKEYID;
|
||||||
|
/**
|
||||||
|
* 阿里云secret
|
||||||
|
*/
|
||||||
|
@Value("${aliyun.keysecret}")
|
||||||
|
private String ACCESSKEYSECRET;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void receiving(Long id) {
|
public void receiving(Long id) {
|
||||||
MercOrderDetail detail = baseMapper.selectById(id);
|
MercOrderDetail detail = baseMapper.selectById(id);
|
||||||
MsgException.checkNull(detail,"订单数据异常");
|
MsgException.checkNull(detail, "订单数据异常");
|
||||||
detail.setStatus(DeviceOrderStatus.COMPLETED.getStatus());
|
detail.setStatus(DeviceOrderStatus.COMPLETED.getStatus());
|
||||||
baseMapper.updateById(detail);
|
baseMapper.updateById(detail);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查看物流信息
|
* 查看物流信息
|
||||||
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public MercOrderExpressVO getOrderExpressInfo(Long id) {
|
public MercOrderExpressVO getOrderExpressInfo(Long id) {
|
||||||
MercOrderDetail detail = baseMapper.selectById(id);
|
MercOrderDetail detail = baseMapper.selectById(id);
|
||||||
MsgException.checkNull(detail,"订单详情数据异常");
|
MsgException.checkNull(detail, "订单详情数据异常");
|
||||||
MercOrderExpressVO vo = moeMapper.getByExpressNo(detail.getExpressNo());
|
MercOrderExpressVO vo = moeMapper.getByExpressNo(detail.getExpressNo());
|
||||||
|
|
||||||
if(vo != null){
|
if (vo != null) {
|
||||||
vo.setServiceTelephone(YtConstant.YT_CUSTOMER_TELEPHONE);
|
vo.setServiceTelephone(YtConstant.YT_CUSTOMER_TELEPHONE);
|
||||||
List<MercOrderExpressDetail> list = moedMapper.getByExpressNo(detail.getExpressNo());
|
List<MercOrderExpressDetail> list = moedMapper.getByExpressNo(detail.getExpressNo());
|
||||||
vo.setExpressDetailList(list);
|
vo.setExpressDetailList(list);
|
||||||
if(!list.isEmpty()){
|
if (!list.isEmpty()) {
|
||||||
vo.setLogisticProvider(list.get(0).getLogisticProvider());
|
vo.setLogisticProvider(list.get(0).getLogisticProvider());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -123,23 +140,24 @@ public class MercOrderDetailServiceImpl extends ServiceImpl<MercOrderDetailMappe
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据订单号查询订单详情
|
* 根据订单号查询订单详情
|
||||||
|
*
|
||||||
* @param orderNo
|
* @param orderNo
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<MercOrderDetail> getDetailByOrderNo(String orderNo,String status) {
|
public List<MercOrderDetail> getDetailByOrderNo(String orderNo, String status) {
|
||||||
QueryWrapper<MercOrderDetail> queryWrapper = new QueryWrapper<MercOrderDetail>()
|
QueryWrapper<MercOrderDetail> queryWrapper = new QueryWrapper<MercOrderDetail>()
|
||||||
.eq("orderNo",orderNo).orderByDesc("id");
|
.eq("orderNo", orderNo).orderByDesc("id");
|
||||||
if(StringUtil.isNotEmpty(status) && !"-1".equals(status)){
|
if (StringUtil.isNotEmpty(status) && !"-1".equals(status)) {
|
||||||
switch (status){
|
switch (status) {
|
||||||
case "1":
|
case "1":
|
||||||
queryWrapper.eq("status",DeviceOrderStatus.COMPLETED.getStatus());
|
queryWrapper.eq("status", DeviceOrderStatus.COMPLETED.getStatus());
|
||||||
break;
|
break;
|
||||||
case "2":
|
case "2":
|
||||||
queryWrapper.eq("status",DeviceOrderStatus.RECEIV_ING.getStatus());
|
queryWrapper.eq("status", DeviceOrderStatus.RECEIV_ING.getStatus());
|
||||||
break;
|
break;
|
||||||
case "3":
|
case "3":
|
||||||
queryWrapper.in("status",DeviceOrderStatus.REFUND_ING.getStatus(),DeviceOrderStatus.REFUND_SUCC.getStatus(),DeviceOrderStatus.REFUND_FAIL.getStatus());
|
queryWrapper.in("status", DeviceOrderStatus.REFUND_ING.getStatus(), DeviceOrderStatus.REFUND_SUCC.getStatus(), DeviceOrderStatus.REFUND_FAIL.getStatus());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -148,40 +166,41 @@ public class MercOrderDetailServiceImpl extends ServiceImpl<MercOrderDetailMappe
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设备订单退款
|
* 设备订单退款
|
||||||
|
*
|
||||||
* @param dto
|
* @param dto
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void refund(MercOrderDetailDTO dto) {
|
public void refund(MercOrderDetailDTO dto) {
|
||||||
MsgException.checkNull(dto.getId(),"退款详情订单ID为空");
|
MsgException.checkNull(dto.getId(), "退款详情订单ID为空");
|
||||||
MsgException.checkNull(dto.getRefundAmt(),"退款金额不能为空");
|
MsgException.checkNull(dto.getRefundAmt(), "退款金额不能为空");
|
||||||
MsgException.checkBlank(dto.getRefundReason(),"退款原因不能为空");
|
MsgException.checkBlank(dto.getRefundReason(), "退款原因不能为空");
|
||||||
if(dto.getPicList() == null || dto.getPicList().size() == 0){
|
if (dto.getPicList() == null || dto.getPicList().size() == 0) {
|
||||||
MsgException.throwException("请先上传图片");
|
MsgException.throwException("请先上传图片");
|
||||||
}
|
}
|
||||||
MercOrderDetail detail = baseMapper.selectById(dto.getId());
|
MercOrderDetail detail = baseMapper.selectById(dto.getId());
|
||||||
MsgException.checkNull(detail,"订单数据异常");
|
MsgException.checkNull(detail, "订单数据异常");
|
||||||
//暂无物流信息 可以直接退款
|
//暂无物流信息 可以直接退款
|
||||||
BigDecimal totalAmt = detail.getPrice().multiply(BigDecimal.valueOf(detail.getNum()));
|
BigDecimal totalAmt = detail.getPrice().multiply(BigDecimal.valueOf(detail.getNum()));
|
||||||
if(StringUtil.isEmpty(detail.getExpressNo())){
|
if (StringUtil.isEmpty(detail.getExpressNo())) {
|
||||||
totalAmt = totalAmt.add(detail.getPostage());
|
totalAmt = totalAmt.add(detail.getPostage());
|
||||||
}else{
|
} else {
|
||||||
MercOrderExpressVO express = moeMapper.getByExpressNo(detail.getExpressNo());
|
MercOrderExpressVO express = moeMapper.getByExpressNo(detail.getExpressNo());
|
||||||
if(express == null){
|
if (express == null) {
|
||||||
totalAmt = totalAmt.add(detail.getPostage());
|
totalAmt = totalAmt.add(detail.getPostage());
|
||||||
}else{
|
} else {
|
||||||
if(YtStatusEnum.ACCEPT.getValue().equals(express.getStatus()) || YtStatusEnum.WAIT.getValue().equals(express.getStatus())){
|
if (YtStatusEnum.ACCEPT.getValue().equals(express.getStatus()) || YtStatusEnum.WAIT.getValue().equals(express.getStatus())) {
|
||||||
totalAmt = totalAmt.add(detail.getPostage());
|
totalAmt = totalAmt.add(detail.getPostage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MsgException.check(dto.getRefundAmt().compareTo(totalAmt) > 0,"退款金额超出商品金额");
|
MsgException.check(dto.getRefundAmt().compareTo(totalAmt) > 0, "退款金额超出商品金额");
|
||||||
if(DeviceOrderStatus.SUCC_PAY.getStatus().equals(detail.getStatus())
|
if (DeviceOrderStatus.SUCC_PAY.getStatus().equals(detail.getStatus())
|
||||||
|| DeviceOrderStatus.RECEIV_ING.getStatus().equals(detail.getStatus())
|
|| DeviceOrderStatus.RECEIV_ING.getStatus().equals(detail.getStatus())
|
||||||
|| DeviceOrderStatus.REFUND_FAIL.getStatus().equals(detail.getStatus())
|
|| DeviceOrderStatus.REFUND_FAIL.getStatus().equals(detail.getStatus())
|
||||||
|| DeviceOrderStatus.COMPLETED.getStatus().equals(detail.getStatus())){
|
|| DeviceOrderStatus.COMPLETED.getStatus().equals(detail.getStatus())) {
|
||||||
List<MercDeviceRefundImage> list = new ArrayList<>(16);
|
List<MercDeviceRefundImage> list = new ArrayList<>(16);
|
||||||
for (String picUrl:dto.getPicList()) {
|
for (String picUrl : dto.getPicList()) {
|
||||||
MercDeviceRefundImage image = new MercDeviceRefundImage(detail,picUrl);
|
MercDeviceRefundImage image = new MercDeviceRefundImage(detail, picUrl);
|
||||||
list.add(image);
|
list.add(image);
|
||||||
}
|
}
|
||||||
mdriService.saveBatch(list);
|
mdriService.saveBatch(list);
|
||||||
|
|
@ -198,72 +217,78 @@ public class MercOrderDetailServiceImpl extends ServiceImpl<MercOrderDetailMappe
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置退款单号
|
* 设置退款单号
|
||||||
|
*
|
||||||
* @param dto
|
* @param dto
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void setRefundExpressNo(MercOrderDetailDTO dto) {
|
public void setRefundExpressNo(MercOrderDetailDTO dto) {
|
||||||
MsgException.checkNull(dto.getId(),"退款详情订单ID为空");
|
MsgException.checkNull(dto.getId(), "退款详情订单ID为空");
|
||||||
MsgException.checkBlank(dto.getRefundExpressNo(),"退款物流单号不能为空");
|
MsgException.checkBlank(dto.getRefundExpressNo(), "退款物流单号不能为空");
|
||||||
dto.setStatus(MercOrderDetail.STATUS_REFUND_AGREE);
|
dto.setStatus(MercOrderDetail.STATUS_REFUND_AGREE);
|
||||||
baseMapper.updateById(dto);
|
baseMapper.updateById(dto);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 审核退款
|
* 审核退款
|
||||||
|
*
|
||||||
* @param orderDetail
|
* @param orderDetail
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Result<Object> auditRefund(MercOrderDetail orderDetail) {
|
public Result<Object> auditRefund(MercOrderDetail orderDetail) {
|
||||||
MsgException.checkNull(orderDetail.getId(),"退款详情订单ID为空");
|
MsgException.checkNull(orderDetail.getId(), "退款详情订单ID为空");
|
||||||
MsgException.checkBlank(orderDetail.getStatus(),"状态不能为空");
|
MsgException.checkBlank(orderDetail.getStatus(), "状态不能为空");
|
||||||
MsgException.checkNull(orderDetail.getRefundAmt(),"退款金额不能为空");
|
MsgException.checkNull(orderDetail.getRefundAmt(), "退款金额不能为空");
|
||||||
if(MercOrderDetail.STATUS_REFUND_FAIL.equals(orderDetail.getStatus())){
|
if (MercOrderDetail.STATUS_REFUND_FAIL.equals(orderDetail.getStatus())) {
|
||||||
MsgException.checkBlank(orderDetail.getRejectRemark(),"退款驳回,驳回原因不能为空!");
|
MsgException.checkBlank(orderDetail.getRejectRemark(), "退款驳回,驳回原因不能为空!");
|
||||||
}
|
}
|
||||||
MercOrderDetail detail = baseMapper.selectById(orderDetail.getId());
|
MercOrderDetail detail = baseMapper.selectById(orderDetail.getId());
|
||||||
MsgException.checkNull(detail,"退款详情ID有误!");
|
MsgException.checkNull(detail, "退款详情ID有误!");
|
||||||
// MsgException.check(!MercOrderDetail.STATUS_REFUND_AGREE.equals(detail.getStatus()),"只能处理退货退款中的订单!");
|
// MsgException.check(!MercOrderDetail.STATUS_REFUND_AGREE.equals(detail.getStatus()),"只能处理退货退款中的订单!");
|
||||||
BigDecimal useRefundAmt = baseMapper.getUseRefundAmtByOrderNo(detail.getOrderNo());
|
BigDecimal useRefundAmt = baseMapper.getUseRefundAmtByOrderNo(detail.getOrderNo());
|
||||||
BigDecimal totalOrderAmt = detail.getPrice().multiply(BigDecimal.valueOf(detail.getNum())).add(detail.getPostage());
|
BigDecimal totalOrderAmt = detail.getPrice().multiply(BigDecimal.valueOf(detail.getNum())).add(detail.getPostage());
|
||||||
if(orderDetail.getRefundAmt().add(useRefundAmt).compareTo(totalOrderAmt) > 0){
|
if (orderDetail.getRefundAmt().add(useRefundAmt).compareTo(totalOrderAmt) > 0) {
|
||||||
MsgException.throwException("退款金额超出当前订单可退款总额");
|
MsgException.throwException("退款金额超出当前订单可退款总额");
|
||||||
}
|
}
|
||||||
if(MercOrderDetail.STATUS_REFUND_SUCCESS.equals(orderDetail.getStatus())){
|
if (MercOrderDetail.STATUS_REFUND_SUCCESS.equals(orderDetail.getStatus())) {
|
||||||
phoneValidateCodeService.checkSmsVerifyCode(orderDetail.getPhone(),orderDetail.getVerifyCode());
|
phoneValidateCodeService.checkSmsVerifyCode(orderDetail.getPhone(), orderDetail.getVerifyCode());
|
||||||
MercOrderNew orderByNo = mercOrderNewMapper.getOrderByNo(detail.getOrderNo());
|
MercOrderNew orderByNo = mercOrderNewMapper.getOrderByNo(detail.getOrderNo());
|
||||||
MsgException.checkNull(orderByNo,"订单有误!");
|
MsgException.checkNull(orderByNo, "订单有误!");
|
||||||
Integer channel = orderByNo.getChannel();
|
Integer channel = orderByNo.getChannel();
|
||||||
MsgException.checkNull(channel,"通道未知,退款失败");
|
MsgException.checkNull(channel, "通道未知,退款失败");
|
||||||
Map<String, Object> result = null;
|
Map<String, Object> result = null;
|
||||||
MerchantOrder order = new MerchantOrder();
|
MerchantOrder order = new MerchantOrder();
|
||||||
order.convert(orderByNo,orderDetail.getRefundAmt(), SettleTypeEnum.D1.getValue(), detail.getRefundReason());
|
order.convert(orderByNo, orderDetail.getRefundAmt(), SettleTypeEnum.D1.getValue(), detail.getRefundReason());
|
||||||
switch (channel){
|
switch (channel) {
|
||||||
case 1:
|
case 1:
|
||||||
|
MerchantChannelStatus channelInfo = merchantChannelStatusMapper.getByMerchantCode(orderByNo.getMerchantCode(), 1);
|
||||||
|
MsgException.checkNull(channelInfo, "收款商户通道信息异常!");
|
||||||
|
result = ysPayOldService.refundPay(order, channelInfo.getMerchantId());
|
||||||
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
case 3:
|
case 3:
|
||||||
MsgException.throwException("当前订单所属通道不支持退款");
|
MsgException.throwException("当前订单所属通道不支持退款");
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
//银盛退款
|
/* //银盛退款
|
||||||
MerchantChannelStatus channelInfo = merchantChannelStatusMapper.getByMerchantCode(orderByNo.getMerchantCode(), 4);
|
MerchantChannelStatus channelInfo = merchantChannelStatusMapper.getByMerchantCode(orderByNo.getMerchantCode(), 4);
|
||||||
MsgException.checkNull(channelInfo,"收款商户通道信息异常!");
|
MsgException.checkNull(channelInfo, "收款商户通道信息异常!");
|
||||||
result = ysPayOldService.refundPay(order, channelInfo.getMerchantId());
|
result = ysPayOldService.refundPay(order, channelInfo.getMerchantId());
|
||||||
break;
|
break;*/
|
||||||
case 5:
|
case 5:
|
||||||
//原生通道退款 TODO 不支持微信支付 因为微信支付走对公账户 所以这里加一个验证
|
//原生通道退款 TODO 不支持微信支付 因为微信支付走对公账户 所以这里加一个验证
|
||||||
MsgException.check(!Constant.PAY_TYPE_ALIPAY.equals(orderByNo.getPayType()),"当前订单支付方式不支持退款!");
|
MsgException.check(!Constant.PAY_TYPE_ALIPAY.equals(orderByNo.getPayType()), "当前订单支付方式不支持退款!");
|
||||||
result = aliService.refundV2(detail);
|
result = aliService.refundV2(detail);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
MsgException.throwException("未知通道");
|
MsgException.throwException("未知通道");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
int code = (int)result.get("code");
|
int code = (int) result.get("code");
|
||||||
String msg = (String) result.get("msg");
|
String msg = (String) result.get("msg");
|
||||||
String refundNo = (String) result.get("refundNo");
|
String refundNo = (String) result.get("refundNo");
|
||||||
if(code != ResultCode.SUCCESS.code()){
|
if (code != ResultCode.SUCCESS.code()) {
|
||||||
return ResultGenerator.genFailResult(msg);
|
return ResultGenerator.genFailResult(msg);
|
||||||
}
|
}
|
||||||
detail.setRefundTime(DateUtils.currentDate());
|
detail.setRefundTime(DateUtils.currentDate());
|
||||||
|
|
@ -277,74 +302,111 @@ public class MercOrderDetailServiceImpl extends ServiceImpl<MercOrderDetailMappe
|
||||||
detail.setStatus(orderDetail.getStatus());
|
detail.setStatus(orderDetail.getStatus());
|
||||||
detail.setRejectRemark(orderDetail.getRejectRemark());
|
detail.setRejectRemark(orderDetail.getRejectRemark());
|
||||||
baseMapper.updateById(detail);
|
baseMapper.updateById(detail);
|
||||||
return ResultGenerator.genSuccessResult("处理成功",null);
|
return ResultGenerator.genSuccessResult("处理成功", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Result<Object> getVerifyCode(PhoneValidateCode phoneValidateCode) {
|
public Result<Object> getVerifyCode(PhoneValidateCode phoneValidateCode) {
|
||||||
MsgException.checkBlank(phoneValidateCode.getPhone(),"获取失败,手机号为空");
|
MsgException.checkBlank(phoneValidateCode.getPhone(), "获取失败,手机号为空");
|
||||||
String checkCode = StringUtil.random(4);
|
String checkCode = StringUtil.random(6);
|
||||||
phoneValidateCode.setCode(checkCode);
|
phoneValidateCode.setCode(checkCode);
|
||||||
JSONObject result = validateCodeUtil.requestManageValidateCode(phoneValidateCode.getPhone(),checkCode);
|
//JSONObject result = validateCodeUtil.requestManageValidateCode(phoneValidateCode.getPhone(), checkCode);
|
||||||
if(result.getIntValue("code") != ResultCode.SUCCESS.code()){
|
/*if (result.getIntValue("code") != ResultCode.SUCCESS.code()) {
|
||||||
return ResultGenerator.genFailResult(result.getString("msg"));
|
return ResultGenerator.genFailResult(result.getString("msg"));
|
||||||
|
}*/
|
||||||
|
|
||||||
|
Client client = null;
|
||||||
|
try {
|
||||||
|
|
||||||
|
client = createClient();
|
||||||
|
// 1.发送短信
|
||||||
|
com.aliyun.dysmsapi20170525.models.SendSmsRequest sendSmsRequest = new com.aliyun.dysmsapi20170525.models.SendSmsRequest()
|
||||||
|
.setSignName("超掌柜")
|
||||||
|
.setTemplateCode("SMS_244665149")
|
||||||
|
.setTemplateParam("{\"code\":" + "'" + checkCode + "'" + "}")
|
||||||
|
.setPhoneNumbers(phoneValidateCode.getPhone());
|
||||||
|
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
|
||||||
|
SendSmsResponse sendSmsResponse = client.sendSmsWithOptions(sendSmsRequest, runtime);
|
||||||
|
|
||||||
|
if (sendSmsResponse.getStatusCode() != 200) {
|
||||||
|
return ResultGenerator.genFailResult(sendSmsResponse.getBody().getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
phoneValidateCode.setSendDt(DateUtils.currentDate());
|
phoneValidateCode.setSendDt(DateUtils.currentDate());
|
||||||
phoneValidateCode.setStatus("1");
|
phoneValidateCode.setStatus("1");
|
||||||
phoneValidateCodeService.savePhoneValidateCode(phoneValidateCode);
|
phoneValidateCodeService.savePhoneValidateCode(phoneValidateCode);
|
||||||
return ResultGenerator.genSuccessResult("获取成功",null);
|
return ResultGenerator.genSuccessResult("获取成功", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送短信(阿里云)
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
public Client createClient() throws Exception {
|
||||||
|
Config config = new Config();
|
||||||
|
config.accessKeyId = ACCESSKEYID;
|
||||||
|
config.accessKeySecret = ACCESSKEYSECRET;
|
||||||
|
return new com.aliyun.dysmsapi20170525.Client(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 推送物流信息
|
* 推送物流信息
|
||||||
|
*
|
||||||
* @param ids
|
* @param ids
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@Override
|
@Override
|
||||||
public Result<Object> printLogistInfo(List<Long> ids) {
|
public Result<Object> printLogistInfo(List<Long> ids) {
|
||||||
MsgException.check(ids.isEmpty(),"未选中订单数据!");
|
MsgException.check(ids.isEmpty(), "未选中订单数据!");
|
||||||
List<MercOrderDetail> list = baseMapper.selectBatchIds(ids);
|
List<MercOrderDetail> list = baseMapper.selectBatchIds(ids);
|
||||||
MsgException.check(list.isEmpty(),"订单数据异常!");
|
MsgException.check(list.isEmpty(), "订单数据异常!");
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
for (MercOrderDetail detail:list) {
|
for (MercOrderDetail detail : list) {
|
||||||
if(!MercOrderDetail.STATUS_PAYED.equals(detail.getStatus())){
|
if (!MercOrderDetail.STATUS_PAYED.equals(detail.getStatus())) {
|
||||||
flag = true;
|
flag = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
MsgException.check(flag,"只能处理已支付的订单!");
|
MsgException.check(flag, "只能处理已支付的订单!");
|
||||||
MercOrderDetail detail = list.get(0);
|
MercOrderDetail detail = list.get(0);
|
||||||
MercOrderNew order = mercOrderNewMapper.getOrderByNo(detail.getOrderNo());
|
MercOrderNew order = mercOrderNewMapper.getOrderByNo(detail.getOrderNo());
|
||||||
MsgException.checkNull(order,"订单数据异常!");
|
MsgException.checkNull(order, "订单数据异常!");
|
||||||
JSONObject result = ytLogistHandler.createYtOrderV2(list,order);
|
JSONObject result = ytLogistHandler.createYtOrderV2(list, order);
|
||||||
if(result.getIntValue("code") != ResultCode.SUCCESS.code()){
|
if (result.getIntValue("code") != ResultCode.SUCCESS.code()) {
|
||||||
MsgException.throwException(result.getString("message"));
|
MsgException.throwException(result.getString("message"));
|
||||||
}
|
}
|
||||||
JSONObject data = result.getJSONObject("data");
|
JSONObject data = result.getJSONObject("data");
|
||||||
UpdateWrapper<MercOrderDetail> updateWrapper = new UpdateWrapper<MercOrderDetail>().in("id",ids)
|
UpdateWrapper<MercOrderDetail> updateWrapper = new UpdateWrapper<MercOrderDetail>().in("id", ids)
|
||||||
.set("logistNo",data.getString("logistNo")).set("expressNo",data.getString("expressNo"))
|
.set("logistNo", data.getString("logistNo")).set("expressNo", data.getString("expressNo"))
|
||||||
.set("status",MercOrderDetail.STATUS_UN_RECEIVED);
|
.set("status", MercOrderDetail.STATUS_UN_RECEIVED);
|
||||||
update(updateWrapper);
|
update(updateWrapper);
|
||||||
MercOrderExpress orderExpress = new MercOrderExpress();
|
MercOrderExpress orderExpress = new MercOrderExpress();
|
||||||
orderExpress.setOrderNo(order.getOrderNo());
|
orderExpress.setOrderNo(order.getOrderNo());
|
||||||
orderExpress.setLogistNo(data.getString("logistNo"));
|
orderExpress.setLogistNo(data.getString("logistNo"));
|
||||||
orderExpress.setExpressNo(data.getString("expressNo"));
|
orderExpress.setExpressNo(data.getString("expressNo"));
|
||||||
orderExpress.setType(MercOrderExpress.EXPRESS_TYPE_HAIR);
|
orderExpress.setType(MercOrderExpress.EXPRESS_TYPE_HAIR);
|
||||||
orderExpress.setStatus(YtStatusEnum.ACCEPT.getValue());
|
orderExpress.setStatus(YtStatusEnum.ACCEPT.getValue());
|
||||||
mercOrderExpressService.save(orderExpress);
|
mercOrderExpressService.save(orderExpress);
|
||||||
return ResultGenerator.genSuccessResult("处理成功",null);
|
return ResultGenerator.genSuccessResult("处理成功", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 分页查询
|
* 分页查询
|
||||||
|
*
|
||||||
* @param page
|
* @param page
|
||||||
* @param condition
|
* @param condition
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Page<MercOrderDetail> pageInfo(Page<MercOrderDetail> page, MercOrderDetail condition) {
|
public Page<MercOrderDetail> pageInfo(Page<MercOrderDetail> page, MercOrderDetail condition) {
|
||||||
return baseMapper.pageInfo(page,condition);
|
return baseMapper.pageInfo(page, condition);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -364,22 +426,23 @@ public class MercOrderDetailServiceImpl extends ServiceImpl<MercOrderDetailMappe
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 填写快递单号
|
* 填写快递单号
|
||||||
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @param expressNo
|
* @param expressNo
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Result<Object> inputExpressNo(Long id, String expressNo) {
|
public Result<Object> inputExpressNo(Long id, String expressNo) {
|
||||||
MsgException.checkNull(id,"订单ID不能为空!");
|
MsgException.checkNull(id, "订单ID不能为空!");
|
||||||
MsgException.checkBlank(expressNo,"快递单号不能为空!");
|
MsgException.checkBlank(expressNo, "快递单号不能为空!");
|
||||||
MercOrderDetail detail = baseMapper.selectById(id);
|
MercOrderDetail detail = baseMapper.selectById(id);
|
||||||
MsgException.checkNull(detail,"订单数据异常!");
|
MsgException.checkNull(detail, "订单数据异常!");
|
||||||
MsgException.check(!MercOrderDetail.STATUS_PAYED.equals(detail.getStatus()),"只能处理已支付的订单数据");
|
MsgException.check(!MercOrderDetail.STATUS_PAYED.equals(detail.getStatus()), "只能处理已支付的订单数据");
|
||||||
MsgException.check(StringUtil.isNotEmpty(detail.getExpressNo()),"当前订单已存在物流单号,请勿重复填写");
|
MsgException.check(StringUtil.isNotEmpty(detail.getExpressNo()), "当前订单已存在物流单号,请勿重复填写");
|
||||||
detail.setStatus(MercOrderDetail.STATUS_UN_RECEIVED);
|
detail.setStatus(MercOrderDetail.STATUS_UN_RECEIVED);
|
||||||
detail.setExpressNo(expressNo);
|
detail.setExpressNo(expressNo);
|
||||||
MercOrderExpress express = mercOrderExpressService.getByExpressNo(expressNo);
|
MercOrderExpress express = mercOrderExpressService.getByExpressNo(expressNo);
|
||||||
if(express == null){
|
if (express == null) {
|
||||||
express = new MercOrderExpress();
|
express = new MercOrderExpress();
|
||||||
express.setLogistNo(detail.getLogistNo());
|
express.setLogistNo(detail.getLogistNo());
|
||||||
express.setOrderNo(detail.getOrderNo());
|
express.setOrderNo(detail.getOrderNo());
|
||||||
|
|
@ -389,17 +452,18 @@ public class MercOrderDetailServiceImpl extends ServiceImpl<MercOrderDetailMappe
|
||||||
mercOrderExpressService.save(express);
|
mercOrderExpressService.save(express);
|
||||||
}
|
}
|
||||||
baseMapper.updateById(detail);
|
baseMapper.updateById(detail);
|
||||||
return ResultGenerator.genSuccessResult("操作成功",null);
|
return ResultGenerator.genSuccessResult("操作成功", null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据订单号和code查询订单信息
|
* 根据订单号和code查询订单信息
|
||||||
|
*
|
||||||
* @param orderNo
|
* @param orderNo
|
||||||
* @param code
|
* @param code
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<MercOrderDetail> listByOrderNoAndCode(String orderNo, String code) {
|
public List<MercOrderDetail> listByOrderNoAndCode(String orderNo, String code) {
|
||||||
return baseMapper.listByOrderNoAndCode(orderNo,code);
|
return baseMapper.listByOrderNoAndCode(orderNo, code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue