|
@@ -18,6 +18,7 @@ import com.caimei365.order.model.po.ReceiptPo;
|
|
import com.caimei365.order.model.vo.*;
|
|
import com.caimei365.order.model.vo.*;
|
|
import com.caimei365.order.service.ReceiptService;
|
|
import com.caimei365.order.service.ReceiptService;
|
|
import com.caimei365.order.utils.DateUtils;
|
|
import com.caimei365.order.utils.DateUtils;
|
|
|
|
+import com.caimei365.order.utils.ImageUtil;
|
|
import com.caimei365.order.utils.MathUtil;
|
|
import com.caimei365.order.utils.MathUtil;
|
|
import com.caimei365.order.utils.Md5Util;
|
|
import com.caimei365.order.utils.Md5Util;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
@@ -26,6 +27,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
import org.apache.commons.lang3.ArrayUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.http.HttpHeaders;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -33,6 +35,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.math.BigDecimal;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Matcher;
|
|
import java.util.regex.Pattern;
|
|
import java.util.regex.Pattern;
|
|
@@ -46,6 +49,8 @@ import java.util.regex.Pattern;
|
|
@Slf4j
|
|
@Slf4j
|
|
@Service
|
|
@Service
|
|
public class ReceiptServiceImpl implements ReceiptService {
|
|
public class ReceiptServiceImpl implements ReceiptService {
|
|
|
|
+ @Value("${caimei.wwwDomain}")
|
|
|
|
+ private String domain;
|
|
@Resource
|
|
@Resource
|
|
private WeChatService weChatService;
|
|
private WeChatService weChatService;
|
|
@Resource
|
|
@Resource
|
|
@@ -467,7 +472,7 @@ public class ReceiptServiceImpl implements ReceiptService {
|
|
* 获取收款列表
|
|
* 获取收款列表
|
|
*
|
|
*
|
|
* @param receiptType 收款款项类型:1订单款,2非订单款,3返佣款 4订单款或者非订单款(因财务阶段无法区分订单非订单), 5供应商退款
|
|
* @param receiptType 收款款项类型:1订单款,2非订单款,3返佣款 4订单款或者非订单款(因财务阶段无法区分订单非订单), 5供应商退款
|
|
- * @param receiptStatusStr 收款状态串(逗号隔开):1待确认、2已确认(待审核)、3审核通过、4审核未通过、5收款撤销【线上支付成功为审核通过】
|
|
|
|
|
|
+ * @param receiptStatus 收款状态:1待确认、2已确认(待审核)、3审核通过、4审核未通过、5收款撤销【线上支付成功为审核通过】
|
|
* @param smsContent 收款短信
|
|
* @param smsContent 收款短信
|
|
* @param startDate 筛选开始时间
|
|
* @param startDate 筛选开始时间
|
|
* @param endDate 筛选结束时间
|
|
* @param endDate 筛选结束时间
|
|
@@ -476,27 +481,23 @@ public class ReceiptServiceImpl implements ReceiptService {
|
|
* @param pageSize 每页数量
|
|
* @param pageSize 每页数量
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public ResponseJson<PageInfo<ReceiptVo>> getReceiptList(Integer receiptType, String receiptStatusStr, String smsContent, String startDate, String endDate, String openid, int pageNum, int pageSize) {
|
|
|
|
|
|
+ public ResponseJson<PageInfo<ReceiptVo>> getReceiptList(Integer receiptType, Integer receiptStatus, String smsContent, String startDate, String endDate, String openid, int pageNum, int pageSize) {
|
|
ReceiptUserVo receiptUser = receiptMapper.getReceiptUserByOpenid(openid);
|
|
ReceiptUserVo receiptUser = receiptMapper.getReceiptUserByOpenid(openid);
|
|
if (null == receiptUser){
|
|
if (null == receiptUser){
|
|
return ResponseJson.error("请重新授权登录!", null);
|
|
return ResponseJson.error("请重新授权登录!", null);
|
|
}
|
|
}
|
|
ReceiptParamsBo paramsBo = new ReceiptParamsBo();
|
|
ReceiptParamsBo paramsBo = new ReceiptParamsBo();
|
|
- Integer receiptStatus = null;
|
|
|
|
if (StringUtils.isNotBlank(smsContent)) {
|
|
if (StringUtils.isNotBlank(smsContent)) {
|
|
// 短信内容隐藏余额
|
|
// 短信内容隐藏余额
|
|
String message = hiddenBalance(smsContent);
|
|
String message = hiddenBalance(smsContent);
|
|
paramsBo.setSmsMd5Code(Md5Util.md5(message));
|
|
paramsBo.setSmsMd5Code(Md5Util.md5(message));
|
|
}
|
|
}
|
|
- if (StringUtils.isNotBlank(receiptStatusStr)) {
|
|
|
|
- String[] receiptStatusArr = null;
|
|
|
|
- if ("1".equals(receiptStatusStr)) {
|
|
|
|
|
|
+ if (null != receiptStatus && receiptStatus > 0) {
|
|
|
|
+ String[] receiptStatusArr;
|
|
|
|
+ if (1 == receiptStatus) {
|
|
receiptStatusArr = "1,4,5".split(",");
|
|
receiptStatusArr = "1,4,5".split(",");
|
|
} else {
|
|
} else {
|
|
- receiptStatusArr = receiptStatusStr.split(",");
|
|
|
|
- if ("2".equals(receiptStatusStr)){
|
|
|
|
- receiptStatus = 2;
|
|
|
|
- }
|
|
|
|
|
|
+ receiptStatusArr = receiptStatus.toString().split(",");
|
|
}
|
|
}
|
|
paramsBo.setReceiptStatusArr(receiptStatusArr);
|
|
paramsBo.setReceiptStatusArr(receiptStatusArr);
|
|
}
|
|
}
|
|
@@ -669,6 +670,44 @@ public class ReceiptServiceImpl implements ReceiptService {
|
|
return ResponseJson.success(pageInfo);
|
|
return ResponseJson.success(pageInfo);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 获取收款订单详情
|
|
|
|
+ *
|
|
|
|
+ * @param orderId 订单Id
|
|
|
|
+ * @param openid 微信openid
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<OrderVo> getReceiptOrderInfo(Integer orderId, String openid) {
|
|
|
|
+ // 操作用户
|
|
|
|
+ ReceiptUserVo receiptUser = checkPermissions(1, openid);
|
|
|
|
+ if (null == receiptUser) {
|
|
|
|
+ return ResponseJson.error("无权限操作!", null);
|
|
|
|
+ }
|
|
|
|
+ // 订单信息
|
|
|
|
+ OrderVo order = orderCommonMapper.getOrderByOrderId(orderId);
|
|
|
|
+ // 设置订单的款项信息
|
|
|
|
+ setOrderAmountInfo(order);
|
|
|
|
+ // 子订单信息
|
|
|
|
+ List<ShopOrderVo> shopOrderList = orderCommonMapper.getShopOrderListByOrderId(order.getOrderId());
|
|
|
|
+ shopOrderList.removeIf(s -> s.getShopId() == 998);
|
|
|
|
+ // 订单商品信息
|
|
|
|
+ double totalAddedValueTax = 0d;
|
|
|
|
+ for (ShopOrderVo shopOrder : shopOrderList) {
|
|
|
|
+ // 供应商名称
|
|
|
|
+ String shopName = baseMapper.getShopNameById(shopOrder.getShopId());
|
|
|
|
+ shopOrder.setShopName(shopName);
|
|
|
|
+ List<OrderProductVo> orderProductList = orderCommonMapper.getShopOrderProduct(shopOrder.getShopOrderId());
|
|
|
|
+ for (OrderProductVo orderProduct : orderProductList) {
|
|
|
|
+ if (null != orderProduct.getTotalAddedValueTax()) {
|
|
|
|
+ totalAddedValueTax = MathUtil.add(totalAddedValueTax, orderProduct.getTotalAddedValueTax()).doubleValue();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ shopOrder.setOrderProductList(orderProductList);
|
|
|
|
+ }
|
|
|
|
+ order.setTotalAddedValueTax(totalAddedValueTax);
|
|
|
|
+ order.setShopOrderList(shopOrderList);
|
|
|
|
+ return ResponseJson.success(order);
|
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
/**
|
|
* @param id 返佣收款ID
|
|
* @param id 返佣收款ID
|
|
@@ -718,13 +757,13 @@ public class ReceiptServiceImpl implements ReceiptService {
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 获取收款订单详情
|
|
|
|
|
|
+ * 供应商退款详情
|
|
*
|
|
*
|
|
* @param orderId 订单Id
|
|
* @param orderId 订单Id
|
|
* @param openid 微信openid
|
|
* @param openid 微信openid
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
- public ResponseJson<OrderVo> getReceiptOrderInfo(Integer orderId, String openid) {
|
|
|
|
|
|
+ public ResponseJson<OrderVo> getRefundShopOrderInfo(Integer orderId, String openid) {
|
|
// 操作用户
|
|
// 操作用户
|
|
ReceiptUserVo receiptUser = checkPermissions(1, openid);
|
|
ReceiptUserVo receiptUser = checkPermissions(1, openid);
|
|
if (null == receiptUser) {
|
|
if (null == receiptUser) {
|
|
@@ -736,23 +775,44 @@ public class ReceiptServiceImpl implements ReceiptService {
|
|
setOrderAmountInfo(order);
|
|
setOrderAmountInfo(order);
|
|
// 子订单信息
|
|
// 子订单信息
|
|
List<ShopOrderVo> shopOrderList = orderCommonMapper.getShopOrderListByOrderId(order.getOrderId());
|
|
List<ShopOrderVo> shopOrderList = orderCommonMapper.getShopOrderListByOrderId(order.getOrderId());
|
|
- shopOrderList.removeIf(s -> s.getShopId() == 998);
|
|
|
|
// 订单商品信息
|
|
// 订单商品信息
|
|
- double totalAddedValueTax = 0d;
|
|
|
|
|
|
+ double needPayAmount = 0d;
|
|
for (ShopOrderVo shopOrder : shopOrderList) {
|
|
for (ShopOrderVo shopOrder : shopOrderList) {
|
|
// 供应商名称
|
|
// 供应商名称
|
|
String shopName = baseMapper.getShopNameById(shopOrder.getShopId());
|
|
String shopName = baseMapper.getShopNameById(shopOrder.getShopId());
|
|
shopOrder.setShopName(shopName);
|
|
shopOrder.setShopName(shopName);
|
|
|
|
+ needPayAmount += (shopOrder.getNeedPayAmount() == null ? 0d : shopOrder.getNeedPayAmount());
|
|
List<OrderProductVo> orderProductList = orderCommonMapper.getShopOrderProduct(shopOrder.getShopOrderId());
|
|
List<OrderProductVo> orderProductList = orderCommonMapper.getShopOrderProduct(shopOrder.getShopOrderId());
|
|
for (OrderProductVo orderProduct : orderProductList) {
|
|
for (OrderProductVo orderProduct : orderProductList) {
|
|
- if (null != orderProduct.getTotalAddedValueTax()) {
|
|
|
|
- totalAddedValueTax = MathUtil.add(totalAddedValueTax, orderProduct.getTotalAddedValueTax()).doubleValue();
|
|
|
|
- }
|
|
|
|
|
|
+ orderProduct.setImage(ImageUtil.getImageUrl("product", orderProduct.getImage(), domain));
|
|
}
|
|
}
|
|
shopOrder.setOrderProductList(orderProductList);
|
|
shopOrder.setOrderProductList(orderProductList);
|
|
|
|
+ List<Integer> rebatePayType = receiptMapper.getRebatePayTypeList(shopOrder.getShopOrderId());
|
|
|
|
+ if (CollectionUtils.isEmpty(rebatePayType)){
|
|
|
|
+ // 没返佣
|
|
|
|
+ shopOrder.setReceiptedFlag(0);
|
|
|
|
+ } else if (10 == rebatePayType.get(0)) {
|
|
|
|
+ // 口头返佣
|
|
|
|
+ shopOrder.setReceiptedType(10);
|
|
|
|
+ shopOrder.setReceiptedFlag(1);
|
|
|
|
+ } else {
|
|
|
|
+ shopOrder.setReceiptedType(1);
|
|
|
|
+ shopOrder.setReceiptedFlag(1);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- order.setTotalAddedValueTax(totalAddedValueTax);
|
|
|
|
order.setShopOrderList(shopOrderList);
|
|
order.setShopOrderList(shopOrderList);
|
|
|
|
+ //收款金额
|
|
|
|
+ if (null != order.getRebateFlag() && 1 == order.getRebateFlag()) {
|
|
|
|
+ order.setReceiptAmount(needPayAmount);
|
|
|
|
+ double surplusAmount = MathUtil.sub(order.getPayTotalFee(), needPayAmount).doubleValue();
|
|
|
|
+ order.setSurplusAmount(surplusAmount);
|
|
|
|
+ } else {
|
|
|
|
+ // 获取订单已支付金额
|
|
|
|
+ Double paidAmount = receiptMapper.getPaidAmountByOrderId(order.getOrderId());
|
|
|
|
+ order.setReceiptAmount(paidAmount);
|
|
|
|
+ double surplusAmount = MathUtil.sub(order.getPayTotalFee(), paidAmount).doubleValue();
|
|
|
|
+ order.setSurplusAmount(surplusAmount);
|
|
|
|
+ }
|
|
return ResponseJson.success(order);
|
|
return ResponseJson.success(order);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -939,6 +999,17 @@ public class ReceiptServiceImpl implements ReceiptService {
|
|
return ResponseJson.success(receiptPo);
|
|
return ResponseJson.success(receiptPo);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 确认收款-关联供应商退款
|
|
|
|
+ *
|
|
|
|
+ * @param receiptAssociateDto
|
|
|
|
+ */
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ @Override
|
|
|
|
+ public ResponseJson<ReceiptPo> receiptAssociateRefund(ReceiptAssociateDto receiptAssociateDto) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 设置订单的款项信息
|
|
* 设置订单的款项信息
|
|
*/
|
|
*/
|