|
@@ -5,9 +5,11 @@ import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
|
+import cn.binarywang.wx.miniapp.api.WxMaService;
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.alibaba.fastjson.TypeReference;
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.fs.common.annotation.DataScope;
|
|
@@ -20,9 +22,15 @@ import com.fs.common.utils.ServletUtils;
|
|
|
import com.fs.common.utils.StringUtils;
|
|
|
import com.fs.common.utils.ip.IpUtils;
|
|
|
import com.fs.common.utils.poi.ExcelUtil;
|
|
|
+import com.fs.company.domain.Company;
|
|
|
+import com.fs.company.domain.CompanyUser;
|
|
|
import com.fs.company.mapper.CompanyConfigMapper;
|
|
|
import com.fs.company.param.FsStoreStatisticsParam;
|
|
|
+import com.fs.company.service.ICompanyService;
|
|
|
+import com.fs.company.service.ICompanyUserService;
|
|
|
import com.fs.company.vo.FsStorePaymentStatisticsVO;
|
|
|
+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.config.CourseConfig;
|
|
@@ -47,9 +55,12 @@ import com.fs.his.param.WxSendRedPacketParam;
|
|
|
import com.fs.his.service.IFsInquiryOrderService;
|
|
|
import com.fs.his.service.IFsPackageOrderService;
|
|
|
import com.fs.his.service.IFsStoreOrderService;
|
|
|
+import com.fs.his.service.IFsStorePaymentService;
|
|
|
import com.fs.his.utils.PhoneUtil;
|
|
|
import com.fs.his.vo.FsStorePaymentExcelVO;
|
|
|
import com.fs.his.vo.FsStorePaymentVO;
|
|
|
+import com.fs.hisStore.param.FsStorePaymentGetWxaCodeParam;
|
|
|
+import com.fs.hisStore.param.FsStorePaymentPayParam;
|
|
|
import com.fs.huifuPay.domain.HuiFuCreateOrder;
|
|
|
import com.fs.huifuPay.domain.HuiFuQueryOrderResult;
|
|
|
import com.fs.huifuPay.domain.HuiFuRefundResult;
|
|
@@ -59,6 +70,8 @@ import com.fs.huifuPay.sdk.opps.core.request.V2TradePaymentScanpayRefundRequest;
|
|
|
import com.fs.huifuPay.service.HuiFuService;
|
|
|
import com.fs.system.domain.SysConfig;
|
|
|
import com.fs.system.mapper.SysConfigMapper;
|
|
|
+import com.fs.system.oss.CloudStorageService;
|
|
|
+import com.fs.system.oss.OSSFactory;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
import com.fs.tzBankPay.TzBankService.TzBankService;
|
|
|
import com.fs.tzBankPay.TzBankService.TzBankServiceImpl.TzBankServiceImpl;
|
|
@@ -102,7 +115,6 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import com.fs.his.service.IFsStorePaymentService;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
@@ -152,6 +164,13 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
private FsUserMapper userMapper;
|
|
|
@Autowired
|
|
|
private FsUserWxMapper userWxMapper;
|
|
|
+ @Autowired
|
|
|
+ private ICompanyUserService companyUserService;
|
|
|
+ @Autowired
|
|
|
+ private ICompanyService companyService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CloudHostProper cloudHostProper;
|
|
|
|
|
|
/**
|
|
|
* 查询支付明细
|
|
@@ -571,7 +590,7 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
if(StringUtils.isEmpty(code)){
|
|
|
return R.error("红包单号生成失败,请重试");
|
|
|
}
|
|
|
- request.setOutBatchNo("fsCourse" + code);
|
|
|
+ request.setOutBatchNo("fsCourse"+cloudHostProper.getProjectCode() + code);
|
|
|
request.setBatchRemark("课堂答题奖励");
|
|
|
request.setBatchName("课堂答题奖励");
|
|
|
Integer amount = WxPayUnifiedOrderRequest.yuanToFen(param.getAmount().toString());
|
|
@@ -583,7 +602,7 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
TransferBatchesRequest.TransferDetail transferDetail = new TransferBatchesRequest.TransferDetail();
|
|
|
transferDetail.setOpenid(param.getOpenId());
|
|
|
String code1 = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
|
- transferDetail.setOutDetailNo("fsCourse" + code1);
|
|
|
+ transferDetail.setOutDetailNo("fsCourse"+cloudHostProper.getProjectCode() + code1);
|
|
|
transferDetail.setTransferAmount(amount);
|
|
|
transferDetail.setTransferRemark("恭喜同学,认真听课,奖励你一朵小红花!");
|
|
|
transferDetailList.add(transferDetail);
|
|
@@ -1152,4 +1171,112 @@ public class FsStorePaymentServiceImpl implements IFsStorePaymentService {
|
|
|
return storePayment;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @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("生成图片失败");
|
|
|
+ }
|
|
|
+ // 返回成功信息
|
|
|
+ return R.ok().put("url",url);
|
|
|
+
|
|
|
+ } catch (WxErrorException e) {
|
|
|
+ logger.error(e.getMessage(), e);
|
|
|
+ return R.error("微信接口调用失败: " + e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R paymentByWxaCode(FsStorePaymentPayParam param) {
|
|
|
+ FsUser user = userMapper.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();
|
|
|
+ FsStorePayment storePayment=new FsStorePayment();
|
|
|
+ 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"))){
|
|
|
+ FsStorePayment mt=new FsStorePayment();
|
|
|
+ mt.setPaymentId(storePayment.getPaymentId());
|
|
|
+ mt.setTradeNo(result.getHf_seq_id());
|
|
|
+ fsStorePaymentMapper.updateFsStorePayment(mt);
|
|
|
+ Map<String, Object> resultMap = com.alibaba.fastjson.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());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|