|
@@ -1,21 +1,25 @@
|
|
package com.fs.hisStore.service.impl;
|
|
package com.fs.hisStore.service.impl;
|
|
|
|
|
|
|
|
+
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.Date;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+
|
|
|
|
+import java.util.*;
|
|
|
|
+
|
|
|
|
|
|
import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
|
import cn.binarywang.wx.miniapp.bean.WxMaJscode2SessionResult;
|
|
import cn.hutool.core.util.IdUtil;
|
|
import cn.hutool.core.util.IdUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
+import com.alibaba.fastjson.TypeReference;
|
|
import com.fs.common.annotation.DataScope;
|
|
import com.fs.common.annotation.DataScope;
|
|
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.utils.DateUtils;
|
|
import com.fs.common.utils.DateUtils;
|
|
import com.fs.common.utils.StringUtils;
|
|
import com.fs.common.utils.StringUtils;
|
|
|
|
+import com.fs.company.domain.Company;
|
|
import com.fs.company.domain.CompanyUser;
|
|
import com.fs.company.domain.CompanyUser;
|
|
import com.fs.company.mapper.CompanyConfigMapper;
|
|
import com.fs.company.mapper.CompanyConfigMapper;
|
|
import com.fs.company.service.ICompanyService;
|
|
import com.fs.company.service.ICompanyService;
|
|
@@ -26,20 +30,26 @@ import com.fs.course.config.RedPacketConfig;
|
|
import com.fs.course.domain.FsCourseRedPacketLog;
|
|
import com.fs.course.domain.FsCourseRedPacketLog;
|
|
import com.fs.course.mapper.FsCourseRedPacketLogMapper;
|
|
import com.fs.course.mapper.FsCourseRedPacketLogMapper;
|
|
import com.fs.course.service.IFsCourseRedPacketLogService;
|
|
import com.fs.course.service.IFsCourseRedPacketLogService;
|
|
|
|
+import com.fs.his.config.FsSysConfig;
|
|
|
|
+import com.fs.his.domain.FsUser;
|
|
import com.fs.his.domain.FsUserWx;
|
|
import com.fs.his.domain.FsUserWx;
|
|
|
|
+import com.fs.his.service.IFsUserService;
|
|
import com.fs.his.service.IFsUserWxService;
|
|
import com.fs.his.service.IFsUserWxService;
|
|
import com.fs.his.utils.ConfigUtil;
|
|
import com.fs.his.utils.ConfigUtil;
|
|
|
|
+import com.fs.his.utils.HttpUtil;
|
|
import com.fs.hisStore.enums.SysConfigEnum;
|
|
import com.fs.hisStore.enums.SysConfigEnum;
|
|
|
|
+import com.fs.hisStore.param.*;
|
|
|
|
+import com.fs.huifuPay.domain.HuiFuCreateOrder;
|
|
|
|
+import com.fs.huifuPay.domain.HuifuCreateOrderResult;
|
|
|
|
+import com.fs.huifuPay.service.HuiFuService;
|
|
import com.fs.pay.pay.config.PayConfig;
|
|
import com.fs.pay.pay.config.PayConfig;
|
|
import com.fs.pay.pay.dto.WxJspayDTO;
|
|
import com.fs.pay.pay.dto.WxJspayDTO;
|
|
-import com.fs.hisStore.param.FsStoreStatisticsParam;
|
|
|
|
-import com.fs.hisStore.param.WxSendRedPacketParam;
|
|
|
|
import com.fs.hisStore.vo.FsStorePaymentStatisticsVO;
|
|
import com.fs.hisStore.vo.FsStorePaymentStatisticsVO;
|
|
|
|
+import com.fs.system.oss.CloudStorageService;
|
|
|
|
+import com.fs.system.oss.OSSFactory;
|
|
import com.fs.system.service.ISysConfigService;
|
|
import com.fs.system.service.ISysConfigService;
|
|
import com.fs.wx.miniapp.config.WxMaProperties;
|
|
import com.fs.wx.miniapp.config.WxMaProperties;
|
|
import com.fs.hisStore.domain.FsUserScrm;
|
|
import com.fs.hisStore.domain.FsUserScrm;
|
|
-import com.fs.hisStore.param.FsStorePaymentPayParam;
|
|
|
|
-import com.fs.hisStore.param.FsStorePaymentParam;
|
|
|
|
import com.fs.hisStore.service.IFsUserScrmService;
|
|
import com.fs.hisStore.service.IFsUserScrmService;
|
|
import com.fs.hisStore.vo.FsStorePaymentVO;
|
|
import com.fs.hisStore.vo.FsStorePaymentVO;
|
|
import com.fs.pay.service.IPayService;
|
|
import com.fs.pay.service.IPayService;
|
|
@@ -54,6 +64,8 @@ import com.github.binarywang.wxpay.exception.WxPayException;
|
|
import com.github.binarywang.wxpay.service.TransferService;
|
|
import com.github.binarywang.wxpay.service.TransferService;
|
|
import com.github.binarywang.wxpay.service.WxPayService;
|
|
import com.github.binarywang.wxpay.service.WxPayService;
|
|
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
|
|
import com.github.binarywang.wxpay.service.impl.WxPayServiceImpl;
|
|
|
|
+import com.google.common.reflect.TypeToken;
|
|
|
|
+import com.google.gson.Gson;
|
|
import me.chanjar.weixin.common.error.WxErrorException;
|
|
import me.chanjar.weixin.common.error.WxErrorException;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -104,6 +116,13 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private CompanyConfigMapper companyConfigMapper;
|
|
private CompanyConfigMapper companyConfigMapper;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private HuiFuService huiFuService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private RedisCache redisCache;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 查询支付明细
|
|
* 查询支付明细
|
|
*
|
|
*
|
|
@@ -322,9 +341,9 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
storePayment.setBankTransactionId(bankTransactionId);
|
|
storePayment.setBankTransactionId(bankTransactionId);
|
|
fsStorePaymentMapper.updateFsStorePayment(storePayment);
|
|
fsStorePaymentMapper.updateFsStorePayment(storePayment);
|
|
//增加佣金
|
|
//增加佣金
|
|
- if(storePayment.getCompanyId()!=null&&storePayment.getCompanyId()>0){
|
|
|
|
- companyService.addCompanyPaymentMoney(storePayment);
|
|
|
|
- }
|
|
|
|
|
|
+// if(storePayment.getCompanyId()!=null&&storePayment.getCompanyId()>0){
|
|
|
|
+// companyService.addCompanyPaymentMoney(storePayment);
|
|
|
|
+// }
|
|
return "SUCCESS";
|
|
return "SUCCESS";
|
|
}
|
|
}
|
|
|
|
|
|
@@ -768,4 +787,115 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
}
|
|
}
|
|
return R.ok();
|
|
return R.ok();
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public R getWxaCodeByPayment(FsStorePaymentGetWxaCodeParam param) {
|
|
|
|
+ final WxMaService wxMaService = WxMaConfiguration.getMaService(param.getAppId());
|
|
|
|
+ String scene;
|
|
|
|
+ //判断销售id
|
|
|
|
+ if (param.getCompanyUserId() == null){
|
|
|
|
+ scene = "companyId="+ param.getCompanyId();
|
|
|
|
+ }else {
|
|
|
|
+ scene = "companyId="+ param.getCompanyId()+"&"+"companyUserId="+ param.getCompanyUserId();
|
|
|
|
+ }
|
|
|
|
+ byte[] file;
|
|
|
|
+ try {
|
|
|
|
+ file = wxMaService.getQrcodeService().createWxaCodeUnlimitBytes(
|
|
|
|
+ scene,
|
|
|
|
+ "pages_user/user/pay",
|
|
|
|
+ true,
|
|
|
|
+ "release",
|
|
|
|
+ 430,
|
|
|
|
+ true,
|
|
|
|
+ null,
|
|
|
|
+ false);
|
|
|
|
+
|
|
|
|
+ // 上传图片到存储桶
|
|
|
|
+ String suffix = ".png";
|
|
|
|
+ CloudStorageService storage = OSSFactory.build();
|
|
|
|
+ String url;
|
|
|
|
+ try {
|
|
|
|
+ url = storage.uploadSuffix(file, suffix);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ // 记录错误日志
|
|
|
|
+ logger.error("生成图片失败:{}",e.getMessage(),e);
|
|
|
|
+ return R.error("生成图片失败");
|
|
|
|
+ }
|
|
|
|
+ redisCache.setCacheObject("company-wxa-code:"+param.getCompanyId(),url);
|
|
|
|
+ // 返回成功信息
|
|
|
|
+ return R.ok().put("url",url);
|
|
|
|
+
|
|
|
|
+ } catch (WxErrorException e) {
|
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
|
+ return R.error("微信接口调用失败: " + e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private IFsUserService fsUserService;
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public R paymentByWxaCode(FsStorePaymentPayParam param) {
|
|
|
|
+ FsUser user = fsUserService.selectFsUserById(param.getUserId());
|
|
|
|
+ if (user==null){
|
|
|
|
+ return R.error("用户不存在!");
|
|
|
|
+ }
|
|
|
|
+ Company company = companyService.selectCompanyById(param.getCompanyId());
|
|
|
|
+ if (company==null || company.getStatus()==0){
|
|
|
|
+ return R.error("服务商不存在,或已被停用!");
|
|
|
|
+ }
|
|
|
|
+ if(param.getPayMoney().compareTo(new BigDecimal(0.0))<1){
|
|
|
|
+ return R.error("支付金额必须大于0");
|
|
|
|
+ }
|
|
|
|
+ if (param.getCompanyUserId()!=null){
|
|
|
|
+ CompanyUser companyUser = companyUserService.selectCompanyUserById(param.getCompanyUserId());
|
|
|
|
+ if(companyUser == null || companyUser.getStatus().equals("1")){
|
|
|
|
+ return R.error("注册失败客服已停用,或不存在!");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //生成支付流水
|
|
|
|
+ String orderSn = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
|
|
+ FsStorePaymentScrm storePayment=new FsStorePaymentScrm();
|
|
|
|
+ storePayment.setCompanyId(param.getCompanyId());
|
|
|
|
+ //判断销售是否存在
|
|
|
|
+ if (param.getCompanyUserId()!=null){
|
|
|
|
+ storePayment.setCompanyUserId(param.getCompanyUserId());
|
|
|
|
+ }
|
|
|
|
+ storePayment.setStatus(0);
|
|
|
|
+ storePayment.setPayCode(orderSn);
|
|
|
|
+ storePayment.setPayMoney(param.getPayMoney());
|
|
|
|
+ storePayment.setCreateTime(new Date());
|
|
|
|
+ storePayment.setPayTypeCode("weixin");
|
|
|
|
+ storePayment.setBusinessType(1);
|
|
|
|
+ storePayment.setRemark("商城收款订单支付");
|
|
|
|
+ storePayment.setOpenId(user.getMaOpenId());
|
|
|
|
+ storePayment.setUserId(user.getUserId());
|
|
|
|
+ fsStorePaymentMapper.insertFsStorePayment(storePayment);
|
|
|
|
+
|
|
|
|
+ //汇付支付
|
|
|
|
+ HuiFuCreateOrder o = new HuiFuCreateOrder();
|
|
|
|
+ o.setTradeType("T_MINIAPP");
|
|
|
|
+ o.setOpenid(user.getMaOpenId());
|
|
|
|
+ o.setReqSeqId("payment-"+storePayment.getPayCode());
|
|
|
|
+ o.setTransAmt(storePayment.getPayMoney().toString());
|
|
|
|
+ o.setGoodsDesc("商城订单支付");
|
|
|
|
+ HuifuCreateOrderResult result = huiFuService.createOrder(o);
|
|
|
|
+ if(result.getResp_code()!=null&&(result.getResp_code().equals("00000000")||result.getResp_code().equals("00000100"))){
|
|
|
|
+ FsStorePaymentScrm mt=new FsStorePaymentScrm();
|
|
|
|
+ mt.setPaymentId(storePayment.getPaymentId());
|
|
|
|
+ mt.setTradeNo(result.getHf_seq_id());
|
|
|
|
+ fsStorePaymentMapper.updateFsStorePayment(mt);
|
|
|
|
+ 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("result",resultMap);
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ return R.error(result.getResp_desc());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|