|
|
@@ -1,9 +1,9 @@
|
|
|
package com.fs.hisStore.service.impl;
|
|
|
|
|
|
+import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
|
import cn.binarywang.wx.miniapp.bean.shop.request.shipping.*;
|
|
|
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingInfoGetResponse;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
-import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
|
import cn.hutool.core.net.URLDecoder;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.core.util.NumberUtil;
|
|
|
@@ -27,13 +27,11 @@ import com.fs.common.exception.CustomException;
|
|
|
import com.fs.common.exception.ServiceException;
|
|
|
import com.fs.common.utils.DateUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
-import com.fs.company.domain.Company;
|
|
|
-import com.fs.company.domain.CompanyDept;
|
|
|
-import com.fs.company.domain.CompanyMoneyLogs;
|
|
|
-import com.fs.company.domain.CompanyUser;
|
|
|
+import com.fs.company.domain.*;
|
|
|
import com.fs.company.mapper.CompanyDeptMapper;
|
|
|
import com.fs.company.mapper.CompanyMapper;
|
|
|
import com.fs.company.mapper.CompanyMoneyLogsMapper;
|
|
|
+import com.fs.company.mapper.CompanyTagMapper;
|
|
|
import com.fs.company.service.ICompanyDeptService;
|
|
|
import com.fs.company.service.ICompanyService;
|
|
|
import com.fs.company.service.ICompanyUserService;
|
|
|
@@ -43,29 +41,44 @@ import com.fs.core.utils.OrderCodeUtils;
|
|
|
import com.fs.course.dto.FsOrderDeliveryNoteDTO;
|
|
|
import com.fs.course.dto.OrderOpenIdTransDTO;
|
|
|
import com.fs.erp.domain.*;
|
|
|
-import com.fs.erp.dto.*;
|
|
|
+import com.fs.erp.dto.ErpOrderQueryRequert;
|
|
|
+import com.fs.erp.dto.ErpOrderQueryResponse;
|
|
|
+import com.fs.erp.dto.ErpOrderResponse;
|
|
|
+import com.fs.erp.dto.ErpRefundUpdateRequest;
|
|
|
import com.fs.erp.mapper.FsErpFinishPushMapper;
|
|
|
import com.fs.erp.service.IErpOrderService;
|
|
|
import com.fs.his.config.FsSysConfig;
|
|
|
-import com.fs.his.domain.*;
|
|
|
+import com.fs.his.domain.FsInquiryOrder;
|
|
|
+import com.fs.his.domain.FsPackageOrder;
|
|
|
+import com.fs.his.domain.FsPrescribe;
|
|
|
+import com.fs.his.domain.FsPrescribeDrug;
|
|
|
import com.fs.his.dto.FsPrescribeUsageDTO;
|
|
|
import com.fs.his.dto.FsProdItemDTO;
|
|
|
import com.fs.his.dto.FsStoreOrderItemDTO;
|
|
|
import com.fs.his.enums.FsStoreOrderLogEnum;
|
|
|
import com.fs.his.enums.FsStoreOrderStatusEnum;
|
|
|
-import com.fs.his.mapper.*;
|
|
|
+import com.fs.his.mapper.FsInquiryOrderMapper;
|
|
|
+import com.fs.his.mapper.FsPackageOrderMapper;
|
|
|
+import com.fs.his.mapper.FsPrescribeDrugMapper;
|
|
|
+import com.fs.his.mapper.FsPrescribeMapper;
|
|
|
import com.fs.his.param.FsStoreOrderSalesParam;
|
|
|
import com.fs.his.service.IFsPrescribeService;
|
|
|
import com.fs.his.service.IFsUserWatchService;
|
|
|
import com.fs.his.utils.ConfigUtil;
|
|
|
import com.fs.his.vo.FsInquiryOrderVO;
|
|
|
+import com.fs.his.vo.FsPrescribeVO;
|
|
|
import com.fs.his.vo.FsStoreOrderExcelVO;
|
|
|
import com.fs.hisStore.config.FsErpConfig;
|
|
|
+import com.fs.hisStore.config.StoreConfig;
|
|
|
+import com.fs.hisStore.config.StoreIntegralConfig;
|
|
|
+import com.fs.hisStore.constants.StoreConstants;
|
|
|
+import com.fs.hisStore.domain.*;
|
|
|
import com.fs.hisStore.dto.*;
|
|
|
+import com.fs.hisStore.enums.*;
|
|
|
import com.fs.hisStore.mapper.*;
|
|
|
import com.fs.hisStore.param.*;
|
|
|
+import com.fs.hisStore.service.*;
|
|
|
import com.fs.hisStore.vo.*;
|
|
|
-import com.fs.his.vo.FsPrescribeVO;
|
|
|
import com.fs.hisapi.domain.ApiResponse;
|
|
|
import com.fs.hisapi.param.CreateOrderParam;
|
|
|
import com.fs.hisapi.param.RecipeDetailParam;
|
|
|
@@ -76,13 +89,6 @@ import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayRefundRequest;
|
|
|
import com.fs.huifuPay.service.HuiFuService;
|
|
|
import com.fs.pay.pay.dto.RefundDTO;
|
|
|
import com.fs.pay.service.IPayService;
|
|
|
-import com.fs.hisStore.config.StoreConfig;
|
|
|
-import com.fs.hisStore.config.StoreIntegralConfig;
|
|
|
-import com.fs.hisStore.constants.StoreConstants;
|
|
|
-import com.fs.hisStore.domain.*;
|
|
|
-import com.fs.hisStore.enums.*;
|
|
|
-import com.fs.hisStore.service.*;
|
|
|
-import com.fs.system.domain.SysConfig;
|
|
|
import com.fs.system.mapper.SysConfigMapper;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
import com.fs.ybPay.domain.RefundResult;
|
|
|
@@ -93,7 +99,6 @@ import com.github.binarywang.wxpay.bean.result.WxPayRefundResult;
|
|
|
import com.github.binarywang.wxpay.config.WxPayConfig;
|
|
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
|
|
import com.github.binarywang.wxpay.service.WxPayService;
|
|
|
-import com.google.gson.Gson;
|
|
|
import lombok.Synchronized;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
@@ -323,6 +328,12 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
@Autowired
|
|
|
private SysConfigMapper sysConfigMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CompanyTagMapper companyTagMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IFsUserProjectTagScrmService userProjectTagService;
|
|
|
+
|
|
|
/**
|
|
|
* 查询订单
|
|
|
*
|
|
|
@@ -580,6 +591,16 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //立减金
|
|
|
+ if (param.getDeductionCouponUserId() != null) {
|
|
|
+ FsStoreCouponUserScrm deductionCouponUser = couponUserService.selectFsStoreCouponUserById(param.getDeductionCouponUserId());
|
|
|
+ if (deductionCouponUser != null && deductionCouponUser.getStatus() == 0) {
|
|
|
+ if (deductionCouponUser.getUseMinPrice().compareTo(priceGroup.getTotalPrice()) == -1) {
|
|
|
+ payPrice = payPrice.subtract(deductionCouponUser.getCouponPrice());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
return FsStoreOrderComputeDTO.builder()
|
|
|
.totalPrice(priceGroup.getTotalPrice())
|
|
|
.payPrice(payPrice)
|
|
|
@@ -705,6 +726,19 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
couponUserService.updateFsStoreCouponUser(couponUser);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //立减金处理
|
|
|
+ if (param.getDeductionCouponUserId() != null) {
|
|
|
+ FsStoreCouponUserScrm deductionCouponUser = couponUserService.selectFsStoreCouponUserById(param.getDeductionCouponUserId());
|
|
|
+ if (deductionCouponUser != null && deductionCouponUser.getStatus() == 0) {
|
|
|
+ storeOrder.setDeductionCouponId(deductionCouponUser.getId());
|
|
|
+ storeOrder.setDeductionCouponPrice(deductionCouponUser.getCouponPrice());
|
|
|
+ //更新立减金优惠券状态
|
|
|
+ deductionCouponUser.setStatus(1);
|
|
|
+ deductionCouponUser.setUseTime(new Date());
|
|
|
+ couponUserService.updateFsStoreCouponUser(deductionCouponUser);
|
|
|
+ }
|
|
|
+ }
|
|
|
//处理推荐人
|
|
|
FsUserScrm user = userService.selectFsUserById(storeOrder.getUserId());
|
|
|
if (user.getSpreadUserId() != null && user.getSpreadUserId() > 0) {
|
|
|
@@ -1038,6 +1072,8 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
this.refundIntegral(order);
|
|
|
//退回优惠券
|
|
|
this.refundCoupon(order);
|
|
|
+ //退回立减金
|
|
|
+ this.refundDeductionCoupon(order);
|
|
|
//退回库存
|
|
|
this.refundStock(order);
|
|
|
fsStoreOrderMapper.cancelOrder(orderId);
|
|
|
@@ -1072,6 +1108,10 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
this.refundIntegral(order);
|
|
|
//退回库存
|
|
|
this.refundStock(order);
|
|
|
+ //退回优惠券
|
|
|
+ this.refundCoupon(order);
|
|
|
+ //退回立减金
|
|
|
+ this.refundDeductionCoupon(order);
|
|
|
fsStoreOrderMapper.cancelOrder(orderId);
|
|
|
//退佣金
|
|
|
if (order.getTuiUserId() != null && order.getTuiUserId() > 0) {
|
|
|
@@ -1135,6 +1175,18 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //退回立减金
|
|
|
+ private void refundDeductionCoupon(FsStoreOrderScrm order) {
|
|
|
+ if (order.getDeductionCouponId() != null) {
|
|
|
+ FsStoreCouponUserScrm couponUser = couponUserService.selectFsStoreCouponUserById(order.getDeductionCouponId());
|
|
|
+ if (couponUser != null && couponUser.getCouponType() == 3) { // 3表示立减金
|
|
|
+ couponUser.setStatus(0);
|
|
|
+ couponUser.setUseTime(null);
|
|
|
+ couponUserService.updateFsStoreCouponUser(couponUser);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//已支付退款
|
|
|
@Override
|
|
|
public void refundOrder(Long orderId) {
|
|
|
@@ -1145,6 +1197,10 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
this.refundIntegral(order);
|
|
|
//退回库存
|
|
|
this.refundStock(order);
|
|
|
+ //退回优惠券
|
|
|
+ this.refundCoupon(order);
|
|
|
+ //退回立减金
|
|
|
+ this.refundDeductionCoupon(order);
|
|
|
fsStoreOrderMapper.cancelOrder(orderId);
|
|
|
}
|
|
|
}
|
|
|
@@ -1315,6 +1371,8 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
createParam.setOrderCreateType(3); //后台制单
|
|
|
createParam.setOrderType(param.getOrderType());
|
|
|
createParam.setOrderMedium(param.getOrderMedium()); //后台制单
|
|
|
+ createParam.setCouponUserId(param.getCouponUserId()); //设置优惠券ID
|
|
|
+ createParam.setDeductionCouponUserId(param.getDeductionCouponUserId()); //设置立减金优惠券用户ID
|
|
|
return this.createOrder(param.getUserId(), createParam);
|
|
|
} else {
|
|
|
throw new CustomException("创建失败");
|
|
|
@@ -1577,6 +1635,30 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
fsStoreOrderMapper.updateFsStoreOrder(order);
|
|
|
orderStatusService.create(order.getId(), OrderLogEnum.FINISH_ORDER.getValue(),
|
|
|
OrderLogEnum.FINISH_ORDER.getDesc());
|
|
|
+ // 为完成订单的客户打上"营养师推荐"标签
|
|
|
+ try{
|
|
|
+ //查询或者创建“营养师推荐”标签
|
|
|
+ HashMap<String, Object> params = new HashMap<>();
|
|
|
+ params.put("companyId", order.getCompanyId());
|
|
|
+ params.put("tag", "营养师推荐");
|
|
|
+ List<CompanyTag> tags = companyTagMapper.selectCompanyTagListByMap(params);
|
|
|
+
|
|
|
+ Long tagId;
|
|
|
+ if(tags == null || tags.isEmpty()){
|
|
|
+ //如果标签不存在,创建新标签
|
|
|
+ CompanyTag newTag = new CompanyTag();
|
|
|
+ newTag.setCompanyId(order.getCompanyId());
|
|
|
+ newTag.setTag("营养师推荐");
|
|
|
+ companyTagMapper.insertCompanyTag(newTag);
|
|
|
+ tagId = newTag.getTagId();
|
|
|
+ }else {
|
|
|
+ tagId = tags.get(0).getTagId();
|
|
|
+ }
|
|
|
+ userProjectTagService.addUserProjectTag(order.getCompanyUserId(), Arrays.asList(tagId));
|
|
|
+ }
|
|
|
+ catch (Exception e){
|
|
|
+ log.error("为订单用户打标签时发生错误:"+e.getMessage(),e);
|
|
|
+ }
|
|
|
//写入公司余额 条件是只有全款订单才分,非全款后台导入
|
|
|
if (order.getCompanyId() != null && order.getCompanyId() > 0 && order.getPayDelivery().compareTo(new BigDecimal(0)) == 0) {
|
|
|
if (order.getTuiMoneyStatus() == null || order.getTuiMoneyStatus() != 1) {
|
|
|
@@ -4057,4 +4139,4 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
}
|
|
|
return start < len ? str.substring(start) : "";
|
|
|
}
|
|
|
-}
|
|
|
+}
|