|
|
@@ -44,14 +44,17 @@ import com.fs.core.config.WxMaConfiguration;
|
|
|
import com.fs.core.config.WxPayProperties;
|
|
|
import com.fs.core.utils.OrderCodeUtils;
|
|
|
import com.fs.course.domain.FsCoursePlaySourceConfig;
|
|
|
+import com.fs.course.domain.FsUserCompanyUser;
|
|
|
import com.fs.course.dto.FsOrderDeliveryNoteDTO;
|
|
|
import com.fs.course.dto.OrderOpenIdTransDTO;
|
|
|
import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
|
|
|
+import com.fs.course.mapper.FsUserCompanyUserMapper;
|
|
|
import com.fs.erp.domain.*;
|
|
|
import com.fs.erp.dto.*;
|
|
|
import com.fs.erp.dto.df.*;
|
|
|
import com.fs.erp.mapper.FsErpFinishPushMapper;
|
|
|
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;
|
|
|
@@ -105,6 +108,7 @@ 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.service.ISysConfigService;
|
|
|
import com.fs.system.service.ISysDictTypeService;
|
|
|
import com.fs.wx.miniapp.config.WxMaProperties;
|
|
|
@@ -125,6 +129,7 @@ import com.github.binarywang.wxpay.config.WxPayConfig;
|
|
|
import com.github.binarywang.wxpay.exception.WxPayException;
|
|
|
import com.github.binarywang.wxpay.service.WxPayService;
|
|
|
import com.google.common.base.Joiner;
|
|
|
+import com.google.gson.Gson;
|
|
|
import lombok.Synchronized;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
@@ -151,6 +156,7 @@ import org.redisson.api.RedissonClient;
|
|
|
import javax.annotation.PostConstruct;
|
|
|
import java.lang.reflect.Field;
|
|
|
import java.math.BigDecimal;
|
|
|
+import java.math.RoundingMode;
|
|
|
import java.nio.charset.Charset;
|
|
|
import java.sql.Timestamp;
|
|
|
import java.text.ParseException;
|
|
|
@@ -201,6 +207,10 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
@Autowired
|
|
|
private FsStoreCartScrmMapper cartMapper;
|
|
|
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private FsUserCompanyUserMapper fsUserCompanyUserMapper;
|
|
|
+
|
|
|
@Autowired
|
|
|
private FsUserAddressScrmMapper userAddressMapper;
|
|
|
|
|
|
@@ -867,12 +877,20 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public R createOrder(long userId, FsStoreOrderCreateParam param) {
|
|
|
+
|
|
|
+ FsUserCompanyUser fsUserCompanyUser = fsUserCompanyUserMapper.selectFsUserCompanyUserByUserId(userId);
|
|
|
+ if (ObjectUtil.isNotEmpty(fsUserCompanyUser)){
|
|
|
+ param.setCompanyId(fsUserCompanyUser.getCompanyId());
|
|
|
+ param.setCompanyUserId(fsUserCompanyUser.getCompanyUserId());
|
|
|
+ }
|
|
|
+
|
|
|
if (!CloudHostUtils.hasCloudHostName("鹤颜堂")){
|
|
|
log.error("进入到数据");
|
|
|
if (ObjectUtil.isEmpty(param.getAddressId())){
|
|
|
return R.error("地址不能为空!");
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
FsStoreOrderComputedParam computedParam = new FsStoreOrderComputedParam();
|
|
|
BeanUtils.copyProperties(param, computedParam);
|
|
|
//计算金额
|
|
|
@@ -1022,17 +1040,19 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
}
|
|
|
|
|
|
//付款方式
|
|
|
- if (param.getPayType().equals("1")) {
|
|
|
+ if (param.getPayType().equals("1") || param.getPayType().equals("99")) {
|
|
|
//全款支付
|
|
|
storeOrder.setStatus(0);
|
|
|
if("广州郑多燕".equals(cloudHostProper.getCompanyName())){
|
|
|
BigDecimal amount = redisCache.getCacheObject("createOrderAmount:" + param.getCreateOrderKey());
|
|
|
storeOrder.setPayDelivery(amount != null ? amount : BigDecimal.ZERO);
|
|
|
}
|
|
|
- } else if (param.getPayType().equals("2")) {
|
|
|
+ }
|
|
|
+ else if (param.getPayType().equals("2")) {
|
|
|
//物流代收
|
|
|
storeOrder.setStatus(1);
|
|
|
- } else if (param.getPayType().equals("3")) {
|
|
|
+ }
|
|
|
+ else if (param.getPayType().equals("3")) {
|
|
|
//货到付款
|
|
|
BigDecimal amount = param.getAmount(); //货到付款 自定义代收金额
|
|
|
if (amount != null && amount.compareTo(BigDecimal.ZERO) > 0) {
|
|
|
@@ -2560,7 +2580,9 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
//将钱退还给用户
|
|
|
List<FsStorePaymentScrm> payments = paymentService.selectFsStorePaymentByOrderId(order.getId());
|
|
|
if (payments != null) {
|
|
|
+
|
|
|
for (FsStorePaymentScrm payment : payments) {
|
|
|
+
|
|
|
if (StringUtils.isBlank(payment.getAppId())) {
|
|
|
throw new IllegalArgumentException("appId不能为空");
|
|
|
}
|
|
|
@@ -2572,10 +2594,20 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
if (merchantConfigId == null || merchantConfigId <= 0) {
|
|
|
throw new CustomException("小程序没有配置商户信息");
|
|
|
}
|
|
|
- MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
|
|
|
- FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
|
|
|
+
|
|
|
+ String payType = payment.getPayMode();
|
|
|
+ if ("wxApp".equals(payment.getPayMode())){
|
|
|
+ payType = "wx";
|
|
|
+ }
|
|
|
+
|
|
|
+// MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
|
|
|
+// FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
|
|
|
|
|
|
if (payment.getPayMode() == null || payment.getPayMode().equals("wx")) {
|
|
|
+
|
|
|
+ MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigByAppId(payment.getAppId(),payType);
|
|
|
+ FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
|
|
|
+
|
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
|
payConfig.setAppId(payment.getAppId());
|
|
|
payConfig.setMchId(fsPayConfig.getWxMchId());
|
|
|
@@ -2608,6 +2640,10 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
return R.error("退款请求失败" + e.getErrCodeDes());
|
|
|
}
|
|
|
} else if (payment.getPayMode() != null && payment.getPayMode().equals("hf")) {
|
|
|
+
|
|
|
+ MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigByAppId(payment.getAppId(),payType);
|
|
|
+ FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
|
|
|
+
|
|
|
String huifuId="";
|
|
|
FsHfpayConfigMapper fsHfpayConfigMapper = SpringUtils.getBean(FsHfpayConfigMapper.class);
|
|
|
if (payment.getAppId() != null) {
|
|
|
@@ -2631,13 +2667,28 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
V2TradePaymentScanpayRefundRequest request = new V2TradePaymentScanpayRefundRequest();
|
|
|
request.setOrgHfSeqId(payment.getTradeNo());
|
|
|
request.setHuifuId(huifuId);
|
|
|
- request.setOrdAmt(payment.getPayMoney().toString());
|
|
|
+
|
|
|
+// request.setOrdAmt(payment.getPayMoney().toString());
|
|
|
+// request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
|
|
|
+// request.setReqSeqId("refund-" + payment.getPayCode());
|
|
|
+// Map<String, Object> extendInfoMap = new HashMap<>();
|
|
|
+// extendInfoMap.put("org_party_order_id", payment.getBankSerialNo());
|
|
|
+// request.setAppId(payment.getAppId());
|
|
|
+//
|
|
|
+ Map<String, Object> extendInfoMap = new HashMap<>();
|
|
|
+ if (order.getPayType().equals("99")){
|
|
|
+ request.setOrdAmt(payment.getPayMoney().setScale(2, RoundingMode.DOWN).toString());
|
|
|
+ extendInfoMap.put("org_req_seq_id", "store-"+payment.getPayCode());
|
|
|
+ }else {
|
|
|
+ request.setOrdAmt(payment.getPayMoney().toString());
|
|
|
+ extendInfoMap.put("org_party_order_id", payment.getBankSerialNo());
|
|
|
+ request.setAppId(payment.getAppId());
|
|
|
+ }
|
|
|
+
|
|
|
request.setOrgReqDate(new SimpleDateFormat("yyyyMMdd").format(payment.getCreateTime()));
|
|
|
request.setReqSeqId("refund-" + payment.getPayCode());
|
|
|
- Map<String, Object> extendInfoMap = new HashMap<>();
|
|
|
- extendInfoMap.put("org_party_order_id", payment.getBankSerialNo());
|
|
|
request.setExtendInfo(extendInfoMap);
|
|
|
- request.setAppId(payment.getAppId());
|
|
|
+
|
|
|
HuiFuRefundResult refund = huiFuService.refund(request);
|
|
|
logger.info("退款:" + refund);
|
|
|
if ((refund.getResp_code().equals("00000000") || refund.getResp_code().equals("00000100")) && (refund.getTrans_stat().equals("S") || refund.getTrans_stat().equals("P"))) {
|
|
|
@@ -5050,17 +5101,13 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
else{
|
|
|
String config=configService.selectConfigByKey("his.store");
|
|
|
com.fs.store.config.StoreConfig storeConfig= JSONUtil.toBean(config, com.fs.store.config.StoreConfig.class);
|
|
|
- if(param.getPayType().equals(1)){
|
|
|
- order.setPayType("1");
|
|
|
+ if(param.getPayType().equals(1)||param.getPayType().equals(99)||param.getPayType().equals(5)){
|
|
|
+
|
|
|
+ order.setPayType(String.valueOf(param.getPayType()));
|
|
|
order.setPayMoney(order.getPayPrice());
|
|
|
if(!"广州郑多燕".equals(cloudHostProper.getCompanyName())){
|
|
|
order.setPayDelivery(BigDecimal.ZERO);
|
|
|
}
|
|
|
-// else {
|
|
|
-// // 郑多燕单独设置支付类型
|
|
|
-// order.setPayType(order.getPayPrice().compareTo(order.getTotalPrice()) == 0 ?"1":"5");
|
|
|
-// logger.info("修改价格--------实际支付金额和总金额:{},{},", order.getPayPrice(), order.getTotalPrice());
|
|
|
-// }
|
|
|
}
|
|
|
else if(param.getPayType().equals(2)){
|
|
|
// 物流代收
|
|
|
@@ -6017,6 +6064,9 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
}
|
|
|
|
|
|
PayOrderParam payOrderParam = buildPayOrderParam(paymentMethod, order);
|
|
|
+ //加前端传来的appid
|
|
|
+ payOrderParam.setAppId(param.getAppId());
|
|
|
+
|
|
|
return storePaymentService.processPaymentScrm(payOrderParam);
|
|
|
}
|
|
|
|