|
@@ -9,7 +9,10 @@ import com.github.microservice.models.type.PaymentType;
|
|
|
import com.github.microservice.net.ResultContent;
|
|
import com.github.microservice.net.ResultContent;
|
|
|
import com.github.microservice.stream.PaymentStreamType;
|
|
import com.github.microservice.stream.PaymentStreamType;
|
|
|
import com.github.microservice.stream.model.OrderStateModel;
|
|
import com.github.microservice.stream.model.OrderStateModel;
|
|
|
|
|
+import com.github.microservice.types.OrderState;
|
|
|
import com.github.microservice.types.RefundStatus;
|
|
import com.github.microservice.types.RefundStatus;
|
|
|
|
|
+import com.zhongshu.card.client.model.org.OrgUserDetailParam;
|
|
|
|
|
+import com.zhongshu.card.client.model.org.OrganizationUserModel;
|
|
|
import com.zhongshu.card.client.model.org.UserCountModel;
|
|
import com.zhongshu.card.client.model.org.UserCountModel;
|
|
|
import com.zhongshu.card.client.service.feign.OrganizationFeignService;
|
|
import com.zhongshu.card.client.service.feign.OrganizationFeignService;
|
|
|
import com.zhongshu.card.client.service.feign.UserFeignService;
|
|
import com.zhongshu.card.client.service.feign.UserFeignService;
|
|
@@ -28,8 +31,10 @@ import com.github.microservice.types.unionFrictionlessPayType.UnionUserOpenType;
|
|
|
import com.zhongshu.payment.client.payModel.unionFrictionlessPay.paymentModel.SignInParam;
|
|
import com.zhongshu.payment.client.payModel.unionFrictionlessPay.paymentModel.SignInParam;
|
|
|
import com.zhongshu.payment.client.payModel.unionFrictionlessPay.paymentModel.UserRescissionParam;
|
|
import com.zhongshu.payment.client.payModel.unionFrictionlessPay.paymentModel.UserRescissionParam;
|
|
|
import com.zhongshu.payment.client.payModel.unionFrictionlessPay.paymentModel.UserSignQueryParam;
|
|
import com.zhongshu.payment.client.payModel.unionFrictionlessPay.paymentModel.UserSignQueryParam;
|
|
|
|
|
+import com.zhongshu.payment.client.types.TradeType;
|
|
|
import com.zhongshu.payment.server.core.dao.RechargeRecordDao;
|
|
import com.zhongshu.payment.server.core.dao.RechargeRecordDao;
|
|
|
import com.zhongshu.payment.server.core.dao.unionFrictionlessPay.UnionUserOpenInfoDao;
|
|
import com.zhongshu.payment.server.core.dao.unionFrictionlessPay.UnionUserOpenInfoDao;
|
|
|
|
|
+import com.zhongshu.payment.server.core.dataConfig.TimeConfig;
|
|
|
import com.zhongshu.payment.server.core.domain.unionFrictionlessPay.UnionUserOpenInfo;
|
|
import com.zhongshu.payment.server.core.domain.unionFrictionlessPay.UnionUserOpenInfo;
|
|
|
import com.zhongshu.payment.server.core.domain.wallet.RechargeRecord;
|
|
import com.zhongshu.payment.server.core.domain.wallet.RechargeRecord;
|
|
|
import com.zhongshu.payment.server.core.service.org.CollectionIdService;
|
|
import com.zhongshu.payment.server.core.service.org.CollectionIdService;
|
|
@@ -47,6 +52,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
|
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -240,6 +246,57 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
|
|
|
*/
|
|
*/
|
|
|
public ResultContent createAndPayOrder(CreateOrderParam param) {
|
|
public ResultContent createAndPayOrder(CreateOrderParam param) {
|
|
|
// 查询是否签约
|
|
// 查询是否签约
|
|
|
|
|
+ String userId = param.getUserId();
|
|
|
|
|
+ String shopId = param.getShopId();
|
|
|
|
|
+ // 创建订单
|
|
|
|
|
+ String outTradeNo = param.getOutTradeNo();
|
|
|
|
|
+ BigDecimal total = param.getTotal();
|
|
|
|
|
+
|
|
|
|
|
+ RechargeRecord rechargeRecord = rechargeRecordDao.findByOutTradeNo(outTradeNo);
|
|
|
|
|
+ if (rechargeRecord == null) {
|
|
|
|
|
+ // 创建充值订单
|
|
|
|
|
+ rechargeRecord = new RechargeRecord();
|
|
|
|
|
+ // 所属项目oid
|
|
|
|
|
+ rechargeRecord.setOid(param.getProjectOid());
|
|
|
|
|
+ // 所属学校oid
|
|
|
|
|
+ rechargeRecord.setSchoolId(param.getSchoolId());
|
|
|
|
|
+ // 所属商户oid
|
|
|
|
|
+ rechargeRecord.setShopId(shopId);
|
|
|
|
|
+ // 用户userId
|
|
|
|
|
+ rechargeRecord.setUserId(userId);
|
|
|
|
|
+ // 消费方式
|
|
|
|
|
+ rechargeRecord.setPaymentType(param.getPaymentType());
|
|
|
|
|
+ // 消费
|
|
|
|
|
+ rechargeRecord.setTradeType(TradeType.Pay);
|
|
|
|
|
+ // 订单号(唯一)
|
|
|
|
|
+ rechargeRecord.setOutTradeNo(outTradeNo);
|
|
|
|
|
+ // 未支付状态 待付款
|
|
|
|
|
+ rechargeRecord.setRechargeState(OrderState.WAIT_PAYMENT);
|
|
|
|
|
+ rechargeRecord.setDescription(param.getDescription());
|
|
|
|
|
+ // 金额
|
|
|
|
|
+ rechargeRecord.setTotal(total);
|
|
|
|
|
+ // 是否提交到支付渠道
|
|
|
|
|
+ rechargeRecord.setCommit(true);
|
|
|
|
|
+
|
|
|
|
|
+ // 时间信息
|
|
|
|
|
+ long createTIme = System.currentTimeMillis();
|
|
|
|
|
+ rechargeRecord.setCreateTime(createTIme);
|
|
|
|
|
+ rechargeRecord.setTimes();
|
|
|
|
|
+ // 订单过期时间
|
|
|
|
|
+ rechargeRecord.setExpireTime(createTIme + TimeConfig.rechargeExpireTime);
|
|
|
|
|
+
|
|
|
|
|
+ // 查询用户在学校的信息
|
|
|
|
|
+ OrgUserDetailParam orgUserDetailParam = new OrgUserDetailParam();
|
|
|
|
|
+ orgUserDetailParam.setOid(param.getSchoolId());
|
|
|
|
|
+ orgUserDetailParam.setUserId(userId);
|
|
|
|
|
+ ResultContent<OrganizationUserModel> orgUserDetail = organizationFeignService.getOrgUserDetail(orgUserDetailParam);
|
|
|
|
|
+ if (orgUserDetail.isFailed()) {
|
|
|
|
|
+ return ResultContent.buildFail("获取用户信息失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ rechargeRecord.setUserInfo(orgUserDetail.getContent());
|
|
|
|
|
+ rechargeRecord.setAttach(param.getAttach());
|
|
|
|
|
+ rechargeRecordDao.save(rechargeRecord);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
SenselessPayParam senselessPayParam = new SenselessPayParam();
|
|
SenselessPayParam senselessPayParam = new SenselessPayParam();
|
|
|
senselessPayParam.setRequestTimestamp(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
|
|
senselessPayParam.setRequestTimestamp(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
|
|
@@ -250,6 +307,7 @@ public class UnionFrictionlessPayMainService extends SuperPayService {
|
|
|
return ResultContent.buildFail(requestAPI.getMsg());
|
|
return ResultContent.buildFail(requestAPI.getMsg());
|
|
|
}
|
|
}
|
|
|
SenselessPayResponse response = (SenselessPayResponse) requestAPI;
|
|
SenselessPayResponse response = (SenselessPayResponse) requestAPI;
|
|
|
|
|
+ log.info("state: {}", response.isSuccess());
|
|
|
|
|
|
|
|
return ResultContent.buildSuccess();
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
}
|