|
@@ -24,6 +24,7 @@ import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
+import com.alibaba.fastjson.TypeReference;
|
|
|
import com.fs.common.config.FSSysConfig;
|
|
import com.fs.common.config.FSSysConfig;
|
|
|
import com.fs.common.core.domain.R;
|
|
import com.fs.common.core.domain.R;
|
|
|
import com.fs.common.core.redis.RedisCache;
|
|
import com.fs.common.core.redis.RedisCache;
|
|
@@ -33,6 +34,7 @@ import com.fs.common.event.TemplateListenEnum;
|
|
|
import com.fs.common.exception.CustomException;
|
|
import com.fs.common.exception.CustomException;
|
|
|
import com.fs.common.exception.ServiceException;
|
|
import com.fs.common.exception.ServiceException;
|
|
|
import com.fs.common.utils.*;
|
|
import com.fs.common.utils.*;
|
|
|
|
|
+import com.fs.common.utils.ip.IpUtils;
|
|
|
import com.fs.company.domain.Company;
|
|
import com.fs.company.domain.Company;
|
|
|
import com.fs.company.domain.CompanyDept;
|
|
import com.fs.company.domain.CompanyDept;
|
|
|
import com.fs.company.domain.CompanyMoneyLogs;
|
|
import com.fs.company.domain.CompanyMoneyLogs;
|
|
@@ -67,6 +69,7 @@ import com.fs.hisStore.enums.OrderLogEnum;
|
|
|
import com.fs.hisStore.enums.ShipperCodeEnum;
|
|
import com.fs.hisStore.enums.ShipperCodeEnum;
|
|
|
import com.fs.hisStore.enums.SysConfigEnum;
|
|
import com.fs.hisStore.enums.SysConfigEnum;
|
|
|
import com.fs.hisStore.mapper.FsStoreProductAttrValueScrmMapper;
|
|
import com.fs.hisStore.mapper.FsStoreProductAttrValueScrmMapper;
|
|
|
|
|
+import com.fs.hisStore.mapper.FsUserScrmMapper;
|
|
|
import com.fs.hisStore.param.FsStoreOrderAddTuiMoneyParam;
|
|
import com.fs.hisStore.param.FsStoreOrderAddTuiMoneyParam;
|
|
|
import com.fs.hisStore.param.FsStoreOrderParam;
|
|
import com.fs.hisStore.param.FsStoreOrderParam;
|
|
|
import com.fs.hisStore.param.FsStoreOrderScrmSetErpPhoneParam;
|
|
import com.fs.hisStore.param.FsStoreOrderScrmSetErpPhoneParam;
|
|
@@ -75,6 +78,9 @@ import com.fs.hisStore.service.IFsStoreProductScrmService;
|
|
|
import com.fs.hisStore.vo.FsMyStoreOrderListQueryVO;
|
|
import com.fs.hisStore.vo.FsMyStoreOrderListQueryVO;
|
|
|
import com.fs.hisStore.vo.FsStoreOrderItemVO;
|
|
import com.fs.hisStore.vo.FsStoreOrderItemVO;
|
|
|
import com.fs.hisStore.vo.FsStoreOrderVO;
|
|
import com.fs.hisStore.vo.FsStoreOrderVO;
|
|
|
|
|
+import com.fs.huifuPay.domain.HuiFuCreateOrder;
|
|
|
|
|
+import com.fs.huifuPay.domain.HuifuCreateOrderResult;
|
|
|
|
|
+import com.fs.huifuPay.service.HuiFuService;
|
|
|
import com.fs.live.domain.*;
|
|
import com.fs.live.domain.*;
|
|
|
import com.fs.live.dto.LiveOrderComputeDTO;
|
|
import com.fs.live.dto.LiveOrderComputeDTO;
|
|
|
import com.fs.live.dto.LiveOrderCustomerExportDTO;
|
|
import com.fs.live.dto.LiveOrderCustomerExportDTO;
|
|
@@ -85,6 +91,11 @@ import com.fs.live.service.*;
|
|
|
import com.fs.live.vo.*;
|
|
import com.fs.live.vo.*;
|
|
|
import com.fs.store.domain.*;
|
|
import com.fs.store.domain.*;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
|
|
+import com.github.binarywang.wxpay.bean.order.WxPayMpOrderResult;
|
|
|
|
|
+import com.github.binarywang.wxpay.bean.request.WxPayUnifiedOrderRequest;
|
|
|
|
|
+import com.github.binarywang.wxpay.config.WxPayConfig;
|
|
|
|
|
+import com.github.binarywang.wxpay.exception.WxPayException;
|
|
|
|
|
+import com.github.binarywang.wxpay.service.WxPayService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang.ObjectUtils;
|
|
import org.apache.commons.lang.ObjectUtils;
|
|
@@ -120,6 +131,11 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private LiveMapper liveMapper;
|
|
private LiveMapper liveMapper;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private HuiFuService huiFuService;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private WxPayService wxPayService;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private LiveGoodsMapper liveGoodsMapper;
|
|
private LiveGoodsMapper liveGoodsMapper;
|
|
@@ -134,7 +150,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
private IFsStoreProductScrmService fsStoreProductService;
|
|
private IFsStoreProductScrmService fsStoreProductService;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
- FsUserMapper userMapper;
|
|
|
|
|
|
|
+ FsUserScrmMapper userMapper;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private IErpOrderService erpOrderService;
|
|
private IErpOrderService erpOrderService;
|
|
@@ -678,10 +694,10 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
@Override
|
|
@Override
|
|
|
public LiveOrder selectLiveOrderByOrderId(String orderId)
|
|
public LiveOrder selectLiveOrderByOrderId(String orderId)
|
|
|
{
|
|
{
|
|
|
-// LiveOrder liveOrder = baseMapper.selectLiveOrderByOrderId(orderId);
|
|
|
|
|
-// if(ObjectUtil.isNull(liveOrder)) {
|
|
|
|
|
-// throw new RuntimeException("该订单没有找到!");
|
|
|
|
|
-// }
|
|
|
|
|
|
|
+ LiveOrder liveOrder = baseMapper.selectLiveOrderByOrderId(orderId);
|
|
|
|
|
+ if(ObjectUtil.isNull(liveOrder)) {
|
|
|
|
|
+ throw new RuntimeException("该订单没有找到!");
|
|
|
|
|
+ }
|
|
|
// List<FsStoreDelivers> byOrderIdWithType = fsStoreDeliversMapper.findByOrderIdWithType(Long.valueOf(orderId), 1);
|
|
// List<FsStoreDelivers> byOrderIdWithType = fsStoreDeliversMapper.findByOrderIdWithType(Long.valueOf(orderId), 1);
|
|
|
// if(CollectionUtils.isNotEmpty(byOrderIdWithType)) {
|
|
// if(CollectionUtils.isNotEmpty(byOrderIdWithType)) {
|
|
|
// FsStoreDelivers delivers = byOrderIdWithType.get(0);
|
|
// FsStoreDelivers delivers = byOrderIdWithType.get(0);
|
|
@@ -693,15 +709,14 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
// liveOrder.setDeliveryStatus(delivers.getStatus());
|
|
// liveOrder.setDeliveryStatus(delivers.getStatus());
|
|
|
// liveOrder.setDeliveryType(String.valueOf(delivers.getStateEx()));
|
|
// liveOrder.setDeliveryType(String.valueOf(delivers.getStateEx()));
|
|
|
// } else {
|
|
// } else {
|
|
|
-// liveOrder.setDeliveryCode(null);
|
|
|
|
|
-// liveOrder.setDeliveryName(null);
|
|
|
|
|
-// liveOrder.setDeliverySn(null);
|
|
|
|
|
-//
|
|
|
|
|
-// liveOrder.setDeliveryStatus(null);
|
|
|
|
|
-// liveOrder.setDeliveryType(null);
|
|
|
|
|
|
|
+ liveOrder.setDeliveryCode(null);
|
|
|
|
|
+ liveOrder.setDeliveryName(null);
|
|
|
|
|
+ liveOrder.setDeliverySn(null);
|
|
|
|
|
+
|
|
|
|
|
+ liveOrder.setDeliveryStatus(null);
|
|
|
|
|
+ liveOrder.setDeliveryType(null);
|
|
|
// }
|
|
// }
|
|
|
-// return liveOrder;
|
|
|
|
|
- return null;
|
|
|
|
|
|
|
+ return liveOrder;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
@@ -2408,7 +2423,7 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
if(liveOrder==null || !liveOrder.getStatus().equals(1)){
|
|
if(liveOrder==null || !liveOrder.getStatus().equals(1)){
|
|
|
throw new CustomException("当前订单未找到或者订单状态不为待支付! orderId:" + orderId);
|
|
throw new CustomException("当前订单未找到或者订单状态不为待支付! orderId:" + orderId);
|
|
|
}
|
|
}
|
|
|
- FsUser user = userMapper.selectFsUserByUserId(Long.valueOf(liveOrder.getUserId()));
|
|
|
|
|
|
|
+ FsUserScrm user = userMapper.selectFsUserById(Long.valueOf(liveOrder.getUserId()));
|
|
|
if(user == null) return R.error("用户不存在");
|
|
if(user == null) return R.error("用户不存在");
|
|
|
String json = configService.selectConfigByKey("store.pay");
|
|
String json = configService.selectConfigByKey("store.pay");
|
|
|
FsPayConfig fsPayConfig = JSON.parseObject(json, FsPayConfig.class);
|
|
FsPayConfig fsPayConfig = JSON.parseObject(json, FsPayConfig.class);
|
|
@@ -2483,6 +2498,146 @@ public class LiveOrderServiceImpl implements ILiveOrderService {
|
|
|
return baseMapper.selectLiveOrderListZm(liveOrder);
|
|
return baseMapper.selectLiveOrderListZm(liveOrder);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Transactional(rollbackFor = Throwable.class,propagation = Propagation.REQUIRED)
|
|
|
|
|
+ public R handleLiveOrderPay(LiveOrderPayParam param) {
|
|
|
|
|
+ LiveOrder order=baseMapper.selectLiveOrderByOrderId(String.valueOf(param.getOrderId()));
|
|
|
|
|
+ if(order==null){
|
|
|
|
|
+ return R.error("订单不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ if(order.getStatus()!= OrderInfoEnum.STATUS_0.getValue()){
|
|
|
|
|
+ return R.error("订单状态不正确");
|
|
|
|
|
+ }
|
|
|
|
|
+ String orderId=redisCache.getCacheObject("isPaying:"+order.getOrderId());
|
|
|
|
|
+ if(StringUtils.isNotEmpty(orderId)&&orderId.equals(order.getOrderId().toString())){
|
|
|
|
|
+ return R.error("正在支付中...");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ FsUserScrm user=userMapper.selectFsUserById(Long.valueOf(order.getUserId()));
|
|
|
|
|
+ if(user!=null&& StringUtils.isNotEmpty(user.getMaOpenId())){
|
|
|
|
|
+ //已改价处理
|
|
|
|
|
+ if(order.getIsEditMoney()!=null&&order.getIsEditMoney()==1){
|
|
|
|
|
+ //改过价不做处理
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ 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");
|
|
|
|
|
+ order.setPayMoney(order.getPayPrice());
|
|
|
|
|
+ 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());
|
|
|
|
|
+ order.setPayDelivery(order.getPayPrice().subtract(payMoney));
|
|
|
|
|
+ order.setPayMoney(payMoney);
|
|
|
|
|
+ }
|
|
|
|
|
+ else if(param.getPayType().equals(3)){
|
|
|
|
|
+ //货到付款
|
|
|
|
|
+ order.setPayType("3");
|
|
|
|
|
+ BigDecimal amount=redisCache.getCacheObject("orderAmount:"+order.getOrderId());
|
|
|
|
|
+ BigDecimal payMoney = BigDecimal.ZERO;
|
|
|
|
|
+ if (amount != null){
|
|
|
|
|
+ payMoney=amount;
|
|
|
|
|
+ }
|
|
|
|
|
+ order.setPayMoney(payMoney);
|
|
|
|
|
+ order.setPayDelivery(order.getPayPrice().subtract(payMoney) );
|
|
|
|
|
+// order.setPayMoney(BigDecimal.ZERO);
|
|
|
|
|
+ }
|
|
|
|
|
+ baseMapper.updateLiveOrder(order);
|
|
|
|
|
+ }
|
|
|
|
|
+ String payCode = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
|
|
|
+// order.setOrderCode(orderCode);
|
|
|
|
|
+// if(order.getPayType().equals("1")||order.getPayType().equals("2")){
|
|
|
|
|
+ if((order.getPayType().equals("1")||order.getPayType().equals("2")||order.getPayType().equals("3")) && order.getPayMoney().compareTo(new BigDecimal(0))>0){
|
|
|
|
|
+ String json = configService.selectConfigByKey("his.pay");
|
|
|
|
|
+ FsPayConfigScrm fsPayConfig = JSON.parseObject(json, FsPayConfigScrm.class);
|
|
|
|
|
+ LiveOrderPayment storePayment=new LiveOrderPayment();
|
|
|
|
|
+ storePayment.setCompanyId(order.getCompanyId());
|
|
|
|
|
+ storePayment.setCompanyUserId(order.getCompanyUserId());
|
|
|
|
|
+ storePayment.setPayMode(fsPayConfig.getType());
|
|
|
|
|
+ storePayment.setStatus(0);
|
|
|
|
|
+ storePayment.setPayCode(payCode);
|
|
|
|
|
+ storePayment.setPayMoney(order.getPayMoney());
|
|
|
|
|
+ storePayment.setCreateTime(new Date());
|
|
|
|
|
+ storePayment.setPayTypeCode("weixin");
|
|
|
|
|
+ storePayment.setBusinessType(2);
|
|
|
|
|
+ storePayment.setRemark("直播订单支付");
|
|
|
|
|
+ storePayment.setOpenId(user.getRealName());
|
|
|
|
|
+ storePayment.setUserId(user.getUserId());
|
|
|
|
|
+ storePayment.setBusinessId(String.valueOf(order.getOrderId()));
|
|
|
|
|
+ liveOrderPaymentMapper.insertLiveOrderPayment(storePayment);
|
|
|
|
|
+
|
|
|
|
|
+ if (fsPayConfig.getType().equals("hf")){
|
|
|
|
|
+ HuiFuCreateOrder o = new HuiFuCreateOrder();
|
|
|
|
|
+ o.setTradeType("T_MINIAPP");
|
|
|
|
|
+ o.setOpenid(user.getMaOpenId());
|
|
|
|
|
+ o.setReqSeqId("live-"+storePayment.getPayCode());
|
|
|
|
|
+ o.setTransAmt(storePayment.getPayMoney().toString());
|
|
|
|
|
+ o.setGoodsDesc("直播订单支付");
|
|
|
|
|
+ if (param != null && StringUtils.isNotBlank(param.getAppId())) {
|
|
|
|
|
+ o.setAppId(param.getAppId());
|
|
|
|
|
+ }
|
|
|
|
|
+ HuifuCreateOrderResult result = huiFuService.createOrder(o);
|
|
|
|
|
+ if(result.getResp_code()!=null&&(result.getResp_code().equals("00000000")||result.getResp_code().equals("00000100"))){
|
|
|
|
|
+ LiveOrderPayment mt=new LiveOrderPayment();
|
|
|
|
|
+ mt.setPaymentId(storePayment.getPaymentId());
|
|
|
|
|
+ mt.setTradeNo(result.getHf_seq_id());
|
|
|
|
|
+ liveOrderPaymentMapper.updateLiveOrderPayment(mt);
|
|
|
|
|
+ redisCache.setCacheObject("isPaying:"+order.getOrderId(),order.getOrderId().toString(),1, TimeUnit.MINUTES);
|
|
|
|
|
+ Map<String, Object> resultMap = JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {});
|
|
|
|
|
+ String s = (String) resultMap.get("package");
|
|
|
|
|
+ resultMap.put("packageValue",s);
|
|
|
|
|
+ return R.ok().put("payType",param.getPayType()).put("result",resultMap);
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ return R.error(result.getResp_desc());
|
|
|
|
|
+ }
|
|
|
|
|
+ }else if (fsPayConfig.getType().equals("wx")){
|
|
|
|
|
+ WxPayConfig payConfig = new WxPayConfig();
|
|
|
|
|
+ payConfig.setAppId(fsPayConfig.getAppId());
|
|
|
|
|
+ payConfig.setMchId(fsPayConfig.getWxMchId());
|
|
|
|
|
+ payConfig.setMchKey(fsPayConfig.getWxMchKey());
|
|
|
|
|
+ payConfig.setSubAppId(org.apache.commons.lang3.StringUtils.trimToNull(null));
|
|
|
|
|
+ payConfig.setSubMchId(org.apache.commons.lang3.StringUtils.trimToNull(null));
|
|
|
|
|
+ payConfig.setKeyPath(fsPayConfig.getKeyPath());
|
|
|
|
|
+ payConfig.setNotifyUrl(fsPayConfig.getNotifyUrlScrm());
|
|
|
|
|
+ wxPayService.setConfig(payConfig);
|
|
|
|
|
+ WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
|
|
|
|
|
+ orderRequest.setOpenid(user.getMaOpenId());//公众号支付提供用户openid
|
|
|
|
|
+ orderRequest.setBody("直播订单支付");
|
|
|
|
|
+ orderRequest.setOutTradeNo("live-" + storePayment.getPayCode());
|
|
|
|
|
+ orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(storePayment.getPayMoney().toString()));//测试
|
|
|
|
|
+ //orderRequest.setTotalFee(WxPayUnifiedOrderRequest.yuanToFen(money));//测试
|
|
|
|
|
+ orderRequest.setTradeType("JSAPI");
|
|
|
|
|
+ orderRequest.setSpbillCreateIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
|
|
|
|
|
+ //调用统一下单接口,获取"预支付交易会话标识"
|
|
|
|
|
+ try {
|
|
|
|
|
+ WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
|
|
|
|
|
+ return R.ok().put("result", orderResult).put("type", "wx").put("isPay", 0).put("payType",param.getPayType());
|
|
|
|
|
+ } catch (WxPayException e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ throw new CustomException("支付失败" + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+// else if(order.getPayType().equals("3")){
|
|
|
|
|
+ else if(order.getPayType().equals("3") && order.getPayMoney().compareTo(new BigDecimal(0))<=0){
|
|
|
|
|
+ //货到付款
|
|
|
|
|
+ this.payConfirm(2,order.getOrderId(),null,null,null,null);
|
|
|
|
|
+ return R.ok().put("payType",param.getPayType());
|
|
|
|
|
+ }
|
|
|
|
|
+ return R.error();
|
|
|
|
|
+ }
|
|
|
|
|
+ else{
|
|
|
|
|
+ return R.error("用户OPENID不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Throwable.class,propagation = Propagation.REQUIRED)
|
|
@Transactional(rollbackFor = Throwable.class,propagation = Propagation.REQUIRED)
|