|
|
@@ -57,30 +57,35 @@ import com.fs.erp.service.IErpOrderService;
|
|
|
import com.fs.his.config.AppConfig;
|
|
|
import com.fs.his.config.FsSysConfig;
|
|
|
import com.fs.his.domain.*;
|
|
|
-import com.fs.his.dto.FsPrescribeUsageDTO;
|
|
|
-import com.fs.his.dto.FsProdItemDTO;
|
|
|
-import com.fs.his.dto.FsStoreOrderAmountScrmStatsQueryDto;
|
|
|
-import com.fs.his.dto.FsStoreOrderItemDTO;
|
|
|
+import com.fs.his.dto.*;
|
|
|
import com.fs.his.enums.*;
|
|
|
import com.fs.his.mapper.*;
|
|
|
-import com.fs.his.param.FsIntegralOrderDoPayParam;
|
|
|
-import com.fs.his.param.FsStoreOrderSalesParam;
|
|
|
-import com.fs.his.param.FsUserAddIntegralTemplateParam;
|
|
|
-import com.fs.his.param.PayOrderParam;
|
|
|
+import com.fs.his.param.*;
|
|
|
import com.fs.his.service.IFsPrescribeService;
|
|
|
+import com.fs.his.service.IFsStoreOrderService;
|
|
|
import com.fs.his.service.IFsUserIntegralLogsService;
|
|
|
import com.fs.his.service.IFsUserWatchService;
|
|
|
import com.fs.his.utils.ConfigUtil;
|
|
|
-import com.fs.his.vo.FsInquiryOrderVO;
|
|
|
-import com.fs.his.vo.FsStoreOrderAmountScrmStatsVo;
|
|
|
-import com.fs.his.vo.FsStoreOrderExcelVO;
|
|
|
+import com.fs.his.vo.*;
|
|
|
import com.fs.his.vo.FsPrescribeVO;
|
|
|
import com.fs.hisStore.config.FsErpConfig;
|
|
|
import com.fs.hisStore.constants.ErpTypeEnum;
|
|
|
import com.fs.hisStore.dto.*;
|
|
|
+import com.fs.hisStore.dto.ErpRemarkDTO;
|
|
|
+import com.fs.hisStore.dto.ExpressDataDTO;
|
|
|
+import com.fs.hisStore.dto.ExpressInfoDTO;
|
|
|
+import com.fs.hisStore.dto.ExpressNotifyDTO;
|
|
|
+import com.fs.hisStore.dto.ExpressResultDTO;
|
|
|
+import com.fs.hisStore.dto.FsStoreCartDTO;
|
|
|
+import com.fs.hisStore.dto.StoreOrderExpressExportDTO;
|
|
|
+import com.fs.hisStore.dto.StorePackageProductDTO;
|
|
|
+import com.fs.hisStore.dto.StoreProductGroupDTO;
|
|
|
import com.fs.hisStore.enums.ShipperCodeEnum;
|
|
|
import com.fs.hisStore.mapper.*;
|
|
|
import com.fs.hisStore.param.*;
|
|
|
+import com.fs.hisStore.param.FsStoreAfterSalesParam;
|
|
|
+import com.fs.hisStore.param.FsStoreOrderParam;
|
|
|
+import com.fs.hisStore.param.FsStoreOrderPayParam;
|
|
|
import com.fs.hisStore.vo.*;
|
|
|
import com.fs.hisStore.vo.FsStoreOrderErpExportVO;
|
|
|
import com.fs.hisStore.vo.FsStoreOrderItemVO;
|
|
|
@@ -111,6 +116,11 @@ import com.fs.hisStore.service.*;
|
|
|
import com.fs.system.domain.SysConfig;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
import com.fs.system.service.ISysDictTypeService;
|
|
|
+import com.fs.tzBankPay.TzBankService.TzBankService;
|
|
|
+import com.fs.tzBankPay.doman.PayCreateOrder;
|
|
|
+import com.fs.tzBankPay.doman.PayCreateOrderResult;
|
|
|
+import com.fs.tzBankPay.doman.PayType;
|
|
|
+import com.fs.tzBankPay.doman.TzBankResult;
|
|
|
import com.fs.wx.miniapp.config.WxMaProperties;
|
|
|
import com.fs.wx.order.domain.FsWxExpressTask;
|
|
|
import com.fs.wx.order.dto.*;
|
|
|
@@ -153,6 +163,8 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
import org.redisson.api.RLock;
|
|
|
import org.redisson.api.RedissonClient;
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import java.lang.reflect.Field;
|
|
|
import java.math.BigDecimal;
|
|
|
@@ -253,6 +265,12 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
@Lazy
|
|
|
private IFsPrescribeService fsPrescribeService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private TzBankService tzBankService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FsUserWxMapper fsUserWxMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
private IPayService payService;
|
|
|
@Autowired
|
|
|
@@ -5889,19 +5907,26 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
if (config.getServiceFee() != null) {
|
|
|
storeOrder.setServiceFee(config.getServiceFee());
|
|
|
}
|
|
|
-
|
|
|
- //后台制单处理
|
|
|
- if (param.getPayPrice() != null && param.getPayPrice().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
- if (param.getPayPrice().compareTo(dto.getTotalPrice()) > 0) {
|
|
|
- return R.error("改价价格不能大于商品总价");
|
|
|
+ BigDecimal money = redisCache.getCacheObject("createOrderMoney:" + param.getOrderKey());
|
|
|
+ if(money != null && money.compareTo(BigDecimal.ZERO) >= 0 && money.compareTo(param.getPayPrice()) <= 0){
|
|
|
+ storeOrder.setPayPrice(money);
|
|
|
+ storeOrder.setPayMoney(money);
|
|
|
+ }else{
|
|
|
+ //后台制单处理
|
|
|
+ if (param.getPayPrice() != null && param.getPayPrice().compareTo(BigDecimal.ZERO) > 0) {
|
|
|
+ if (param.getPayPrice().compareTo(dto.getTotalPrice()) > 0) {
|
|
|
+ return R.error("改价价格不能大于商品总价");
|
|
|
+ }
|
|
|
+ storeOrder.setPayPrice(param.getPayPrice());
|
|
|
+ storeOrder.setPayMoney(param.getPayPrice());
|
|
|
+ } else {
|
|
|
+ storeOrder.setPayPrice(dto.getPayPrice());
|
|
|
+ storeOrder.setPayMoney(dto.getPayPrice());
|
|
|
}
|
|
|
- storeOrder.setPayPrice(param.getPayPrice());
|
|
|
- storeOrder.setPayMoney(param.getPayPrice());
|
|
|
- } else {
|
|
|
- storeOrder.setPayPrice(dto.getPayPrice());
|
|
|
- storeOrder.setPayMoney(dto.getPayPrice());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
storeOrder.setStatus(1);
|
|
|
storeOrder.setPaid(1);
|
|
|
storeOrder.setPayTime(new Date());
|
|
|
@@ -6081,6 +6106,125 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
return storePaymentService.processPaymentScrm(payOrderParam);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public R zfbPayment(FsStoreOrderDoPayParam param) {
|
|
|
+ FsStoreOrderScrm order = fsStoreOrderMapper.selectFsStoreOrderById(param.getOrderId());
|
|
|
+
|
|
|
+ FSUserVO user=userService.selectFsUserByUserId(param.getUserId());
|
|
|
+
|
|
|
+ String json = configService.selectConfigByKey("his.pay");
|
|
|
+ PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
|
|
|
+
|
|
|
+ String openId = null;
|
|
|
+ String appId = param.getAppId();
|
|
|
+ if (StringUtils.isNotBlank(appId)) {
|
|
|
+ //查询fs_user_wx的openId
|
|
|
+ Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
|
|
|
+ .eq(FsUserWx::getFsUserId, param.getUserId())
|
|
|
+ .eq(FsUserWx::getAppId, appId);
|
|
|
+ FsUserWx fsUserWx = fsUserWxMapper.selectOne(queryWrapper);
|
|
|
+ if (fsUserWx != null) {
|
|
|
+ openId = fsUserWx.getOpenId();
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ appId = payConfigDTO.getAppId();
|
|
|
+ openId = Objects.isNull(user) ? "" : user.getMaOpenId();
|
|
|
+ if (StringUtils.isBlank(openId)){
|
|
|
+ Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
|
|
|
+ .eq(FsUserWx::getFsUserId, param.getUserId())
|
|
|
+ .eq(FsUserWx::getAppId, appId);
|
|
|
+ FsUserWx fsUserWx = fsUserWxMapper.selectOne(queryWrapper);
|
|
|
+ if (Objects.nonNull(fsUserWx)){
|
|
|
+ openId = fsUserWx.getOpenId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(order.getPayMoney().compareTo(new BigDecimal(0))==0){
|
|
|
+ /*this.payConfirm(order.getOrderCode(),"","","",2,null,null);
|
|
|
+ return R.ok().put("isPay",1);*/
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ String payCode = OrderCodeUtils.getOrderSn();
|
|
|
+ if(StringUtils.isEmpty(payCode)){
|
|
|
+ return R.error("订单生成失败,请重试");
|
|
|
+ }
|
|
|
+// String json = configService.selectConfigByKey("his.pay");
|
|
|
+// PayConfigDTO payConfigDTO = JSONUtil.toBean(json, PayConfigDTO.class);
|
|
|
+ FsStorePaymentScrm storePayment=new FsStorePaymentScrm();
|
|
|
+ storePayment.setStatus(0);
|
|
|
+ storePayment.setPayMode(payConfigDTO.getType());
|
|
|
+ storePayment.setPayCode(payCode);
|
|
|
+ storePayment.setCompanyId(order.getCompanyId());
|
|
|
+ storePayment.setCompanyUserId(order.getCompanyUserId());
|
|
|
+ storePayment.setBusinessCode(order.getOrderCode());
|
|
|
+ storePayment.setPayMoney(order.getPayMoney());
|
|
|
+ storePayment.setCreateTime(new Date());
|
|
|
+ storePayment.setPayTypeCode("支付宝");
|
|
|
+ storePayment.setBusinessType(1);
|
|
|
+ storePayment.setRemark("商城订单支付");
|
|
|
+ storePayment.setOpenId(openId);
|
|
|
+ storePayment.setOrderId(order.getId());
|
|
|
+ storePayment.setUserId(user.getUserId());
|
|
|
+ storePayment.setBusinessOrderId(order.getId().toString());
|
|
|
+ if(storePaymentService.insertFsStorePayment(storePayment)>0){
|
|
|
+ if (payConfigDTO.getType().equals("yb")) {
|
|
|
+ return R.error("支付暂不可用!");
|
|
|
+ } else if (payConfigDTO.getType().equals("tz")) {
|
|
|
+ PayCreateOrder o = new PayCreateOrder();
|
|
|
+ o.setOrderNo("store" + storePayment.getPayCode()); // 业务系统订单号
|
|
|
+ o.setTrxAmt(storePayment.getPayMoney().doubleValue()); // 交易金额
|
|
|
+ o.setBusinessCstNo(order.getUserId().toString()); // 业务平台客户号
|
|
|
+ String phone="";
|
|
|
+ if (user.getPhone()!=null&&user.getPhone().length()>4){
|
|
|
+ phone=user.getPhone().substring(user.getPhone().length()-4);
|
|
|
+ }
|
|
|
+ o.setPayerName("微信用户"+phone);
|
|
|
+ o.setGoodsInfo("商城订单支付"); // 订单信息
|
|
|
+ o.setOrderType(2);
|
|
|
+ o.setOrderId(order.getOrderCode());
|
|
|
+ o.setPayType(Arrays.asList(PayType.ALIPAY_BARCODE_PAYMENT.getCode()));
|
|
|
+ TzBankResult<PayCreateOrderResult> result = tzBankService.createOrder(o);
|
|
|
+ FsStorePaymentScrm mt=new FsStorePaymentScrm();
|
|
|
+ mt.setPaymentId(storePayment.getPaymentId());
|
|
|
+ mt.setTradeNo(result.getBody().getOrderFlowNo());
|
|
|
+ storePaymentService.updateFsStorePayment(mt);
|
|
|
+ return R.ok().put("isPay", 0).put("data", result).put("type", "tz");
|
|
|
+ }else if (payConfigDTO.getType().equals("hf")) {
|
|
|
+ HuiFuCreateOrder o = new HuiFuCreateOrder();
|
|
|
+ o.setTradeType("A_NATIVE");
|
|
|
+ o.setOpenid(openId);
|
|
|
+ o.setReqSeqId("store-"+storePayment.getPayCode());
|
|
|
+ o.setTransAmt(storePayment.getPayMoney().toString());
|
|
|
+ o.setGoodsDesc("商城订单支付");
|
|
|
+ o.setAppId(appId);
|
|
|
+ if (o.getAppId()!=null&& !o.getAppId().isEmpty()){
|
|
|
+ Wrapper<FsUserWx> queryWrapper = Wrappers.<FsUserWx>lambdaQuery()
|
|
|
+ .eq(FsUserWx::getFsUserId, param.getUserId())
|
|
|
+ .eq(FsUserWx::getAppId, payConfigDTO.getAppId());
|
|
|
+ FsUserWx fsUserWx = fsUserWxMapper.selectOne(queryWrapper);
|
|
|
+ if (fsUserWx!=null){
|
|
|
+ o.setOpenid(fsUserWx.getOpenId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ HuifuCreateOrderResult result = huiFuService.createOrder(o);
|
|
|
+ FsStorePaymentScrm mt=new FsStorePaymentScrm();
|
|
|
+ mt.setPaymentId(storePayment.getPaymentId());
|
|
|
+ mt.setTradeNo(result.getHf_seq_id());
|
|
|
+ mt.setAppId(appId);
|
|
|
+ storePaymentService.updateFsStorePayment(mt);
|
|
|
+ return R.ok().put("isPay",0).put("data",result).put("type","hf");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ throw new CustomException("支付失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return R.error();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 综合参数
|