|
|
@@ -6,18 +6,22 @@ import com.github.pagehelper.PageInfo; |
|
|
|
import com.iformall.common.ErrorCode; |
|
|
|
import com.iformall.common.IdWorker; |
|
|
|
import com.iformall.domain.entity.PayAdapterResult; |
|
|
|
import com.iformall.domain.po.SysConfig; |
|
|
|
import com.iformall.domain.po.WxAppinfo; |
|
|
|
import com.iformall.domain.po.WxPayOrder; |
|
|
|
import com.iformall.domain.po.WxPayAccount; |
|
|
|
import com.iformall.domain.po.base.TenantEntity; |
|
|
|
import com.iformall.exception.MallinkException; |
|
|
|
import com.iformall.mapper.WxAppinfoMapper; |
|
|
|
import com.iformall.mapper.WxCUserMapper; |
|
|
|
import com.iformall.mapper.WxPayOrderMapper; |
|
|
|
import com.iformall.mapper.WxPayAccountMapper; |
|
|
|
import com.iformall.service.SysConfigService; |
|
|
|
import com.iformall.service.WxAppinfoService; |
|
|
|
import com.iformall.service.WxPayAccountService; |
|
|
|
import com.iformall.utils.DateUtils; |
|
|
|
import com.iformall.utils.RedisLock; |
|
|
|
import com.iformall.utils.SysConfigConstant; |
|
|
|
import com.iformall.utils.XmlUtil; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.Map; |
|
|
@@ -29,6 +33,8 @@ import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.context.annotation.Lazy; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Propagation; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class WxPayServiceImpl implements WxPayService { |
|
|
@@ -58,6 +64,13 @@ public class WxPayServiceImpl implements WxPayService { |
|
|
|
@Autowired |
|
|
|
WxPayAccountService wxPayAccountService; |
|
|
|
|
|
|
|
@Lazy |
|
|
|
@Autowired |
|
|
|
SysConfigService sysConfigService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
WxCUserMapper wxCUserMapper; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageInfo<WxPayOrder> listPayOrderAsPage(WxPayOrder record, Integer pageIndex, Integer pageSize) { |
|
|
|
return PageHelper.startPage(pageIndex, pageSize).doSelectPageInfo(() -> wxPayOrderMapper.findList(record)); |
|
|
@@ -132,6 +145,7 @@ public class WxPayServiceImpl implements WxPayService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(propagation = Propagation.REQUIRED, readOnly = false, rollbackFor = {Exception.class}) |
|
|
|
@Override |
|
|
|
public void handlePaidSuccess(String tenantId,Long orderId,Long cUserId,Integer fee,Date paidTime,String transcationId, |
|
|
|
String userPhone) throws Exception{ |
|
|
@@ -151,17 +165,23 @@ public class WxPayServiceImpl implements WxPayService { |
|
|
|
Long id = idworker.nextId(); |
|
|
|
payOrder.setId(id); |
|
|
|
payOrder.setTenantId(tenantId); |
|
|
|
payOrder.setCreateTime(new Date()); |
|
|
|
payOrder.setUpdateTime(new Date()); |
|
|
|
payOrder.setcUserId(cUserId); |
|
|
|
payOrder.setPayAmount(fee); |
|
|
|
payOrder.setPayTime(paidTime); |
|
|
|
payOrder.setTransactionId(transcationId); |
|
|
|
payOrder.setcUserPhone(userPhone); |
|
|
|
SysConfig config = sysConfigService.getByKey(SysConfigConstant.expired_days, payOrder); |
|
|
|
Date curr = new Date(); |
|
|
|
payOrder.setCreateTime(curr); |
|
|
|
payOrder.setUpdateTime(curr); |
|
|
|
payOrder.setValidStartTime(curr); |
|
|
|
Date endtime = DateUtils.getTimeAfterDays(Integer.parseInt(config.getConfigItemValue()), curr); |
|
|
|
payOrder.setValidEndTime(endtime); |
|
|
|
wxPayOrderMapper.insert(payOrder); |
|
|
|
wxCUserMapper.updateValidTime(cUserId, tenantId, curr, endtime); |
|
|
|
}catch(Exception e) { |
|
|
|
logger.error("handlePaidSuccess fail.",e); |
|
|
|
throw new MallinkException(ErrorCode.SERVER_ERROR.getCode(),"支付失败"+orderId); |
|
|
|
throw new MallinkException(ErrorCode.SERVER_ERROR.getCode(),"支付更新失败"+orderId); |
|
|
|
}finally { |
|
|
|
redisLock.unlock("carPayOrderLock_"+orderId, timeStr); |
|
|
|
} |
|
|
|