|
|
@@ -6,6 +6,7 @@ import cn.binarywang.wx.miniapp.bean.shop.request.shipping.*;
|
|
|
import cn.binarywang.wx.miniapp.bean.shop.response.WxMaOrderShippingInfoBaseResponse;
|
|
|
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;
|
|
|
@@ -50,9 +51,10 @@ import com.fs.config.cloud.CloudHostProper;
|
|
|
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.dto.FsOrderDeliveryNoteDTO;
|
|
|
import com.fs.course.dto.OrderOpenIdTransDTO;
|
|
|
-import com.fs.hisStore.dto.DeliveryNoteImportResultDTO;
|
|
|
+import com.fs.course.mapper.FsCoursePlaySourceConfigMapper;
|
|
|
import com.fs.erp.domain.*;
|
|
|
import com.fs.erp.dto.ErpOrderQueryRequert;
|
|
|
import com.fs.erp.dto.ErpOrderQueryResponse;
|
|
|
@@ -116,6 +118,12 @@ import com.fs.huifuPay.service.HuiFuService;
|
|
|
import com.fs.pay.pay.dto.OrderQueryDTO;
|
|
|
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.mapper.SysConfigMapper;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
import com.fs.system.service.ISysDictTypeService;
|
|
|
@@ -195,6 +203,13 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
@Autowired
|
|
|
private CompanyMoneyLogsMapper moneyLogsMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CompanyUserUserMapper companyUserUserMapper;
|
|
|
+ @Autowired
|
|
|
+ private FsCoursePlaySourceConfigMapper fsCoursePlaySourceConfigMapper;
|
|
|
+ @Autowired
|
|
|
+ private MerchantAppConfigMapper merchantAppConfigMapper;
|
|
|
@Autowired
|
|
|
private IFsStoreOrderStatusScrmService orderStatusService;
|
|
|
@Autowired
|
|
|
@@ -220,8 +235,6 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
|
|
|
@Autowired
|
|
|
private IFsStoreCartScrmService cartService;
|
|
|
- @Autowired
|
|
|
- private CompanyUserUserMapper companyUserUserMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private ApplicationEventPublisher publisher;
|
|
|
@@ -648,8 +661,11 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
public List<FsStoreOrderVO> selectFsStoreOrderListVO(FsStoreOrderParam param) {
|
|
|
List<FsStoreOrderVO> list = fsStoreOrderMapper.selectFsStoreOrderListVO(param);
|
|
|
for (FsStoreOrderVO vo : list) {
|
|
|
- String nickName = vo.getUserPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2");
|
|
|
- vo.setNickname(nickName);
|
|
|
+ if (StringUtils.isNotEmpty(vo.getUserPhone())){
|
|
|
+ String nickName = vo.getUserPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2");
|
|
|
+ vo.setNickname(nickName);
|
|
|
+ }
|
|
|
+
|
|
|
if (StringUtils.isNotEmpty(vo.getItemJson())) {
|
|
|
JSONArray jsonArray = JSONUtil.parseArray(vo.getItemJson());
|
|
|
List<FsStoreOrderItemVO> items = JSONUtil.toList(jsonArray, FsStoreOrderItemVO.class);
|
|
|
@@ -667,8 +683,11 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
public List<FsStoreOrderVO> selectFsStoreOrderAllListVO(FsStoreOrderParam param) {
|
|
|
List<FsStoreOrderVO> list = fsStoreOrderMapper.selectFsStoreOrderAllListVO(param);
|
|
|
for (FsStoreOrderVO vo : list) {
|
|
|
- String nickName = vo.getUserPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2");
|
|
|
- vo.setNickname(nickName);
|
|
|
+ if (StringUtils.isNotEmpty(vo.getUserPhone())){
|
|
|
+ String nickName = vo.getUserPhone().replaceAll("(\\d{3})\\d*(\\d{4})", "$1****$2");
|
|
|
+ vo.setNickname(nickName);
|
|
|
+ }
|
|
|
+
|
|
|
if (StringUtils.isNotEmpty(vo.getItemJson())) {
|
|
|
JSONArray jsonArray = JSONUtil.parseArray(vo.getItemJson());
|
|
|
List<FsStoreOrderItemVO> items = JSONUtil.toList(jsonArray, FsStoreOrderItemVO.class);
|
|
|
@@ -876,6 +895,12 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public R createOrder(long userId, FsStoreOrderCreateParam param) {
|
|
|
+ if (!CloudHostUtils.hasCloudHostName("鹤颜堂")){
|
|
|
+ log.error("进入到数据");
|
|
|
+ if (ObjectUtil.isEmpty(param.getAddressId())){
|
|
|
+ return R.error("地址不能为空!");
|
|
|
+ }
|
|
|
+ }
|
|
|
FsStoreOrderComputedParam computedParam = new FsStoreOrderComputedParam();
|
|
|
BeanUtils.copyProperties(param, computedParam);
|
|
|
//计算金额
|
|
|
@@ -983,10 +1008,12 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
|
|
|
storeOrder.setUserId(userId);
|
|
|
storeOrder.setOrderCode(orderSn);
|
|
|
- storeOrder.setRealName(address.getRealName());
|
|
|
- storeOrder.setUserPhone(address.getPhone());
|
|
|
- storeOrder.setUserAddress(address.getProvince() + " " + address.getCity() +
|
|
|
- " " + address.getDistrict() + " " + address.getDetail().trim());
|
|
|
+ if (ObjectUtil.isNotEmpty(address)){
|
|
|
+ storeOrder.setRealName(address.getRealName());
|
|
|
+ storeOrder.setUserPhone(address.getPhone());
|
|
|
+ storeOrder.setUserAddress(address.getProvince() + " " + address.getCity() +
|
|
|
+ " " + address.getDistrict() + " " + address.getDetail().trim());
|
|
|
+ }
|
|
|
storeOrder.setCartId(cartIds);
|
|
|
storeOrder.setTotalNum(Long.parseLong(String.valueOf(carts.size())));
|
|
|
storeOrder.setTotalPrice(dto.getTotalPrice());
|
|
|
@@ -2096,7 +2123,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
return "";
|
|
|
}
|
|
|
- } else if (type.equals(2)) {
|
|
|
+ }else if (type.equals(2)) {
|
|
|
//货到付款
|
|
|
order = fsStoreOrderMapper.selectFsStoreOrderById(orderId);
|
|
|
if (!order.getStatus().equals(OrderInfoEnum.STATUS_0.getValue())) {
|
|
|
@@ -2127,10 +2154,12 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
storeOrder.setPayTime(new Date());
|
|
|
fsStoreOrderMapper.updateFsStoreOrder(storeOrder);
|
|
|
// 添加订单审核
|
|
|
- if (storeOrder.getCompanyId() != null) {
|
|
|
+ if (storeOrder.getCompanyId() != null) {
|
|
|
addOrderAudit(order);
|
|
|
}
|
|
|
- return "SUCCESS";
|
|
|
+
|
|
|
+
|
|
|
+ return "SUCCESS";
|
|
|
|
|
|
|
|
|
//非处方直接提交OMS
|
|
|
@@ -2554,9 +2583,12 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
fsStoreAfterSalesParam.setProductList(productParams);
|
|
|
|
|
|
return fsStoreAfterSalesScrmService.applyForAfterSales(order.getUserId(),fsStoreAfterSalesParam);
|
|
|
- } else{
|
|
|
- jSTOrderService.refundUpdateScrm(request);
|
|
|
- }
|
|
|
+ }/* else{
|
|
|
+ ErpRefundOrder order1=new ErpRefundOrder();
|
|
|
+ order1.setOrderCode(order.getOrderCode());
|
|
|
+ order1.setDeliverySn(order.getDeliverySn());
|
|
|
+ erpOrderService.refundOrder(order1);
|
|
|
+ }*/
|
|
|
}
|
|
|
order.setStatus(-2);
|
|
|
order.setRefundPrice(order.getPayMoney());
|
|
|
@@ -2578,13 +2610,24 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
//将钱退还给用户
|
|
|
List<FsStorePaymentScrm> payments = paymentService.selectFsStorePaymentByOrderId(order.getId());
|
|
|
if (payments != null) {
|
|
|
- String json = configService.selectConfigByKey("his.pay");
|
|
|
-
|
|
|
- FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
|
|
|
for (FsStorePaymentScrm payment : payments) {
|
|
|
+ if (StringUtils.isBlank(payment.getAppId())) {
|
|
|
+ throw new IllegalArgumentException("appId不能为空");
|
|
|
+ }
|
|
|
+ FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(payment.getAppId());
|
|
|
+ if (fsCoursePlaySourceConfig == null) {
|
|
|
+ throw new CustomException("未找到appId对应的小程序配置: " + payment.getAppId());
|
|
|
+ }
|
|
|
+ Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
|
|
|
+ if (merchantConfigId == null || merchantConfigId <= 0) {
|
|
|
+ throw new CustomException("小程序没有配置商户信息");
|
|
|
+ }
|
|
|
+ MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
|
|
|
+ FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
|
|
|
+
|
|
|
if (payment.getPayMode() == null || payment.getPayMode().equals("wx")) {
|
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
|
- payConfig.setAppId(fsPayConfig.getAppId());
|
|
|
+ payConfig.setAppId(fsCoursePlaySourceConfig.getAppid());
|
|
|
payConfig.setMchId(fsPayConfig.getWxMchId());
|
|
|
payConfig.setMchKey(fsPayConfig.getWxMchKey());
|
|
|
payConfig.setKeyPath(fsPayConfig.getKeyPath());
|
|
|
@@ -2876,8 +2919,8 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
totalMoney = totalMoney.add(vo.getPrice().multiply(new BigDecimal(vo.getCartNum().toString())));
|
|
|
}
|
|
|
} else {
|
|
|
- //套餐制单
|
|
|
- totalMoney = carts.get(0).getPrice();
|
|
|
+ //套餐制单,这个金额是套餐的金额
|
|
|
+ totalMoney = redisCache.getCacheObject("createOrderMoney:" + createOrderKey);
|
|
|
}
|
|
|
if (money.compareTo(totalMoney) == 1) {
|
|
|
throw new CustomException("价格不能大于商品总价", 501);
|
|
|
@@ -3229,6 +3272,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
|
|
|
//获取运费模板区域列表按照城市排序
|
|
|
List<FsShippingTemplatesRegionScrm> shippingTemplatesRegionList = shippingTemplatesRegionService.selectFsShippingTemplatesRegionListByTempIdsAndCityIds(StringUtils.join(tempIds, ","), StringUtils.join(citys, ","));
|
|
|
+
|
|
|
boolean isQg = false;
|
|
|
|
|
|
if (CollectionUtils.isEmpty(shippingTemplatesRegionList)&&CollectionUtils.isNotEmpty(shippingTemplatesList)&&shippingTemplatesList.size()<2) {
|
|
|
@@ -4605,7 +4649,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
else if(param.getPayType().equals(2)){
|
|
|
order.setPayType("2");
|
|
|
BigDecimal payMoney=order.getPayPrice().multiply(new BigDecimal(storeConfig.getPayRate())).divide(new BigDecimal(100));
|
|
|
- payMoney=new BigDecimal(payMoney.setScale(0, BigDecimal.ROUND_HALF_UP).longValue());
|
|
|
+ payMoney=new BigDecimal(payMoney.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
// 如果小程序需要支付的金额小于0.01元,不能走物流代收,让走货到付款 xgb
|
|
|
if (payMoney.compareTo(new BigDecimal("0.01")) < 0) {
|
|
|
return R.error("物流代收计算支付金额为0,不允许选择物流代收");
|
|
|
@@ -4637,14 +4681,25 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
}
|
|
|
this.updateFsStoreOrder(order);
|
|
|
}
|
|
|
- String payCode = OrderCodeUtils.getOrderSn();
|
|
|
+ String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
|
if((order.getPayType().equals("1")||order.getPayType().equals("2")||order.getPayType().equals("3")) && order.getPayMoney().compareTo(new BigDecimal(0))>0){
|
|
|
- String json = configService.selectConfigByKey(STORE_PAY_CONF);
|
|
|
- FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
|
|
|
+ if (StringUtils.isBlank(param.getAppId())) {
|
|
|
+ throw new IllegalArgumentException("appId不能为空");
|
|
|
+ }
|
|
|
+ FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
|
|
|
+ if (fsCoursePlaySourceConfig == null) {
|
|
|
+ throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
|
|
|
+ }
|
|
|
+ Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
|
|
|
+ if (merchantConfigId == null || merchantConfigId <= 0) {
|
|
|
+ throw new CustomException("小程序没有配置商户信息");
|
|
|
+ }
|
|
|
+ MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
|
|
|
+ FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
|
|
|
FsStorePaymentScrm storePayment=new FsStorePaymentScrm();
|
|
|
storePayment.setCompanyId(order.getCompanyId());
|
|
|
storePayment.setCompanyUserId(order.getCompanyUserId());
|
|
|
- storePayment.setPayMode(fsPayConfig.getType());
|
|
|
+ storePayment.setPayMode(merchantAppConfig.getMerchantType());
|
|
|
storePayment.setStatus(0);
|
|
|
storePayment.setPayCode(payCode);
|
|
|
storePayment.setPayMoney(order.getPayMoney());
|
|
|
@@ -4656,10 +4711,10 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
storePayment.setUserId(user.getUserId());
|
|
|
storePayment.setBusinessOrderId(order.getId().toString());
|
|
|
storePayment.setOrderId(order.getId());
|
|
|
- storePayment.setAppId(fsPayConfig.getAppId() == null ? "" : fsPayConfig.getAppId());
|
|
|
+ storePayment.setAppId(fsCoursePlaySourceConfig.getAppid() == null ? "" : fsCoursePlaySourceConfig.getAppid());
|
|
|
fsStorePaymentMapper.insertFsStorePayment(storePayment);
|
|
|
|
|
|
- if (fsPayConfig.getType().equals("hf")){
|
|
|
+ if (merchantAppConfig.getMerchantType().equals("hf")){
|
|
|
HuiFuCreateOrder o = new HuiFuCreateOrder();
|
|
|
o.setTradeType("T_MINIAPP");
|
|
|
o.setOpenid(user.getMaOpenId());
|
|
|
@@ -4668,7 +4723,8 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
o.setGoodsDesc("商城订单支付");
|
|
|
o.setAppId(param.getAppId());
|
|
|
try {
|
|
|
- HuiFuUtils.doDiv(o,order.getCompanyId());
|
|
|
+
|
|
|
+ HuiFuUtils.doDiv(o,order.getCompanyId(), storePayment.getMerConfigId());
|
|
|
//存储分账明细
|
|
|
HuiFuUtils.saveDivItem(o, order.getOrderCode(), storePayment.getPayCode());
|
|
|
} catch (Exception e) {
|
|
|
@@ -4691,9 +4747,9 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
else{
|
|
|
return R.error(result.getResp_desc());
|
|
|
}
|
|
|
- }else if (fsPayConfig.getType().equals("wx")){
|
|
|
+ }else if (merchantAppConfig.getMerchantType().equals("wx")){
|
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
|
- payConfig.setAppId(fsPayConfig.getAppId());
|
|
|
+ payConfig.setAppId(fsCoursePlaySourceConfig.getAppid());
|
|
|
payConfig.setMchId(fsPayConfig.getWxMchId());
|
|
|
payConfig.setMchKey(fsPayConfig.getWxMchKey());
|
|
|
payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
|
|
|
@@ -4776,14 +4832,25 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
if(!order.getIsPayRemain().equals(0)){
|
|
|
return R.error("此订单已支付");
|
|
|
}
|
|
|
- String payCode = OrderCodeUtils.getOrderSn();
|
|
|
- String json = configService.selectConfigByKey(STORE_PAY_CONF);
|
|
|
- FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
|
|
|
+ String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
|
+ if (StringUtils.isBlank(param.getAppId())) {
|
|
|
+ throw new IllegalArgumentException("appId不能为空");
|
|
|
+ }
|
|
|
+ FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
|
|
|
+ if (fsCoursePlaySourceConfig == null) {
|
|
|
+ throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
|
|
|
+ }
|
|
|
+ Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
|
|
|
+ if (merchantConfigId == null || merchantConfigId <= 0) {
|
|
|
+ throw new CustomException("小程序没有配置商户信息");
|
|
|
+ }
|
|
|
+ MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
|
|
|
+ FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
|
|
|
FsStorePaymentScrm storePayment=new FsStorePaymentScrm();
|
|
|
storePayment.setCompanyId(order.getCompanyId());
|
|
|
storePayment.setCompanyUserId(order.getCompanyUserId());
|
|
|
storePayment.setStatus(0);
|
|
|
- storePayment.setPayMode(fsPayConfig.getType());
|
|
|
+ storePayment.setPayMode(merchantAppConfig.getMerchantType());
|
|
|
storePayment.setPayCode(payCode);
|
|
|
storePayment.setPayMoney(order.getPayDelivery());
|
|
|
storePayment.setCreateTime(new Date());
|
|
|
@@ -4797,7 +4864,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
storePayment.setIsPayRemain(1);
|
|
|
fsStorePaymentMapper.insertFsStorePayment(storePayment);
|
|
|
|
|
|
- if (fsPayConfig.getType().equals("hf")){
|
|
|
+ if (merchantAppConfig.getMerchantType().equals("hf")){
|
|
|
HuiFuCreateOrder o = new HuiFuCreateOrder();
|
|
|
o.setTradeType("T_MINIAPP");
|
|
|
o.setOpenid(user.getMaOpenId());
|
|
|
@@ -4820,10 +4887,10 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
else{
|
|
|
return R.error(result.getResp_desc());
|
|
|
}
|
|
|
- }else if (fsPayConfig.getType().equals("wx")){
|
|
|
+ }else if (merchantAppConfig.getMerchantType().equals("wx")){
|
|
|
//创建微信订单
|
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
|
- payConfig.setAppId(fsPayConfig.getAppId());
|
|
|
+ payConfig.setAppId(fsCoursePlaySourceConfig.getAppid());
|
|
|
payConfig.setMchId(fsPayConfig.getWxMchId());
|
|
|
payConfig.setMchKey(fsPayConfig.getWxMchKey());
|
|
|
payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
|
|
|
@@ -4893,16 +4960,27 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
return R.error("正在支付中...");
|
|
|
}
|
|
|
|
|
|
- String json = configService.selectConfigByKey(STORE_PAY_CONF);
|
|
|
- FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
|
|
|
- String payCode = OrderCodeUtils.getOrderSn();
|
|
|
+ if (StringUtils.isBlank(param.getAppId())) {
|
|
|
+ throw new IllegalArgumentException("appId不能为空");
|
|
|
+ }
|
|
|
+ FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
|
|
|
+ if (fsCoursePlaySourceConfig == null) {
|
|
|
+ throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
|
|
|
+ }
|
|
|
+ Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
|
|
|
+ if (merchantConfigId == null || merchantConfigId <= 0) {
|
|
|
+ throw new CustomException("小程序没有配置商户信息");
|
|
|
+ }
|
|
|
+ MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
|
|
|
+ FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
|
|
|
+ String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
|
//易宝支付
|
|
|
FsStorePaymentScrm storePayment=new FsStorePaymentScrm();
|
|
|
storePayment.setCompanyId(order.getCompanyId());
|
|
|
storePayment.setCompanyUserId(order.getCompanyUserId());
|
|
|
storePayment.setStatus(0);
|
|
|
storePayment.setPayCode(payCode);
|
|
|
- storePayment.setPayMode(fsPayConfig.getType());
|
|
|
+ storePayment.setPayMode(merchantAppConfig.getMerchantType());
|
|
|
storePayment.setPayMoney(order.getPayMoney());
|
|
|
storePayment.setCreateTime(new Date());
|
|
|
storePayment.setPayTypeCode("weixin");
|
|
|
@@ -4914,7 +4992,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
storePayment.setOrderId(order.getId());
|
|
|
fsStorePaymentMapper.insertFsStorePayment(storePayment);
|
|
|
|
|
|
- if (fsPayConfig.getType().equals("hf")){
|
|
|
+ if (merchantAppConfig.getMerchantType().equals("hf")){
|
|
|
HuiFuCreateOrder o = new HuiFuCreateOrder();
|
|
|
o.setTradeType("T_MINIAPP");
|
|
|
o.setOpenid(user.getMaOpenId());
|
|
|
@@ -4937,10 +5015,10 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
else{
|
|
|
return R.error(result.getResp_desc());
|
|
|
}
|
|
|
- }else if (fsPayConfig.getType().equals("wx")){
|
|
|
+ }else if (merchantAppConfig.getMerchantType().equals("wx")){
|
|
|
//创建微信订单
|
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
|
- payConfig.setAppId(fsPayConfig.getAppId());
|
|
|
+ payConfig.setAppId(fsCoursePlaySourceConfig.getAppid());
|
|
|
payConfig.setMchId(fsPayConfig.getWxMchId());
|
|
|
payConfig.setMchKey(fsPayConfig.getWxMchKey());
|
|
|
payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
|
|
|
@@ -4994,14 +5072,25 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
}
|
|
|
FsUserScrm user=userService.selectFsUserById(order.getUserId());
|
|
|
if(user!=null){
|
|
|
- String payCode = OrderCodeUtils.getOrderSn();
|
|
|
- String json = configService.selectConfigByKey(STORE_PAY_CONF);
|
|
|
- FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
|
|
|
+ String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
|
+ if (StringUtils.isBlank(param.getAppId())) {
|
|
|
+ throw new IllegalArgumentException("appId不能为空");
|
|
|
+ }
|
|
|
+ FsCoursePlaySourceConfig fsCoursePlaySourceConfig = fsCoursePlaySourceConfigMapper.selectCoursePlaySourceConfigByAppId(param.getAppId());
|
|
|
+ if (fsCoursePlaySourceConfig == null) {
|
|
|
+ throw new CustomException("未找到appId对应的小程序配置: " + param.getAppId());
|
|
|
+ }
|
|
|
+ Long merchantConfigId = fsCoursePlaySourceConfig.getMerchantConfigId();
|
|
|
+ if (merchantConfigId == null || merchantConfigId <= 0) {
|
|
|
+ throw new CustomException("小程序没有配置商户信息");
|
|
|
+ }
|
|
|
+ MerchantAppConfig merchantAppConfig = merchantAppConfigMapper.selectMerchantAppConfigById(fsCoursePlaySourceConfig.getMerchantConfigId());
|
|
|
+ FsPayConfig fsPayConfig = JSON.parseObject(merchantAppConfig.getDataJson(), FsPayConfig.class);
|
|
|
FsStorePaymentScrm storePayment=new FsStorePaymentScrm();
|
|
|
storePayment.setCompanyId(order.getCompanyId());
|
|
|
storePayment.setCompanyUserId(order.getCompanyUserId());
|
|
|
storePayment.setStatus(0);
|
|
|
- storePayment.setPayMode(fsPayConfig.getType());
|
|
|
+ storePayment.setPayMode(merchantAppConfig.getMerchantType());
|
|
|
storePayment.setPayCode(payCode);
|
|
|
storePayment.setPayMoney(order.getPayDelivery());
|
|
|
storePayment.setCreateTime(new Date());
|
|
|
@@ -5015,7 +5104,7 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
storePayment.setIsPayRemain(1);
|
|
|
fsStorePaymentMapper.insertFsStorePayment(storePayment);
|
|
|
|
|
|
- if (fsPayConfig.getType().equals("hf")){
|
|
|
+ if (merchantAppConfig.getMerchantType().equals("hf")){
|
|
|
HuiFuCreateOrder o = new HuiFuCreateOrder();
|
|
|
o.setTradeType("T_MINIAPP");
|
|
|
o.setOpenid(user.getMaOpenId());
|
|
|
@@ -5039,9 +5128,9 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
else{
|
|
|
return R.error(result.getResp_desc());
|
|
|
}
|
|
|
- }else if(fsPayConfig.getType().equals("wx")) {
|
|
|
+ }else if(merchantAppConfig.getMerchantType().equals("wx")) {
|
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
|
- payConfig.setAppId(fsPayConfig.getAppId());
|
|
|
+ payConfig.setAppId(fsCoursePlaySourceConfig.getAppid());
|
|
|
payConfig.setMchId(fsPayConfig.getWxMchId());
|
|
|
payConfig.setMchKey(fsPayConfig.getWxMchKey());
|
|
|
payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
|
|
|
@@ -5116,10 +5205,14 @@ public class FsStoreOrderScrmServiceImpl implements IFsStoreOrderScrmService {
|
|
|
order.setPayDelivery(BigDecimal.ZERO);
|
|
|
}
|
|
|
else if(param.getPayType().equals(2)){
|
|
|
-
|
|
|
+ // 物流代收
|
|
|
order.setPayType("2");
|
|
|
BigDecimal payMoney=order.getPayPrice().multiply(new BigDecimal(storeConfig.getPayRate())).divide(new BigDecimal(100));
|
|
|
- payMoney=new BigDecimal(payMoney.setScale(0, BigDecimal.ROUND_HALF_UP).longValue());
|
|
|
+ payMoney=new BigDecimal(payMoney.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue());
|
|
|
+ // 如果小程序需要支付的金额小于0.01元,不能走物流代收,让走货到付款 xgb
|
|
|
+ if (payMoney.compareTo(new BigDecimal("0.01")) < 0) {
|
|
|
+ return R.error("物流代收计算支付金额为0,不允许选择物流代收");
|
|
|
+ }
|
|
|
order.setPayDelivery(order.getPayPrice().subtract(payMoney));
|
|
|
order.setPayMoney(payMoney);
|
|
|
}
|