|
@@ -3,11 +3,16 @@ package com.fs.hisStore.service.impl;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
|
|
|
|
+import java.time.ZoneId;
|
|
|
|
|
+import java.time.ZonedDateTime;
|
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
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.binarywang.wx.miniapp.bean.shop.request.shipping.*;
|
|
|
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.JSON;
|
|
@@ -28,27 +33,31 @@ import com.fs.core.config.WxMaConfiguration;
|
|
|
import com.fs.core.utils.OrderCodeUtils;
|
|
import com.fs.core.utils.OrderCodeUtils;
|
|
|
import com.fs.course.config.RedPacketConfig;
|
|
import com.fs.course.config.RedPacketConfig;
|
|
|
import com.fs.course.domain.FsCourseRedPacketLog;
|
|
import com.fs.course.domain.FsCourseRedPacketLog;
|
|
|
|
|
+import com.fs.course.dto.FsOrderDeliveryNoteDTO;
|
|
|
|
|
+import com.fs.course.dto.FsPaymentDeliveryNoteDTO;
|
|
|
|
|
+import com.fs.course.dto.OrderOpenIdTransDTO;
|
|
|
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.course.vo.FsStorePaymentUsetVo;
|
|
|
import com.fs.his.domain.FsUser;
|
|
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.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.config.StoreConfig;
|
|
|
import com.fs.hisStore.enums.SysConfigEnum;
|
|
import com.fs.hisStore.enums.SysConfigEnum;
|
|
|
import com.fs.hisStore.param.*;
|
|
import com.fs.hisStore.param.*;
|
|
|
|
|
+import com.fs.hisStore.vo.FsStoreOrderCodeOpenIdVo;
|
|
|
import com.fs.huifuPay.domain.HuiFuCreateOrder;
|
|
import com.fs.huifuPay.domain.HuiFuCreateOrder;
|
|
|
import com.fs.huifuPay.domain.HuifuCreateOrderResult;
|
|
import com.fs.huifuPay.domain.HuifuCreateOrderResult;
|
|
|
import com.fs.huifuPay.sdk.opps.core.utils.HuiFuUtils;
|
|
import com.fs.huifuPay.sdk.opps.core.utils.HuiFuUtils;
|
|
|
import com.fs.huifuPay.service.HuiFuService;
|
|
import com.fs.huifuPay.service.HuiFuService;
|
|
|
-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.vo.FsStorePaymentStatisticsVO;
|
|
import com.fs.hisStore.vo.FsStorePaymentStatisticsVO;
|
|
|
import com.fs.system.oss.CloudStorageService;
|
|
import com.fs.system.oss.CloudStorageService;
|
|
|
import com.fs.system.oss.OSSFactory;
|
|
import com.fs.system.oss.OSSFactory;
|
|
|
import com.fs.system.service.ISysConfigService;
|
|
import com.fs.system.service.ISysConfigService;
|
|
|
|
|
+import com.fs.utils.TwelveDigitSnowflake;
|
|
|
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.service.IFsUserScrmService;
|
|
import com.fs.hisStore.service.IFsUserScrmService;
|
|
@@ -65,9 +74,7 @@ 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 lombok.Synchronized;
|
|
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
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;
|
|
@@ -88,8 +95,8 @@ import javax.servlet.http.HttpServletRequest;
|
|
|
* @date 2022-06-20
|
|
* @date 2022-06-20
|
|
|
*/
|
|
*/
|
|
|
@Service
|
|
@Service
|
|
|
-public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
|
|
-{
|
|
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService {
|
|
|
Logger logger = LoggerFactory.getLogger(getClass());
|
|
Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private WxMaProperties properties;
|
|
private WxMaProperties properties;
|
|
@@ -132,8 +139,7 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
* @return 支付明细
|
|
* @return 支付明细
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public FsStorePaymentScrm selectFsStorePaymentById(Long paymentId)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public FsStorePaymentScrm selectFsStorePaymentById(Long paymentId) {
|
|
|
return fsStorePaymentMapper.selectFsStorePaymentById(paymentId);
|
|
return fsStorePaymentMapper.selectFsStorePaymentById(paymentId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -144,8 +150,7 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
* @return 支付明细
|
|
* @return 支付明细
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public List<FsStorePaymentScrm> selectFsStorePaymentList(FsStorePaymentScrm fsStorePayment)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public List<FsStorePaymentScrm> selectFsStorePaymentList(FsStorePaymentScrm fsStorePayment) {
|
|
|
return fsStorePaymentMapper.selectFsStorePaymentList(fsStorePayment);
|
|
return fsStorePaymentMapper.selectFsStorePaymentList(fsStorePayment);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -156,8 +161,7 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
* @return 结果
|
|
* @return 结果
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public int insertFsStorePayment(FsStorePaymentScrm fsStorePayment)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public int insertFsStorePayment(FsStorePaymentScrm fsStorePayment) {
|
|
|
fsStorePayment.setCreateTime(DateUtils.getNowDate());
|
|
fsStorePayment.setCreateTime(DateUtils.getNowDate());
|
|
|
return fsStorePaymentMapper.insertFsStorePayment(fsStorePayment);
|
|
return fsStorePaymentMapper.insertFsStorePayment(fsStorePayment);
|
|
|
}
|
|
}
|
|
@@ -169,8 +173,7 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
* @return 结果
|
|
* @return 结果
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public int updateFsStorePayment(FsStorePaymentScrm fsStorePayment)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public int updateFsStorePayment(FsStorePaymentScrm fsStorePayment) {
|
|
|
return fsStorePaymentMapper.updateFsStorePayment(fsStorePayment);
|
|
return fsStorePaymentMapper.updateFsStorePayment(fsStorePayment);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -181,8 +184,7 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
* @return 结果
|
|
* @return 结果
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public int deleteFsStorePaymentByIds(Long[] paymentIds)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public int deleteFsStorePaymentByIds(Long[] paymentIds) {
|
|
|
return fsStorePaymentMapper.deleteFsStorePaymentByIds(paymentIds);
|
|
return fsStorePaymentMapper.deleteFsStorePaymentByIds(paymentIds);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -193,15 +195,14 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
* @return 结果
|
|
* @return 结果
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public int deleteFsStorePaymentById(Long paymentId)
|
|
|
|
|
- {
|
|
|
|
|
|
|
+ public int deleteFsStorePaymentById(Long paymentId) {
|
|
|
return fsStorePaymentMapper.deleteFsStorePaymentById(paymentId);
|
|
return fsStorePaymentMapper.deleteFsStorePaymentById(paymentId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional
|
|
@Transactional
|
|
|
public R payment(FsStorePaymentPayParam payment) {
|
|
public R payment(FsStorePaymentPayParam payment) {
|
|
|
- if(payment.getPayMoney().compareTo(new BigDecimal(0.0))<1){
|
|
|
|
|
|
|
+ if (payment.getPayMoney().compareTo(new BigDecimal(0.0)) < 1) {
|
|
|
return R.error("支付金额必须大于0");
|
|
return R.error("支付金额必须大于0");
|
|
|
}
|
|
}
|
|
|
// //获取OPENID
|
|
// //获取OPENID
|
|
@@ -213,8 +214,8 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
// } catch (WxErrorException e) {
|
|
// } catch (WxErrorException e) {
|
|
|
// e.printStackTrace();
|
|
// e.printStackTrace();
|
|
|
// }
|
|
// }
|
|
|
- CompanyUser companyUser=companyUserService.selectCompanyUserById(payment.getCompanyUserId());
|
|
|
|
|
- FsUserScrm user=userService.selectFsUserById(payment.getUserId());
|
|
|
|
|
|
|
+ CompanyUser companyUser = companyUserService.selectCompanyUserById(payment.getCompanyUserId());
|
|
|
|
|
+ FsUserScrm user = userService.selectFsUserById(payment.getUserId());
|
|
|
// if(user==null){
|
|
// if(user==null){
|
|
|
// //写入
|
|
// //写入
|
|
|
// user=new FsUser();
|
|
// user=new FsUser();
|
|
@@ -227,7 +228,7 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
// user.setIsWeixinAuth(0);
|
|
// user.setIsWeixinAuth(0);
|
|
|
// userService.insertFsUser(user);
|
|
// userService.insertFsUser(user);
|
|
|
// }
|
|
// }
|
|
|
- FsStorePaymentScrm storePayment=new FsStorePaymentScrm();
|
|
|
|
|
|
|
+ FsStorePaymentScrm storePayment = new FsStorePaymentScrm();
|
|
|
storePayment.setCompanyId(payment.getCompanyId());
|
|
storePayment.setCompanyId(payment.getCompanyId());
|
|
|
storePayment.setCompanyUserId(payment.getCompanyUserId());
|
|
storePayment.setCompanyUserId(payment.getCompanyUserId());
|
|
|
storePayment.setStatus(0);
|
|
storePayment.setStatus(0);
|
|
@@ -239,7 +240,7 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
storePayment.setRemark(payment.getRemark());
|
|
storePayment.setRemark(payment.getRemark());
|
|
|
storePayment.setOpenId(user.getMaOpenId());
|
|
storePayment.setOpenId(user.getMaOpenId());
|
|
|
storePayment.setUserId(user.getUserId());
|
|
storePayment.setUserId(user.getUserId());
|
|
|
- if(companyUser==null){
|
|
|
|
|
|
|
+ if (companyUser == null) {
|
|
|
return R.error("销售帐号不存在");
|
|
return R.error("销售帐号不存在");
|
|
|
}
|
|
}
|
|
|
storePayment.setDeptId(companyUser.getDeptId());
|
|
storePayment.setDeptId(companyUser.getDeptId());
|
|
@@ -249,7 +250,7 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
WxJspayDTO p = new WxJspayDTO();
|
|
WxJspayDTO p = new WxJspayDTO();
|
|
|
// 使用setter方法为对象赋值
|
|
// 使用setter方法为对象赋值
|
|
|
p.setPayMoney(storePayment.getPayMoney().toString());
|
|
p.setPayMoney(storePayment.getPayMoney().toString());
|
|
|
- p.setLowOrderId("payment-"+storePayment.getPayCode());
|
|
|
|
|
|
|
+ p.setLowOrderId("payment-" + storePayment.getPayCode());
|
|
|
p.setBody("超重/肥胖/气血/代谢/美乳/慢病医学管理方案服务");
|
|
p.setBody("超重/肥胖/气血/代谢/美乳/慢病医学管理方案服务");
|
|
|
p.setIsMinipg("1");
|
|
p.setIsMinipg("1");
|
|
|
//p.setReturnUrl(PayConfig.notifyUrl);
|
|
//p.setReturnUrl(PayConfig.notifyUrl);
|
|
@@ -258,14 +259,13 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
p.setAttach("");
|
|
p.setAttach("");
|
|
|
p.setStoreid("0");
|
|
p.setStoreid("0");
|
|
|
CreateWxOrderResult wxOrder = ybPayService.createWxOrder(p);
|
|
CreateWxOrderResult wxOrder = ybPayService.createWxOrder(p);
|
|
|
- if(wxOrder.getStatus().equals("100")){
|
|
|
|
|
- FsStorePaymentScrm ment=new FsStorePaymentScrm();
|
|
|
|
|
|
|
+ if (wxOrder.getStatus().equals("100")) {
|
|
|
|
|
+ FsStorePaymentScrm ment = new FsStorePaymentScrm();
|
|
|
ment.setPaymentId(storePayment.getPaymentId());
|
|
ment.setPaymentId(storePayment.getPaymentId());
|
|
|
ment.setTradeNo(wxOrder.getUpOrderId());
|
|
ment.setTradeNo(wxOrder.getUpOrderId());
|
|
|
fsStorePaymentMapper.updateFsStorePayment(ment);
|
|
fsStorePaymentMapper.updateFsStorePayment(ment);
|
|
|
- return R.ok().put("result",wxOrder.getPay_info());
|
|
|
|
|
- }
|
|
|
|
|
- else{
|
|
|
|
|
|
|
+ return R.ok().put("result", wxOrder.getPay_info());
|
|
|
|
|
+ } else {
|
|
|
return R.error(wxOrder.getMessage());
|
|
return R.error(wxOrder.getMessage());
|
|
|
}
|
|
}
|
|
|
//小雨点支付
|
|
//小雨点支付
|
|
@@ -308,7 +308,7 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- @DataScope(deptAlias = "cu",userAlias = "cu")
|
|
|
|
|
|
|
+ @DataScope(deptAlias = "cu", userAlias = "cu")
|
|
|
public List<FsStorePaymentVO> selectFsStorePaymentListQueryVO(FsStorePaymentParam fsStorePayment) {
|
|
public List<FsStorePaymentVO> selectFsStorePaymentListQueryVO(FsStorePaymentParam fsStorePayment) {
|
|
|
return fsStorePaymentMapper.selectFsStorePaymentListQueryVO(fsStorePayment);
|
|
return fsStorePaymentMapper.selectFsStorePaymentListQueryVO(fsStorePayment);
|
|
|
}
|
|
}
|
|
@@ -324,16 +324,16 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public Long selectFsStorePaymentCount(int type,Long companyId,Long companyUserId) {
|
|
|
|
|
- return fsStorePaymentMapper.selectFsStorePaymentCount(type,companyId,companyUserId);
|
|
|
|
|
|
|
+ public Long selectFsStorePaymentCount(int type, Long companyId, Long companyUserId) {
|
|
|
|
|
+ return fsStorePaymentMapper.selectFsStorePaymentCount(type, companyId, companyUserId);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional
|
|
@Transactional
|
|
|
- public String payConfirm(String payCode,String tradeNo,String bankTransactionId,String bankSerialNo) {
|
|
|
|
|
|
|
+ public String payConfirm(String payCode, String tradeNo, String bankTransactionId, String bankSerialNo) {
|
|
|
//更新订单状态
|
|
//更新订单状态
|
|
|
- FsStorePaymentScrm storePayment=fsStorePaymentMapper.selectFsStorePaymentByCode(payCode);
|
|
|
|
|
- if(!storePayment.getStatus().equals(0)){
|
|
|
|
|
|
|
+ FsStorePaymentScrm storePayment = fsStorePaymentMapper.selectFsStorePaymentByCode(payCode);
|
|
|
|
|
+ if (!storePayment.getStatus().equals(0)) {
|
|
|
return "";
|
|
return "";
|
|
|
}
|
|
}
|
|
|
storePayment.setStatus(1);
|
|
storePayment.setStatus(1);
|
|
@@ -352,12 +352,12 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional
|
|
@Transactional
|
|
|
public String refund(String orderCode) {
|
|
public String refund(String orderCode) {
|
|
|
- FsStorePaymentScrm payment=fsStorePaymentMapper.selectFsStorePaymentByCode(orderCode);
|
|
|
|
|
|
|
+ FsStorePaymentScrm payment = fsStorePaymentMapper.selectFsStorePaymentByCode(orderCode);
|
|
|
payment.setStatus(-1);
|
|
payment.setStatus(-1);
|
|
|
payment.setRefundTime(new Date());
|
|
payment.setRefundTime(new Date());
|
|
|
fsStorePaymentMapper.updateFsStorePayment(payment);
|
|
fsStorePaymentMapper.updateFsStorePayment(payment);
|
|
|
//收款 减去所有
|
|
//收款 减去所有
|
|
|
- if(payment.getCompanyId()!=null&&payment.getCompanyId()>0){
|
|
|
|
|
|
|
+ if (payment.getCompanyId() != null && payment.getCompanyId() > 0) {
|
|
|
companyService.subCompanyPaymentMoney(payment);
|
|
companyService.subCompanyPaymentMoney(payment);
|
|
|
}
|
|
}
|
|
|
return "success";
|
|
return "success";
|
|
@@ -389,7 +389,7 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
String json;
|
|
String json;
|
|
|
RedPacketConfig config = new RedPacketConfig();
|
|
RedPacketConfig config = new RedPacketConfig();
|
|
|
// 根据红包模式获取配置
|
|
// 根据红包模式获取配置
|
|
|
- switch (param.getRedPacketMode()){
|
|
|
|
|
|
|
+ switch (param.getRedPacketMode()) {
|
|
|
case 1:
|
|
case 1:
|
|
|
json = configService.selectConfigByKey("redPacket.config");
|
|
json = configService.selectConfigByKey("redPacket.config");
|
|
|
config = JSONUtil.toBean(json, RedPacketConfig.class);
|
|
config = JSONUtil.toBean(json, RedPacketConfig.class);
|
|
@@ -400,7 +400,7 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
break;
|
|
break;
|
|
|
}
|
|
}
|
|
|
//H5的用公众号的appid发,小程序的用小程序的appid来发
|
|
//H5的用公众号的appid发,小程序的用小程序的appid来发
|
|
|
- if (param.getSource()==2){
|
|
|
|
|
|
|
+ if (param.getSource() == 2) {
|
|
|
config.setAppId(param.getAppId());
|
|
config.setAppId(param.getAppId());
|
|
|
}
|
|
}
|
|
|
//组合返回参数
|
|
//组合返回参数
|
|
@@ -409,13 +409,13 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
if (config.getIsNew() != null && config.getIsNew() == 1) {
|
|
if (config.getIsNew() != null && config.getIsNew() == 1) {
|
|
|
result = sendRedPacketV3Internal(param, config);
|
|
result = sendRedPacketV3Internal(param, config);
|
|
|
} else {
|
|
} else {
|
|
|
- result= sendRedPacketLegacyInternal(param, config);
|
|
|
|
|
|
|
+ result = sendRedPacketLegacyInternal(param, config);
|
|
|
}
|
|
}
|
|
|
- result.put("isNew",config.getIsNew());
|
|
|
|
|
|
|
+ result.put("isNew", config.getIsNew());
|
|
|
// result.put("mchId",config.getMchId());
|
|
// result.put("mchId",config.getMchId());
|
|
|
|
|
|
|
|
- result.put("mchId",config.getMchId());
|
|
|
|
|
- System.out.println("发红包返回"+result);
|
|
|
|
|
|
|
+ result.put("mchId", config.getMchId());
|
|
|
|
|
+ System.out.println("发红包返回" + result);
|
|
|
return result;
|
|
return result;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -429,12 +429,12 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
|
|
|
|
|
TransferBillsRequest request = new TransferBillsRequest();
|
|
TransferBillsRequest request = new TransferBillsRequest();
|
|
|
request.setAppid(config.getAppId());
|
|
request.setAppid(config.getAppId());
|
|
|
- System.out.println("appid:"+config.getAppId());
|
|
|
|
|
|
|
+ System.out.println("appid:" + config.getAppId());
|
|
|
request.setOpenid(param.getOpenId());
|
|
request.setOpenid(param.getOpenId());
|
|
|
|
|
|
|
|
// String code = String.valueOf(IdUtil.getSnowflake(0, 0).nextId());
|
|
// String code = String.valueOf(IdUtil.getSnowflake(0, 0).nextId());
|
|
|
- String code = OrderCodeUtils.getOrderSn();
|
|
|
|
|
- if(StringUtils.isEmpty(code)){
|
|
|
|
|
|
|
+ String code = OrderCodeUtils.getOrderSn();
|
|
|
|
|
+ if (StringUtils.isEmpty(code)) {
|
|
|
return R.error("红包单号生成失败,请重试");
|
|
return R.error("红包单号生成失败,请重试");
|
|
|
}
|
|
}
|
|
|
request.setOutBillNo("fsCourse" + code);
|
|
request.setOutBillNo("fsCourse" + code);
|
|
@@ -481,8 +481,8 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
TransferBatchesRequest request = new TransferBatchesRequest();
|
|
TransferBatchesRequest request = new TransferBatchesRequest();
|
|
|
request.setAppid(config.getAppId());
|
|
request.setAppid(config.getAppId());
|
|
|
// String code = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
// String code = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
|
- String code = OrderCodeUtils.getOrderSn();
|
|
|
|
|
- if(StringUtils.isEmpty(code)){
|
|
|
|
|
|
|
+ String code = OrderCodeUtils.getOrderSn();
|
|
|
|
|
+ if (StringUtils.isEmpty(code)) {
|
|
|
return R.error("红包单号生成失败,请重试");
|
|
return R.error("红包单号生成失败,请重试");
|
|
|
}
|
|
}
|
|
|
request.setOutBatchNo("fsCourse" + code);
|
|
request.setOutBatchNo("fsCourse" + code);
|
|
@@ -499,17 +499,17 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
|
|
|
|
|
String openId;
|
|
String openId;
|
|
|
//临时方法,有code的时候获取一下客户的openId
|
|
//临时方法,有code的时候获取一下客户的openId
|
|
|
- if (StringUtils.isNotEmpty(param.getCode())){
|
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(param.getCode())) {
|
|
|
WxMaService wxService = WxMaConfiguration.getMaService(param.getAppId());
|
|
WxMaService wxService = WxMaConfiguration.getMaService(param.getAppId());
|
|
|
try {
|
|
try {
|
|
|
WxMaJscode2SessionResult session = wxService.getUserService().getSessionInfo(param.getCode());
|
|
WxMaJscode2SessionResult session = wxService.getUserService().getSessionInfo(param.getCode());
|
|
|
openId = session.getOpenid();
|
|
openId = session.getOpenid();
|
|
|
- logger.info("修改或新增openId:{},userId:{},appId:{}",session.getOpenid(),param.getUser().getUserId(),param.getAppId());
|
|
|
|
|
- handleFsUserWx(param.getUser(),param.getAppId(),session);
|
|
|
|
|
- } catch (WxErrorException e){
|
|
|
|
|
|
|
+ logger.info("修改或新增openId:{},userId:{},appId:{}", session.getOpenid(), param.getUser().getUserId(), param.getAppId());
|
|
|
|
|
+ handleFsUserWx(param.getUser(), param.getAppId(), session);
|
|
|
|
|
+ } catch (WxErrorException e) {
|
|
|
return R.error("openId获取失败," + e.getMessage());
|
|
return R.error("openId获取失败," + e.getMessage());
|
|
|
}
|
|
}
|
|
|
- }else {
|
|
|
|
|
|
|
+ } else {
|
|
|
openId = param.getOpenId();
|
|
openId = param.getOpenId();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -552,7 +552,7 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
// }
|
|
// }
|
|
|
boolean updated = fsUserWxService.lambdaUpdate()
|
|
boolean updated = fsUserWxService.lambdaUpdate()
|
|
|
.eq(FsUserWx::getFsUserId, user.getUserId())
|
|
.eq(FsUserWx::getFsUserId, user.getUserId())
|
|
|
- .eq(FsUserWx::getAppId,appId )
|
|
|
|
|
|
|
+ .eq(FsUserWx::getAppId, appId)
|
|
|
.eq(FsUserWx::getOpenId, session.getOpenid())
|
|
.eq(FsUserWx::getOpenId, session.getOpenid())
|
|
|
.set(FsUserWx::getUnionId, session.getUnionid() == null ? "" : session.getUnionid())
|
|
.set(FsUserWx::getUnionId, session.getUnionid() == null ? "" : session.getUnionid())
|
|
|
.set(FsUserWx::getUpdateTime, new Date())
|
|
.set(FsUserWx::getUpdateTime, new Date())
|
|
@@ -579,7 +579,7 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
RedPacketConfig config = new RedPacketConfig();
|
|
RedPacketConfig config = new RedPacketConfig();
|
|
|
// 根据红包模式获取配置
|
|
// 根据红包模式获取配置
|
|
|
|
|
|
|
|
- String json = configService.selectConfigByKey("redPacket.config");
|
|
|
|
|
|
|
+ String json = configService.selectConfigByKey("redPacket.config");
|
|
|
config = JSONUtil.toBean(json, RedPacketConfig.class);
|
|
config = JSONUtil.toBean(json, RedPacketConfig.class);
|
|
|
|
|
|
|
|
param.setSource(2);
|
|
param.setSource(2);
|
|
@@ -645,15 +645,15 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public String transferNotify(String notifyData, HttpServletRequest request) {
|
|
public String transferNotify(String notifyData, HttpServletRequest request) {
|
|
|
- logger.info("zyp \n【收到转账回调】:{}",notifyData);
|
|
|
|
|
|
|
+ logger.info("zyp \n【收到转账回调】:{}", notifyData);
|
|
|
try {
|
|
try {
|
|
|
String json = configService.selectConfigByKey("redPacket.config");
|
|
String json = configService.selectConfigByKey("redPacket.config");
|
|
|
RedPacketConfig config = JSONUtil.toBean(json, RedPacketConfig.class);
|
|
RedPacketConfig config = JSONUtil.toBean(json, RedPacketConfig.class);
|
|
|
//创建微信订单
|
|
//创建微信订单
|
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
|
- BeanUtils.copyProperties(config,payConfig);
|
|
|
|
|
|
|
+ BeanUtils.copyProperties(config, payConfig);
|
|
|
System.out.println(payConfig);
|
|
System.out.println(payConfig);
|
|
|
- logger.info("到零钱回调:{}",payConfig);
|
|
|
|
|
|
|
+ logger.info("到零钱回调:{}", payConfig);
|
|
|
WxPayService wxPayService = new WxPayServiceImpl();
|
|
WxPayService wxPayService = new WxPayServiceImpl();
|
|
|
wxPayService.setConfig(payConfig);
|
|
wxPayService.setConfig(payConfig);
|
|
|
SignatureHeader signatureHeader = new SignatureHeader();
|
|
SignatureHeader signatureHeader = new SignatureHeader();
|
|
@@ -661,17 +661,17 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
signatureHeader.setNonce(request.getHeader("Wechatpay-Nonce"));
|
|
signatureHeader.setNonce(request.getHeader("Wechatpay-Nonce"));
|
|
|
signatureHeader.setSerial(request.getHeader("Wechatpay-Serial"));
|
|
signatureHeader.setSerial(request.getHeader("Wechatpay-Serial"));
|
|
|
signatureHeader.setSignature(request.getHeader("Wechatpay-Signature"));
|
|
signatureHeader.setSignature(request.getHeader("Wechatpay-Signature"));
|
|
|
- WxPayTransferBatchesNotifyV3Result result = wxPayService.parseTransferBatchesNotifyV3Result(notifyData,signatureHeader);
|
|
|
|
|
- logger.info("到零钱回调:{}",result.getResult());
|
|
|
|
|
- if (result.getResult().getBatchStatus().equals("FINISHED") && result.getResult().getFailNum()==0) {
|
|
|
|
|
- R r = redPacketLogService.syncRedPacket(result.getResult().getOutBatchNo(),result.getResult().getBatchId());
|
|
|
|
|
- logger.info("result:{}",r);
|
|
|
|
|
- if (r.get("code").equals(200)){
|
|
|
|
|
|
|
+ WxPayTransferBatchesNotifyV3Result result = wxPayService.parseTransferBatchesNotifyV3Result(notifyData, signatureHeader);
|
|
|
|
|
+ logger.info("到零钱回调:{}", result.getResult());
|
|
|
|
|
+ if (result.getResult().getBatchStatus().equals("FINISHED") && result.getResult().getFailNum() == 0) {
|
|
|
|
|
+ R r = redPacketLogService.syncRedPacket(result.getResult().getOutBatchNo(), result.getResult().getBatchId());
|
|
|
|
|
+ logger.info("result:{}", r);
|
|
|
|
|
+ if (r.get("code").equals(200)) {
|
|
|
return WxPayNotifyResponse.success("处理成功");
|
|
return WxPayNotifyResponse.success("处理成功");
|
|
|
- }else {
|
|
|
|
|
|
|
+ } else {
|
|
|
return WxPayNotifyResponse.fail("");
|
|
return WxPayNotifyResponse.fail("");
|
|
|
}
|
|
}
|
|
|
- }else {
|
|
|
|
|
|
|
+ } else {
|
|
|
return WxPayNotifyResponse.fail("");
|
|
return WxPayNotifyResponse.fail("");
|
|
|
}
|
|
}
|
|
|
} catch (WxPayException e) {
|
|
} catch (WxPayException e) {
|
|
@@ -682,13 +682,13 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public String v3TransferNotify(String notifyData, HttpServletRequest request) {
|
|
public String v3TransferNotify(String notifyData, HttpServletRequest request) {
|
|
|
- logger.info("zyp \n【收到转账回调】:{}",notifyData);
|
|
|
|
|
|
|
+ logger.info("zyp \n【收到转账回调】:{}", notifyData);
|
|
|
try {
|
|
try {
|
|
|
String json = configService.selectConfigByKey("redPacket.config");
|
|
String json = configService.selectConfigByKey("redPacket.config");
|
|
|
RedPacketConfig config = JSONUtil.toBean(json, RedPacketConfig.class);
|
|
RedPacketConfig config = JSONUtil.toBean(json, RedPacketConfig.class);
|
|
|
//创建微信订单
|
|
//创建微信订单
|
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
|
- BeanUtils.copyProperties(config,payConfig);
|
|
|
|
|
|
|
+ BeanUtils.copyProperties(config, payConfig);
|
|
|
WxPayService wxPayService = new WxPayServiceImpl();
|
|
WxPayService wxPayService = new WxPayServiceImpl();
|
|
|
wxPayService.setConfig(payConfig);
|
|
wxPayService.setConfig(payConfig);
|
|
|
SignatureHeader signatureHeader = new SignatureHeader();
|
|
SignatureHeader signatureHeader = new SignatureHeader();
|
|
@@ -696,21 +696,21 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
signatureHeader.setNonce(request.getHeader("Wechatpay-Nonce"));
|
|
signatureHeader.setNonce(request.getHeader("Wechatpay-Nonce"));
|
|
|
signatureHeader.setSerial(request.getHeader("Wechatpay-Serial"));
|
|
signatureHeader.setSerial(request.getHeader("Wechatpay-Serial"));
|
|
|
signatureHeader.setSignature(request.getHeader("Wechatpay-Signature"));
|
|
signatureHeader.setSignature(request.getHeader("Wechatpay-Signature"));
|
|
|
- TransferBillsNotifyResult result = wxPayService.parseTransferBillsNotifyV3Result(notifyData,signatureHeader);
|
|
|
|
|
- logger.info("到零钱回调:{}",result.getResult());
|
|
|
|
|
|
|
+ TransferBillsNotifyResult result = wxPayService.parseTransferBillsNotifyV3Result(notifyData, signatureHeader);
|
|
|
|
|
+ logger.info("到零钱回调:{}", result.getResult());
|
|
|
if (result.getResult().getState().equals("SUCCESS")) {
|
|
if (result.getResult().getState().equals("SUCCESS")) {
|
|
|
- R r = redPacketLogService.syncRedPacket(result.getResult().getOutBillNo(),result.getResult().getTransferBillNo());
|
|
|
|
|
- logger.info("result:{}",r);
|
|
|
|
|
- if (r.get("code").equals(200)){
|
|
|
|
|
|
|
+ R r = redPacketLogService.syncRedPacket(result.getResult().getOutBillNo(), result.getResult().getTransferBillNo());
|
|
|
|
|
+ logger.info("result:{}", r);
|
|
|
|
|
+ if (r.get("code").equals(200)) {
|
|
|
return WxPayNotifyResponse.success("处理成功");
|
|
return WxPayNotifyResponse.success("处理成功");
|
|
|
- }else {
|
|
|
|
|
|
|
+ } else {
|
|
|
return WxPayNotifyResponse.fail("");
|
|
return WxPayNotifyResponse.fail("");
|
|
|
}
|
|
}
|
|
|
- }else {
|
|
|
|
|
|
|
+ } else {
|
|
|
return WxPayNotifyResponse.fail("");
|
|
return WxPayNotifyResponse.fail("");
|
|
|
}
|
|
}
|
|
|
} catch (WxPayException e) {
|
|
} catch (WxPayException e) {
|
|
|
- logger.error("zyp \n【转账回调异常】:{}", e.getReturnMsg(),e);
|
|
|
|
|
|
|
+ logger.error("zyp \n【转账回调异常】:{}", e.getReturnMsg(), e);
|
|
|
return WxPayNotifyResponse.fail(e.getMessage());
|
|
return WxPayNotifyResponse.fail(e.getMessage());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -724,21 +724,21 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
// RedPacketConfig config = JSONUtil.toBean(json, RedPacketConfig.class);
|
|
// RedPacketConfig config = JSONUtil.toBean(json, RedPacketConfig.class);
|
|
|
List<FsCourseRedPacketLog> logs = redPacketLogMapper.selectFailAll();
|
|
List<FsCourseRedPacketLog> logs = redPacketLogMapper.selectFailAll();
|
|
|
String appId = "wx414427b10866c04e";
|
|
String appId = "wx414427b10866c04e";
|
|
|
- for (FsCourseRedPacketLog log : logs){
|
|
|
|
|
|
|
+ for (FsCourseRedPacketLog log : logs) {
|
|
|
FsUserScrm user = userService.selectFsUserById(log.getUserId());
|
|
FsUserScrm user = userService.selectFsUserById(log.getUserId());
|
|
|
WxSendRedPacketParam param = new WxSendRedPacketParam();
|
|
WxSendRedPacketParam param = new WxSendRedPacketParam();
|
|
|
param.setAppId(appId);
|
|
param.setAppId(appId);
|
|
|
- if (user==null || user.getMaOpenId()==null){
|
|
|
|
|
|
|
+ if (user == null || user.getMaOpenId() == null) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
param.setOpenId(user.getMaOpenId());
|
|
param.setOpenId(user.getMaOpenId());
|
|
|
param.setAmount(log.getAmount());
|
|
param.setAmount(log.getAmount());
|
|
|
R r = this.sendRedPacketTest(param);
|
|
R r = this.sendRedPacketTest(param);
|
|
|
- if (r.get("code").equals(200)){
|
|
|
|
|
|
|
+ if (r.get("code").equals(200)) {
|
|
|
log.setOutBatchNo(r.get("orderCode").toString());
|
|
log.setOutBatchNo(r.get("orderCode").toString());
|
|
|
log.setBatchId(r.get("batchId").toString());
|
|
log.setBatchId(r.get("batchId").toString());
|
|
|
redPacketLogMapper.updateFsCourseRedPacketLog(log);
|
|
redPacketLogMapper.updateFsCourseRedPacketLog(log);
|
|
|
- logger.info("更新完成:{}",log.getLogId());
|
|
|
|
|
|
|
+ logger.info("更新完成:{}", log.getLogId());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|
|
@@ -788,24 +788,24 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
return R.ok();
|
|
return R.ok();
|
|
|
- }
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- public R getWxaCodeByPayment(FsStorePaymentGetWxaCodeParam param) {
|
|
|
|
|
|
|
+ public R getWxaCodeByPayment(FsStorePaymentGetWxaCodeParam param) {
|
|
|
final WxMaService wxMaService = WxMaConfiguration.getMaService(param.getAppId());
|
|
final WxMaService wxMaService = WxMaConfiguration.getMaService(param.getAppId());
|
|
|
String scene;
|
|
String scene;
|
|
|
//判断销售id
|
|
//判断销售id
|
|
|
- if (param.getCompanyUserId() == null){
|
|
|
|
|
- scene = "companyId="+ param.getCompanyId();
|
|
|
|
|
- }else {
|
|
|
|
|
- scene = "companyId="+ param.getCompanyId()+"&"+"companyUserId="+ param.getCompanyUserId();
|
|
|
|
|
|
|
+ if (param.getCompanyUserId() == null) {
|
|
|
|
|
+ scene = "companyId=" + param.getCompanyId();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ scene = "companyId=" + param.getCompanyId() + "&" + "companyUserId=" + param.getCompanyUserId();
|
|
|
}
|
|
}
|
|
|
byte[] file;
|
|
byte[] file;
|
|
|
try {
|
|
try {
|
|
|
|
|
|
|
|
file = wxMaService.getQrcodeService().createWxaCodeBytes(
|
|
file = wxMaService.getQrcodeService().createWxaCodeBytes(
|
|
|
- "pages_user/user/pay?companyId="+param.getCompanyId(),
|
|
|
|
|
|
|
+ "pages_user/user/pay?companyId=" + param.getCompanyId(),
|
|
|
"release",
|
|
"release",
|
|
|
430,
|
|
430,
|
|
|
true,
|
|
true,
|
|
@@ -827,14 +827,14 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
String url;
|
|
String url;
|
|
|
try {
|
|
try {
|
|
|
url = storage.uploadSuffix(file, suffix);
|
|
url = storage.uploadSuffix(file, suffix);
|
|
|
- } catch (Exception e) {
|
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
// 记录错误日志
|
|
// 记录错误日志
|
|
|
- logger.error("生成图片失败:{}",e.getMessage(),e);
|
|
|
|
|
|
|
+ logger.error("生成图片失败:{}", e.getMessage(), e);
|
|
|
return R.error("生成图片失败");
|
|
return R.error("生成图片失败");
|
|
|
}
|
|
}
|
|
|
- redisCache.setCacheObject("company-wxa-code:"+param.getCompanyId()+":"+param.getAppId(),url);
|
|
|
|
|
|
|
+ redisCache.setCacheObject("company-wxa-code:" + param.getCompanyId() + ":" + param.getAppId(), url);
|
|
|
// 返回成功信息
|
|
// 返回成功信息
|
|
|
- return R.ok().put("url",url);
|
|
|
|
|
|
|
+ return R.ok().put("url", url);
|
|
|
|
|
|
|
|
} catch (WxErrorException e) {
|
|
} catch (WxErrorException e) {
|
|
|
logger.error(e.getMessage(), e);
|
|
logger.error(e.getMessage(), e);
|
|
@@ -849,29 +849,29 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
@Override
|
|
@Override
|
|
|
public R paymentByWxaCode(FsStorePaymentPayParam param) {
|
|
public R paymentByWxaCode(FsStorePaymentPayParam param) {
|
|
|
FsUser user = fsUserService.selectFsUserById(param.getUserId());
|
|
FsUser user = fsUserService.selectFsUserById(param.getUserId());
|
|
|
- if (user==null){
|
|
|
|
|
|
|
+ if (user == null) {
|
|
|
return R.error("用户不存在!");
|
|
return R.error("用户不存在!");
|
|
|
}
|
|
}
|
|
|
Company company = companyService.selectCompanyById(param.getCompanyId());
|
|
Company company = companyService.selectCompanyById(param.getCompanyId());
|
|
|
- if (company==null || company.getStatus()==0){
|
|
|
|
|
|
|
+ if (company == null || company.getStatus() == 0) {
|
|
|
return R.error("服务商不存在,或已被停用!");
|
|
return R.error("服务商不存在,或已被停用!");
|
|
|
}
|
|
}
|
|
|
- if(param.getPayMoney().compareTo(new BigDecimal(0.0))<1){
|
|
|
|
|
|
|
+ if (param.getPayMoney().compareTo(new BigDecimal(0.0)) < 1) {
|
|
|
return R.error("支付金额必须大于0");
|
|
return R.error("支付金额必须大于0");
|
|
|
}
|
|
}
|
|
|
- if (param.getCompanyUserId()!=null){
|
|
|
|
|
|
|
+ if (param.getCompanyUserId() != null) {
|
|
|
CompanyUser companyUser = companyUserService.selectCompanyUserById(param.getCompanyUserId());
|
|
CompanyUser companyUser = companyUserService.selectCompanyUserById(param.getCompanyUserId());
|
|
|
- if(companyUser == null || companyUser.getStatus().equals("1")){
|
|
|
|
|
|
|
+ if (companyUser == null || companyUser.getStatus().equals("1")) {
|
|
|
return R.error("注册失败客服已停用,或不存在!");
|
|
return R.error("注册失败客服已停用,或不存在!");
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//生成支付流水
|
|
//生成支付流水
|
|
|
String orderSn = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
String orderSn = IdUtil.getSnowflake(0, 0).nextIdStr();
|
|
|
- FsStorePaymentScrm storePayment=new FsStorePaymentScrm();
|
|
|
|
|
|
|
+ FsStorePaymentScrm storePayment = new FsStorePaymentScrm();
|
|
|
storePayment.setCompanyId(param.getCompanyId());
|
|
storePayment.setCompanyId(param.getCompanyId());
|
|
|
//判断销售是否存在
|
|
//判断销售是否存在
|
|
|
- if (param.getCompanyUserId()!=null){
|
|
|
|
|
|
|
+ if (param.getCompanyUserId() != null) {
|
|
|
storePayment.setCompanyUserId(param.getCompanyUserId());
|
|
storePayment.setCompanyUserId(param.getCompanyUserId());
|
|
|
}
|
|
}
|
|
|
storePayment.setStatus(0);
|
|
storePayment.setStatus(0);
|
|
@@ -891,30 +891,30 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
HuiFuCreateOrder o = new HuiFuCreateOrder();
|
|
HuiFuCreateOrder o = new HuiFuCreateOrder();
|
|
|
o.setTradeType("T_MINIAPP");
|
|
o.setTradeType("T_MINIAPP");
|
|
|
o.setOpenid(user.getMaOpenId());
|
|
o.setOpenid(user.getMaOpenId());
|
|
|
- o.setReqSeqId("payment-"+storePayment.getPayCode());
|
|
|
|
|
|
|
+ o.setReqSeqId("payment-" + storePayment.getPayCode());
|
|
|
o.setTransAmt(storePayment.getPayMoney().toString());
|
|
o.setTransAmt(storePayment.getPayMoney().toString());
|
|
|
o.setGoodsDesc("商城订单支付");
|
|
o.setGoodsDesc("商城订单支付");
|
|
|
o.setAppId(param.getAppId());
|
|
o.setAppId(param.getAppId());
|
|
|
//公司分账
|
|
//公司分账
|
|
|
try {
|
|
try {
|
|
|
- HuiFuUtils.doDiv(o,company.getCompanyId());
|
|
|
|
|
|
|
+ HuiFuUtils.doDiv(o, company.getCompanyId());
|
|
|
//存储分账明细
|
|
//存储分账明细
|
|
|
HuiFuUtils.saveDivItem(o, storePayment.getPayCode(), storePayment.getPayCode());
|
|
HuiFuUtils.saveDivItem(o, storePayment.getPayCode(), storePayment.getPayCode());
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
|
logger.error("-------------微信收款分账出错:{}", e.getMessage());
|
|
logger.error("-------------微信收款分账出错:{}", e.getMessage());
|
|
|
}
|
|
}
|
|
|
HuifuCreateOrderResult result = huiFuService.createOrder(o);
|
|
HuifuCreateOrderResult result = huiFuService.createOrder(o);
|
|
|
- if(result.getResp_code()!=null&&(result.getResp_code().equals("00000000")||result.getResp_code().equals("00000100"))){
|
|
|
|
|
- FsStorePaymentScrm mt=new FsStorePaymentScrm();
|
|
|
|
|
|
|
+ if (result.getResp_code() != null && (result.getResp_code().equals("00000000") || result.getResp_code().equals("00000100"))) {
|
|
|
|
|
+ FsStorePaymentScrm mt = new FsStorePaymentScrm();
|
|
|
mt.setPaymentId(storePayment.getPaymentId());
|
|
mt.setPaymentId(storePayment.getPaymentId());
|
|
|
mt.setTradeNo(result.getHf_seq_id());
|
|
mt.setTradeNo(result.getHf_seq_id());
|
|
|
fsStorePaymentMapper.updateFsStorePayment(mt);
|
|
fsStorePaymentMapper.updateFsStorePayment(mt);
|
|
|
- Map<String, Object> resultMap = JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {});
|
|
|
|
|
|
|
+ Map<String, Object> resultMap = JSON.parseObject(result.getPay_info(), new TypeReference<Map<String, Object>>() {
|
|
|
|
|
+ });
|
|
|
String s = (String) resultMap.get("package");
|
|
String s = (String) resultMap.get("package");
|
|
|
- resultMap.put("packageValue",s);
|
|
|
|
|
- return R.ok().put("result",resultMap);
|
|
|
|
|
- }
|
|
|
|
|
- else{
|
|
|
|
|
|
|
+ resultMap.put("packageValue", s);
|
|
|
|
|
+ return R.ok().put("result", resultMap);
|
|
|
|
|
+ } else {
|
|
|
return R.error(result.getResp_desc());
|
|
return R.error(result.getResp_desc());
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -948,4 +948,85 @@ public class FsStorePaymentScrmServiceImpl implements IFsStorePaymentScrmService
|
|
|
}
|
|
}
|
|
|
return "success";
|
|
return "success";
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public R oneClickShipping() {
|
|
|
|
|
+ try {
|
|
|
|
|
+ StringBuilder builder = new StringBuilder();
|
|
|
|
|
+ //获取商城配置
|
|
|
|
|
+ String json = configService.selectConfigByKey("store.config");
|
|
|
|
|
+ StoreConfig config = JSONUtil.toBean(json, StoreConfig.class);
|
|
|
|
|
+ //验证是否开启微信发货
|
|
|
|
|
+ if (config.getIsWeChatShipping() != null && config.getIsWeChatShipping()) {
|
|
|
|
|
+ //获取支付信息
|
|
|
|
|
+ List<FsStorePaymentUsetVo> paymentList = fsStorePaymentMapper.getPaymentUsetInfoList();
|
|
|
|
|
+ if (paymentList.isEmpty()) {
|
|
|
|
|
+ return R.ok("操作成功,暂无同步订单信息!");
|
|
|
|
|
+ }
|
|
|
|
|
+ String uploadTime = ZonedDateTime.now(ZoneId.of("Asia/Shanghai"))
|
|
|
|
|
+ .format(DateTimeFormatter.ISO_OFFSET_DATE_TIME);
|
|
|
|
|
+ Map<String, List<FsStorePaymentUsetVo>> paymentUsetVoMap = paymentList.stream().collect(Collectors.groupingBy(FsStorePaymentUsetVo::getAppId));
|
|
|
|
|
+ for (Map.Entry<String, List<FsStorePaymentUsetVo>> entry : paymentUsetVoMap.entrySet()) {
|
|
|
|
|
+ List<String> successList = new ArrayList<>();
|
|
|
|
|
+ String appId = entry.getKey();
|
|
|
|
|
+ List<FsStorePaymentUsetVo> userPayments = entry.getValue();
|
|
|
|
|
+ final WxMaService wxService = WxMaConfiguration.getMaService(appId);
|
|
|
|
|
+ if (!userPayments.isEmpty()) {
|
|
|
|
|
+ for (FsStorePaymentUsetVo v : userPayments) {
|
|
|
|
|
+ // 上传物流信息到微信
|
|
|
|
|
+ if (uploadShippingInfoToWechat(wxService, v, uploadTime)) {
|
|
|
|
|
+ successList.add(v.getBankTransactionId());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //批量更新数据
|
|
|
|
|
+ if (!successList.isEmpty()) {
|
|
|
|
|
+ fsStorePaymentMapper.batchUpadte(successList);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ return R.ok(builder.toString().equals("") ? "操作成功!" : builder.toString());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("导入发货单快递信息失败", e);
|
|
|
|
|
+ return R.error("导入失败:" + e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private boolean uploadShippingInfoToWechat(WxMaService wxService,
|
|
|
|
|
+ FsStorePaymentUsetVo dto,
|
|
|
|
|
+ String uploadTime) {
|
|
|
|
|
+ try {
|
|
|
|
|
+ WxMaOrderShippingInfoUploadRequest request = new WxMaOrderShippingInfoUploadRequest();
|
|
|
|
|
+ OrderKeyBean orderKeyBean = new OrderKeyBean();
|
|
|
|
|
+ orderKeyBean.setOrderNumberType(2);
|
|
|
|
|
+ orderKeyBean.setTransactionId(dto.getBankTransactionId());//交易订单号ID
|
|
|
|
|
+ request.setOrderKey(orderKeyBean);
|
|
|
|
|
+ request.setDeliveryMode(1);
|
|
|
|
|
+ request.setLogisticsType(4);
|
|
|
|
|
+ List<ShippingListBean> shippingList = new ArrayList<>();
|
|
|
|
|
+ ShippingListBean shippingListBean = new ShippingListBean();
|
|
|
|
|
+ //默认物品信息
|
|
|
|
|
+ shippingListBean.setTrackingNo(String.valueOf(new TwelveDigitSnowflake(1).nextId()));
|
|
|
|
|
+ shippingListBean.setExpressCompany("FS");
|
|
|
|
|
+ shippingListBean.setItemDesc("默认商品");
|
|
|
|
|
+ ContactBean contactBean = new ContactBean();
|
|
|
|
|
+ contactBean.setReceiverContact(dto.getPhone());
|
|
|
|
|
+ shippingListBean.setContact(contactBean);
|
|
|
|
|
+
|
|
|
|
|
+ shippingList.add(shippingListBean);
|
|
|
|
|
+ request.setShippingList(shippingList);
|
|
|
|
|
+ request.setUploadTime(uploadTime);
|
|
|
|
|
+ // 设置支付者信息
|
|
|
|
|
+ PayerBean payerBean = new PayerBean();
|
|
|
|
|
+ payerBean.setOpenid(dto.getOpenId());
|
|
|
|
|
+ request.setPayer(payerBean);
|
|
|
|
|
+ // 上传物流信息
|
|
|
|
|
+ return wxService.getWxMaOrderShippingService().upload(request).getErrCode() == 0;
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("上传物流信息到微信失败,订单号: {}", dto.getBankTransactionId(), e);
|
|
|
|
|
+ return false;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|