Authored by Lixiaodi

Merge branch 'dev_order' of http://git.yoho.cn/ufo/yohoufo-fore into dev_order

... ... @@ -37,4 +37,7 @@ public class StoredSeller {
private long updateTime;
//是否跳过了芝麻认证,1: 跳过 ,default 0
private Integer breakZhiMaCert;
}
... ...
... ... @@ -21,7 +21,7 @@ public interface IZhiMaCertDao {
ZhiMaCert selectValidByCertNo(String certNo);
//根据业务编号查询
//ZhiMaCert selectByBizNo(String bizNo);
ZhiMaCert selectByBizNo(@Param("bizNo")String bizNo);
... ...
... ... @@ -13,10 +13,11 @@
<result column="quit_time" property="quitTime" jdbcType="INTEGER" />
<result column="create_time" property="createTime" jdbcType="INTEGER" />
<result column="update_time" property="updateTime" jdbcType="INTEGER" />
<result column="break_zhi_ma_cert" property="breakZhiMaCert" jdbcType="TINYINT" />
</resultMap>
<sql id="Base_Column_List" >
id, uid, valid_status,cert_no,cert_name,operator_uid,operator_name,enter_time,quit_time ,create_time, update_time
id, uid, valid_status,cert_no,cert_name,operator_uid,operator_name,enter_time,quit_time ,create_time, update_time,break_zhi_ma_cert
</sql>
<select id="selectValidByUid" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
... ... @@ -28,16 +29,16 @@
</select>
<insert id="insert" parameterType="com.yohoufo.dal.order.model.StoredSeller" >
insert into stored_seller (uid, valid_status,cert_no,cert_name,operator_uid,operator_name,enter_time,quit_time, create_time, update_time)
insert into stored_seller (uid, valid_status,cert_no,cert_name,operator_uid,operator_name,enter_time,quit_time, create_time, update_time,break_zhi_ma_cert)
values (#{uid},#{validStatus},
#{certNo},#{certName},#{operatorUid},#{operatorName},
#{enterTime},#{quitTime},
#{createTime},#{updateTime})
#{createTime},#{updateTime},#{breakZhiMaCert})
</insert>
<update id="updateStatusByUid">
update stored_seller
set valid_status = #{validStatus},update_time = #{updateTime}
set valid_status = #{validStatus},update_time = #{updateTime},quit_time = #{updateTime}
where uid = #{uid} and valid_status = #{expectStatus}
</update>
... ...
... ... @@ -56,7 +56,7 @@
from storage
</select>
<select id="selectByGoodsId" resultMap="BaseResultMap">
select id, product_id, goods_id, size_id, storage_num
select id, product_id, goods_id, size_id, storage_num, suggest_low_price, suggest_high_price
from storage where goods_id=#{goodsId,jdbcType=INTEGER}
</select>
<update id="addStorageNum">
... ...
... ... @@ -157,7 +157,7 @@ public abstract class AbsOrderDetailService extends AbsOrderViewService implemen
OrderDetailInfo.PriceInfo priceInfo = OrderDetailInfo.PriceInfo.builder()
.goodPrice(buyerOrderGoods.getGoodsPrice() == null ? "0" : buyerOrderGoods.getGoodsPrice().toPlainString() )
.feePrice(buyerOrder.getShipFee() == null ? "0" : buyerOrder.getShipFee().toPlainString())
.couponCutPrice(buyerOrderGoods.getCouponCutAmount() == null ? "0.00":buyerOrderGoods.getCouponCutAmount().toPlainString())
.couponCutPrice(buyerOrderGoods.getCouponCutAmount() == null ? "0.00": "-" + buyerOrderGoods.getCouponCutAmount().toPlainString())
.realPayPrice(buyerOrder.getAmount() == null ? "0" : buyerOrder.getAmount().toPlainString())
.build();
orderDetailInfo.setPriceInfo(priceInfo);
... ...
... ... @@ -145,6 +145,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
}catch (Exception ex){
if (ex instanceof UfoServiceException && ((UfoServiceException) ex).getCode() == SellerOrderPrepareProcessor.TIPS_ERROR_CODE){
tips = ((UfoServiceException) ex).getMessage();
}else{
throw ex;
}
}
... ... @@ -177,6 +179,8 @@ public class SellerOrderService implements IOrderListService, IOrderDetailServi
}catch (Exception ex){
if (ex instanceof UfoServiceException && ((UfoServiceException) ex).getCode() == SellerOrderPrepareProcessor.TIPS_ERROR_CODE){
tips = ((UfoServiceException) ex).getMessage();
}else{
throw ex;
}
}
spc.setTips(tips);
... ...
... ... @@ -13,6 +13,7 @@ import com.yohoufo.order.service.proxy.InBoxFacade;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.time.LocalDateTime;
... ... @@ -36,6 +37,10 @@ public class StoreSellerServiceImpl implements IStoredSellerService {
@Autowired
StoredSellerCacheService storedSellerCacheService;
@Value("${zhimacert.switch:true}")
private boolean zhiMaCertSwitch;
/**
* 是否入驻商户
* @param uid
... ... @@ -55,8 +60,13 @@ public class StoreSellerServiceImpl implements IStoredSellerService {
public Map<String,Boolean> entryStatus(Integer uid){
logger.info("StoredSellerServiceImpl entryStatus uid is {} ",uid);
Boolean isZhiMaCert=false;
ZhiMaCert zhiMaCert = getZhiMaCertInfo(uid);
if(null != zhiMaCert){
if(zhiMaCertSwitch){
ZhiMaCert zhiMaCert = getZhiMaCertInfo(uid);
if(null != zhiMaCert){
isZhiMaCert = true;
}
}else{
isZhiMaCert = true;
}
... ... @@ -99,6 +109,14 @@ public class StoreSellerServiceImpl implements IStoredSellerService {
logger.info("StoredSellerServiceImpl addUserAsStoredSeller enter uid is {} ",uid);
//检查是否已经实名认证
ZhiMaCert zhiMaCert = getZhiMaCertInfo(uid);
int breakZhiMaCert=0;
//芝麻认证没开启,并且没有认证
if(!zhiMaCertSwitch&&zhiMaCert==null){
zhiMaCert = new ZhiMaCert();
breakZhiMaCert=1;
}
if(null == zhiMaCert){
logger.error("StoredSellerServiceImpl get zhi ma cert info is null , uid is {} ",uid);
throw new ServiceException(400,"商户没有实名认证通过,不允许入驻");
... ... @@ -114,6 +132,7 @@ public class StoreSellerServiceImpl implements IStoredSellerService {
storedSeller.setCertName(zhiMaCert.getCertName());
storedSeller.setCreateTime(ts);
storedSeller.setUpdateTime(ts);
storedSeller.setBreakZhiMaCert(breakZhiMaCert);
logger.info("StoredSellerServiceImpl addUserAsStoredSeller insert uid is {} , storedSeller {} ",uid,storedSeller);
int num=storedSellerMapper.insert(storedSeller);
if(num<0){
... ...
... ... @@ -206,10 +206,10 @@ public class StoredSellerDepositServiceImpl implements IStoredSellerDepositServi
throw new UfoServiceException(400,"商户存在出售中商品,不允许退驻!");
}
String aliPayAccount = getAlipayAccount(uid);
String aliPayAccount = getAlipayIDOrAccount(uid);
if(StringUtils.isBlank(aliPayAccount)){
logger.error("quitStoredSeller not allowed cause of aliPayAccount is blank ,uid {}" ,uid);
throw new UfoServiceException(400,"商户存在出售中商品,不允许退驻!");
throw new UfoServiceException(400,"支付宝账号未绑定,不允许退驻!");
}
... ... @@ -272,12 +272,18 @@ public class StoredSellerDepositServiceImpl implements IStoredSellerDepositServi
@SuppressWarnings("unchecked")
private String getAlipayAccount(int targetUid) {
private String getAlipayIDOrAccount(int targetUid) {
ApiResponse<AuthorizeResultRespVO> resp = ufoServiceCaller.call("ufo.user.aliPayAccountQuery", ApiResponse.class, targetUid);
if (resp != null) {
AuthorizeResultRespVO data = (AuthorizeResultRespVO) resp.getData();
if (data != null && data.getAlipayAccount() != null) {
return data.getAlipayAccount();
if (data != null ) {
if(StringUtils.isNotBlank(data.getAlipayId()) ){
return data.getAlipayId();
}else if(StringUtils.isNotBlank(data.getAlipayAccount())){
return data.getAlipayAccount();
}else{
return null;
}
}
}
return null;
... ...
... ... @@ -361,4 +361,18 @@ public class ProductController {
return new ApiResponse(code, e.getMessage(), Boolean.FALSE);
}
}
@ApiOperation(name = "ufo.product.storageInfo", desc="再次出售商品,卖家出售的价格区间 供app调用")
@RequestMapping(params = "method=ufo.product.storageInfo")
@Cachable(expire = 180)
public ApiResponse queryStorageBaseInfoEx(@RequestParam(value = "storage_id") Integer storageId) {
if (storageId == null) {
LOG.info("in method=ufo.product.storageInfo storageId Is Null");
return null;
}
LOG.info("in method=ufo.product.storageInfo storageId = {}", storageId);
StorageLeastPriceResp resp = productService.querStorageLeastPriceEx(storageId);
return new ApiResponse.ApiResponseBuilder().data(resp).code(200).message("storage data").build();
}
}
\ No newline at end of file
... ...
... ... @@ -16,4 +16,12 @@ public class StorageLeastPriceResp {
private Integer skup;
@JSONField(name="suggest_low_price")
private BigDecimal suggestLowPrice;
@JSONField(name="suggest_high_price")
private BigDecimal suggestHighPrice;
@JSONField(name="product_max_price")
private BigDecimal productMaxPrice = new BigDecimal(100000); //默认商品的最高售价
}
... ...
... ... @@ -58,4 +58,11 @@ public interface ProductService {
* @return
*/
int sellerBatchUpdatePrice(List<Integer> skupList, Double price);
/**
* 根据storageId查询建议价格,商品最高售价,skup出售价格
* @param storageId
* @return
*/
StorageLeastPriceResp querStorageLeastPriceEx(Integer storageId);
}
... ...
... ... @@ -135,6 +135,28 @@ public class ProductServiceImpl implements ProductService{
return resp;
}
public StorageLeastPriceResp querStorageLeastPriceEx(Integer storageId) {
Storage storage = storageMapper.selectByPrimaryKey(storageId);
if (null == storage) {
LOGGER.warn("storageMapper.selectByPrimaryKey is null, storageId is {}", storageId);
return new StorageLeastPriceResp();
}
StoragePrice storagePrice = storagePriceMapper.selectLeastPrice(storageId);
StorageLeastPriceResp resp = new StorageLeastPriceResp();
resp.setStorageId(storageId);
resp.setSuggestLowPrice(storage.getSuggestLowPrice());
resp.setSuggestHighPrice(storage.getSuggestHighPrice());
// 如果最低价高于建议售价,则相当于没有此库存
if (null != storagePrice && (null == storage.getSuggestHighPrice() || (null != storage.getSuggestHighPrice() && storagePrice.getPrice().compareTo(storage.getSuggestHighPrice()) <= 0))) {
resp.setLeastPrice(storagePrice.getPrice());
resp.setSkup(storagePrice.getSkup());
}
return resp;
}
@Override
public StorageDataResp queryStorageInfo(Integer storageId) {
StorageDataResp resp = new StorageDataResp();
... ...
... ... @@ -134,5 +134,11 @@
<artifactId>alipay-sdk-java</artifactId>
<version>3.4.27.ALL</version>
</dependency>
<dependency>
<groupId>xom</groupId>
<artifactId>xom</artifactId>
<version>1.2.5</version>
</dependency>
</dependencies>
</project>
\ No newline at end of file
... ...
... ... @@ -95,11 +95,7 @@ public class RealNameAuthorizeController {
throw new GatewayException(400, "参数错误,uid不存在!");
}
ZhiMaCert zhiMaCertInfo =realNameAuthorizeService.getValidZhiMaCert(uid);
boolean isZhiMaCert=false;
if(zhiMaCertInfo!=null){
isZhiMaCert=true;
}
boolean isZhiMaCert = realNameAuthorizeService.isValidZhiMaCert(uid);
return new ApiResponse(isZhiMaCert);
}
... ... @@ -158,10 +154,6 @@ public class RealNameAuthorizeController {
throw new GatewayException(400, "参数错误,uid不能为空!");
}
//zhiMacertID
if (reqVO.getZhiMaCertId() == null || reqVO.getZhiMaCertId()<=0){
throw new GatewayException(400, "参数错误,芝麻认知记录id不能为空!");
}
//bizNO
if(StringUtils.isBlank(reqVO.getZhiMaBizNo())){
... ... @@ -175,8 +167,8 @@ public class RealNameAuthorizeController {
/**
* 新接口
* 支付宝第三方验证后, 调用接口 保存 用户对应的支付宝账号信息
* 支付宝账号绑定接口--新
* 支付宝授权后自动绑定, 1)查询支付宝账号信息,2)支付宝账号信息入库
*/
@RequestMapping(params = "method=ufo.user.autoBindAliPayAccount")
public ApiResponse autoBindAliPayAccount(RealNameAuthorizeReqVO reqVO) throws GatewayException {
... ... @@ -184,15 +176,13 @@ public class RealNameAuthorizeController {
//(1) 优先校验请求的参数
if (reqVO == null || reqVO.getUid()<=0){
throw new GatewayException(400, "参数错误,uid不能为空!");
throw new GatewayException(402, "支付宝绑定失败,请重试");
}
//检查是否已经实名认证,如果已经认证直接返回
if(null != realNameAuthorizeService.getValidAuthorizeInfo(reqVO.getUid())){
throw new GatewayException (601,"已实名认证");
}
//(3) 开始绑定支付宝账号 入库
//2)走绑定流程
try{
realNameAuthorizeService.autoBindAliPayAccount(reqVO);
return new ApiResponse(200,"绑定成功");
... ... @@ -201,7 +191,7 @@ public class RealNameAuthorizeController {
if (e instanceof GatewayException) {
throw e;
}
return new ApiResponse(201,"绑定失败!");
return new ApiResponse(400,"支付宝绑定失败,请重试");
}
}
... ...
... ... @@ -18,6 +18,7 @@ public interface IRealNameAuthorizeService {
void saveAuthorizeInfo(RealNameAuthorizeReqVO reqVO);
boolean isValidZhiMaCert(int uid);
ZhiMaCert getValidZhiMaCert(int uid);
... ...
... ... @@ -13,6 +13,7 @@ import com.yoho.error.exception.ServiceException;
import com.yoho.tools.common.beans.ApiResponse;
import com.yohobuy.ufo.model.user.resp.AuthorizeResultRespVO;
import com.yohoufo.common.exception.GatewayException;
import com.yohoufo.common.exception.UfoServiceException;
import com.yohoufo.common.utils.HttpClient;
import com.yohoufo.common.utils.UserInfoHiddenHelper;
import com.yohoufo.dal.user.IUserAuthorizeInfoDao;
... ... @@ -28,9 +29,13 @@ import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Date;
/**
... ... @@ -51,6 +56,9 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
@Autowired
private HttpClient httpClient;
@Value("${zhimacert.switch:true}")
private boolean zhiMaCertSwitch;
/* @Autowired
private GraphVerifyService graphVerifyService;*/
... ... @@ -188,7 +196,7 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
/**
* 支付宝授权自动绑定
* 1)安卓客户端 --先获取 access_token, iphone跳过此步
* 1)安卓客户端 --先获取 access_token
* 2)获取用户信息
* 3)绑定入库
* @param reqVO
... ... @@ -197,15 +205,15 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
@Override
public void autoBindAliPayAccount(RealNameAuthorizeReqVO reqVO) throws GatewayException {
int uid = reqVO.getUid();
String access_token = reqVO.getAccess_token();
String auth_code = reqVO.getAuth_code();
logger.info("enter autoBindAliPayAccount, uid={}, auth_code={}, access_token={} ", reqVO, auth_code, access_token);
logger.info("enter autoBindAliPayAccount, uid={}, auth_code={} ", uid, auth_code);
String access_token;
//1)获取access_token
if(StringUtils.isEmpty( access_token)) {
if (StringUtils.isEmpty(auth_code)) {
throw new GatewayException(201, "请求参数错误,绑定失败!");
}
if(StringUtils.isEmpty(auth_code)) {
logger.warn("autoBindAliPayAccount error! auth_code is empty, uid={}",uid);
throw new GatewayException(402, "支付宝绑定失败,请重试");
}else{
//获取access_token alipay.system.oauth.token
AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfigInfo.OPENAPI_URL, AlipayConfigInfo.appid, AlipayConfigInfo.private_key, "json", "utf-8", AlipayConfigInfo.ali_public_key, "RSA");
AlipaySystemOauthTokenRequest request = new AlipaySystemOauthTokenRequest();
... ... @@ -216,16 +224,18 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
try {
response = alipayClient.execute(request);
} catch (AlipayApiException e) {
logger.warn("autoBindAliPayAccount AlipaySystemOauthTokenRequest error! uid={},auth_code={},response={}, e: {}", uid, auth_code, response, e);
throw new GatewayException(201, "绑定失败!");
logger.warn("autoBindAliPayAccount AlipaySystemOauthTokenRequest error! uid={},auth_code={},response.getCode={},response.getSubCode={} e: {}", uid, auth_code,
response == null ? "":response.getCode(), response == null ? "":response.getSubCode(), e);
throw new GatewayException(400, "支付宝绑定失败,请重试");
}
logger.info("autoBindAliPayAccount AlipaySystemOauthTokenRequest uid={},auth_code={},response={}", uid, auth_code, access_token, response);
logger.info("autoBindAliPayAccount AlipaySystemOauthTokenRequest uid={},auth_code={},response.getCode={},response.getSubCode={}", uid, auth_code,
response == null ? "":response.getCode(),response == null ? "":response.getSubCode());
//调用成功
if (response.isSuccess()) {
access_token = response.getAccessToken();
} else {
throw new GatewayException(201, "绑定失败!");
throw new GatewayException(400, "支付宝绑定失败,请重试");
}
}
... ... @@ -236,22 +246,24 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
try {
response = alipayClient.execute(request, access_token);
} catch (AlipayApiException e) {
logger.warn("autoBindAliPayAccount AlipayUserInfoShareRequest error! uid={},auth_code={},access_token={},response={}, e: {}", uid, auth_code, access_token,response, e);
throw new GatewayException(201, "绑定失败!");
logger.warn("autoBindAliPayAccount AlipayUserInfoShareRequest error! uid={},auth_code={},access_token={},response.getCode={},response.getSubCode={}, e: {}", uid, auth_code, access_token,
response == null ? "": response.getCode(), response == null ? "":response.getSubCode(), e);
throw new GatewayException(400, "支付宝绑定失败,请重试");
}
logger.info("autoBindAliPayAccount AlipayUserInfoShareRequest , uid={},auth_code={},access_token={}, response={}", uid, auth_code, access_token,response);
logger.info("autoBindAliPayAccount AlipayUserInfoShareRequest , uid={},auth_code={},access_token={}, response.getCode={},response.getSubCode={}", uid, auth_code, access_token,
response == null ? "": response.getCode(), response == null ? "":response.getSubCode());
if (!response.isSuccess()) {
throw new GatewayException(201, "绑定失败!");
throw new GatewayException(400, "支付宝绑定失败,请重试");
}
//3)调用成功--入库操作
String alipayUid = response.getUserId();
String nickName = response.getNickName();
if(StringUtils.isBlank(alipayUid)){
logger.warn("autoBindAliPayAccount error, alipayUid is blank! uid={},auth_code={},access_token={}, response={} ",uid, auth_code,access_token, response);
throw new GatewayException(201, "绑定失败!");
logger.warn("autoBindAliPayAccount error, alipayUid is blank! uid={},auth_code={},access_token={}",uid, auth_code,access_token);
throw new GatewayException(400, "支付宝绑定失败,请重试");
}
UserAuthorizeInfo userAuthorizeInfo = new UserAuthorizeInfo();
... ... @@ -263,7 +275,19 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
userAuthorizeInfo.setCreateTime(create_time);
userAuthorizeInfoDao.insertSelective(userAuthorizeInfo);
logger.info("autoBindAliPayAccount success!uid={}, alipayUid={}, nickName={} ", uid, alipayUid, nickName);
}
public boolean isValidZhiMaCert(int uid){
//如果芝麻认知没有开启,默认芝麻认证通过
if(!zhiMaCertSwitch){
return true;
}
//否则,从db查询认证信息
if(null!=this.getValidZhiMaCert(uid)){
return true;
}
return false;
}
@Override
... ... @@ -286,21 +310,37 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
return zhiMaCert;
}
/**
38 * 获取现在时间
39 *
40 * @return返回字符串格式 yyyy-MM-dd HH:mm:ss
41 */
public static String getStringDate() {
Date currentTime = new Date();
SimpleDateFormat formatter = new SimpleDateFormat("yyyyMMddHHmmss");
String dateString = formatter.format(currentTime);
return dateString;
}
public static void main(String[] args) {
System.out.println(getStringDate());
}
@Override
public AuthorizeResultRespVO zhiMaCertInit(RealNameAuthorizeReqVO reqVO) {
logger.info("real name zhiMaCertInit reqVO {}", reqVO);
//检查是否已经认证,如果已经认证,报错
if (null != this.getValidZhiMaCert(reqVO.getUid())) {
throw new ServiceException(400, "已实名认证!");
if (isValidZhiMaCert(reqVO.getUid())) {
throw new UfoServiceException(400, "已实名认证!");
}
//检查身份证号认证信息是否已经存在,存在则不允许再次使用
if (null != zhiMaCertDao.selectValidByCertNo(reqVO.getCertNo())) {
throw new ServiceException(400, "身份证号已被占用!");
throw new UfoServiceException(400, "身份证号已被占用!");
}
//调用芝麻接口,返回biz_no
//构建唯一的 transaction_id : ufoCert+id
LocalDateTime now = getLocalDateTime();
Long nowSecond = LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8"));
//存储认证信息
... ... @@ -319,7 +359,8 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
throw new ServiceException(400, "错误:保存实名认知信息异常!");
}
String transactionId="ufoCert"+zhiMaCert.getId();
//7+14+
String transactionId="ufoCert"+getStringDate()+zhiMaCert.getId();
String bizNo=ZhiMaCallUtil.zhiMaCertInit(transactionId,reqVO.getCertName(),reqVO.getCertNo());
... ... @@ -330,6 +371,7 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
//不需要更新bizNO到数据库了,不需要记录
zhiMaCertDao.updateBizNoByByPrimaryKey(zhiMaCert.getId(),bizNo);
//通过biz_no,生成returnUrl
String returnUrl = ZhiMaCallUtil.zhiMaCertUrl(bizNo);
... ... @@ -351,18 +393,20 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
public ApiResponse zhiMaCertResultQuery(RealNameAuthorizeReqVO reqVO) {
logger.info("real name zhiMaCertResultQuery reqVO {}", reqVO);
//根据uid,获取biz_no
ZhiMaCert zhiMaCert=zhiMaCertDao.selectByPrimaryKey(reqVO.getZhiMaCertId());
ZhiMaCert zhiMaCert=zhiMaCertDao.selectByBizNo(reqVO.getZhiMaBizNo());
if(zhiMaCert==null){
logger.error("zhiMaCertResultQuery get cert by biz no is null ",reqVO.getZhiMaBizNo());
throw new ServiceException(400, "错误:未找到芝麻认证信息!");
logger.error("zhiMaCertResultQuery get cert is null ",reqVO.getZhiMaBizNo());
throw new UfoServiceException(400, "错误:未找到芝麻认证信息!");
}
logger.info("zhiMaCertResultQuery get zhiMaCert by biz no from db is {} ",zhiMaCert);
logger.info("zhiMaCertResultQuery get zhiMaCert from db is {} ",zhiMaCert);
if(!zhiMaCert.getUid().equals(reqVO.getUid())){
Integer zhiMaCertId=zhiMaCert.getId();
/*if(!zhiMaCert.getUid().equals(reqVO.getUid())){
logger.error("zhiMaCertResultQuery get cert by biz no is not same req uid {} ,db uid {}",reqVO.getUid(),zhiMaCert.getUid());
throw new ServiceException(400, "错误:未找到用户芝麻认证信息!");
}
}*/
ZhimaCustomerCertificationQueryResponse zhiMaResp=ZhiMaCallUtil.zhiMaResult(reqVO.getZhiMaBizNo());
if(zhiMaResp==null){
... ... @@ -372,7 +416,7 @@ public class RealNameAuthorizeServiceImpl implements IRealNameAuthorizeService {
if(zhiMaResp.isSuccess()&&"true".equals(zhiMaResp.getPassed())){
//芝麻认证通过
int updateCount = zhiMaCertDao.updateValidStatusByPrimaryKey(reqVO.getZhiMaCertId());
int updateCount = zhiMaCertDao.updateValidStatusByPrimaryKey(zhiMaCertId);
if(updateCount <1){
logger.error("zhiMaCertResultQuery update zhi ma cert valid status error,req vo {}",reqVO);
throw new ServiceException(400, "错误:更新用户芝麻认证信息错误!");
... ...
package com.yohoufo.user.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import com.alipay.api.request.ZhimaCustomerCertificationCertifyRequest;
... ... @@ -24,30 +23,19 @@ public class ZhiMaCallUtil {
private static String url="https://openapi.alipaydev.com/gateway.do";//"https://openapi.alipay.com/gateway.do"
*/
private static String APP_ID = "2013080700000742";
private static String APP_PRIVATE_KEY = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAOfywqINCNC+IFvg" +
"zqq3aEYxmh89WamWL59FukMKoKYMDR1NWMgFLNX2ld6aRWWdlJCBUsTzH/8uabEj" +
"fBOM5BK+N08GfkpCYRmzww2y1H8RZ4P3wtKu95UYdaq3Ir5ucfgKxGy/1ay2qQFZ" +
"PAkvPtTw+qdkVOgPakvqCWgcFL8LAgMBAAECgYAYeTnmJV/vvo/lgePsiWucNHGh" +
"qDSEu08NDCtqFX375zufAuFCQaGIdfs8QKTf4u+hC7QzCcAvibMnOKpH2c7apAEc" +
"RUfTUUcY/UB/yIkvzjkvkMKZSXI6y3lyFn8mNEwQei9u4OdSg1IBVuWqZoyqilCm" +
"ARMzXyoeAOY55MelSQJBAPP+sEbPadMENkzzkiiHCHuo3Y0OEF5Zv2h3LJmtRx/6" +
"B60mrfaUSSbU/iNq0uzQSoDQlY2DxXb21l1LYZzgdn8CQQDzXFXNj/qkXIuTLjfK" +
"YxIhwiNKYXXKeG9C6+MlviY2zVrKruuuHJMcJ8238hzRcPsX+TCwFd3VhHuL61jB" +
"2+l1AkBhUNTH+VQQ6N4rhP5nkawNfkWXS+O1bgBMzzOHu7fhhhznr8S002H1zf/q" +
"6mFkOJNum0L65XKtxzeqkDVHl7NLAkEAg/jKvxMZRRC60DH8J1DagFwbbzay/f2Z" +
"uJzbLZiUeJucZNW/EUiFrnsXYG13m0y9nh6QfK0fA684oIQcOeTcEQJBAIxCxNUP" +
"jXsvqTV2ypek3ktvutFwSFuvo0zD2sn2HNlMSfh3K6RZV2Q0Q4W7bLELKEEkxmJX" +
"IMLSK3hQB7jYD0Q=";
private static String ALIPAY_PUBLIC_KEY = "MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCnxj/9qwVfgoUh/y2W89L6BkRAFljhNhgPdyPuBV64bfQNN1PjbCzkIM6qRdKBoLPXm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IPNB3/+nQQgpaekkogqcz5JnfTdJC8SEs79Enhgwisjt2Utb83b73qZQIDAQAB";
private static String url="https://openapi.alipay.com/gateway.do";
//固定不变
private final static String ZHI_MA_PRODUCT_CODE="w1010100000000002978";
private final static String input_charset = "utf-8";
private final static String signType = "RSA";//目前支持RSA2和RSA,推荐使用RSA2
private final static String signType = "RSA2";//目前支持RSA2和RSA,推荐使用RSA2
/**
* 芝麻认知,请求biz_no
... ... @@ -63,6 +51,7 @@ public class ZhiMaCallUtil {
AlipayClient alipayClient = new DefaultAlipayClient(url, APP_ID, APP_PRIVATE_KEY, "json", input_charset, ALIPAY_PUBLIC_KEY, signType);
ZhimaCustomerCertificationInitializeRequest request = new ZhimaCustomerCertificationInitializeRequest();
/*
JSONObject identityParam=new JSONObject();
identityParam.put("identity_type","CERT_INFO");
identityParam.put("cert_type","IDENTITY_CARD");
... ... @@ -75,20 +64,21 @@ public class ZhiMaCallUtil {
jo.put("biz_code","SMART_FACE");
jo.put("identity_param",identityParam);
jo.put("ext_biz_param",new JSONObject());
/*String bizContent = "{"
*/
//bizContent 要求严格按照以下顺序
String bizContent = "{"
+ "\"transaction_id\":\""+transactionId+"\","
+ "\"product_code\":\"w1010100000000002978\","
+ "\"product_code\":\""+ZHI_MA_PRODUCT_CODE+"\","
+ "\"biz_code\":\"SMART_FACE\","
+ "\"identity_param\":\"{\\\"identity_type\\\":\\\"CERT_INFO\\\",\\\"cert_type\\\":\\\"IDENTITY_CARD\\\",\\\"cert_name\\\":\\\""+certName+"\\\",\\\"cert_no\\\":\\\""+certNo+"\\\"}\","
+ "\"ext_biz_param\":\"{}\"" + " }";*/
+ "\"ext_biz_param\":\"{}\"" + " }";
String bizContent=JSON.toJSONString(jo);
//String bizContent=JSON.toJSONString(jo);
request.setBizContent(bizContent);
logger.info("zhi ma cert init begin request is {} ",request);
logger.info("zhi ma cert init begin request is {} ",JSON.toJSONString(request));
ZhimaCustomerCertificationInitializeResponse response = alipayClient.execute(request);
logger.info("zhi ma cert init end response {}",response);
logger.info("zhi ma cert init end response {}", JSON.toJSONString(response));
if (response.isSuccess()) {
logger.info("zhi ma cert init end ,call success ");
... ... @@ -119,21 +109,23 @@ public class ZhiMaCallUtil {
ZhimaCustomerCertificationCertifyRequest request = new ZhimaCustomerCertificationCertifyRequest();
// 设置业务参数,必须要biz_no
JSONObject jo=new JSONObject();
/* JSONObject jo=new JSONObject();
jo.put("biz_no",bizNo);
String bizContent=JSON.toJSONString(jo);*/
String bizContent=JSON.toJSONString(jo);
// 设置业务参数,必须要biz_no
String bizContent="{\"biz_no\":\""+bizNo+"\"}";
request.setBizContent(bizContent);
// 设置回调地址,必填. 如果需要直接在支付宝APP里面打开回调地址使用alipay协议
// alipay://www.taobao.com 或者 alipays://www.taobao.com,分别对应http和https请求
request.setReturnUrl("alipays://www.taobao.com");
request.setReturnUrl("yohobuyufo://www.yohobuy.com/ufo?pagename=NameAuth&");
logger.info("zhi ma cert url begin ,request {} ",request);
logger.info("zhi ma cert url begin ,request {} ",JSON.toJSONString(request));
// 这里一定要使用GET模式
ZhimaCustomerCertificationCertifyResponse response = alipayClient.pageExecute(request, "GET");
logger.info("zhi ma cert url end ,response {} " ,response);
logger.info("zhi ma cert url end ,response {} " ,JSON.toJSONString(response));
// 从body中获取URL
String url = response.getBody();
return url;
... ... @@ -159,15 +151,16 @@ public class ZhiMaCallUtil {
ZhimaCustomerCertificationQueryRequest request = new ZhimaCustomerCertificationQueryRequest();
// 设置业务参数,必须要biz_no
JSONObject jo=new JSONObject();
/*JSONObject jo=new JSONObject();
jo.put("biz_no",bizNo);
String bizContent=JSON.toJSONString(jo);
String bizContent=JSON.toJSONString(jo);*/
String bizContent="{\"biz_no\":\""+bizNo+"\"}";
request.setBizContent(bizContent);
logger.info("zhi ma result begin ,request {} ",request);
response = alipayClient.execute(request);
logger.info("zhi ma result end ,response {} ",response);
logger.info("zhi ma result end ,response {} ",JSON.toJSONString(response));
return response;
}catch (Exception e){
... ...
... ... @@ -2,6 +2,9 @@
deposit.prestore=999
# 保证金充值列表
deposit.recharge.list=1000,2000,5000,10000
# 芝麻认证开始开关,如果为false,芝麻认知直接返回通过
zhimacert.switch=true
# ******************** service call timeout in mil-seconds ********************
service.call.connectReqTimeout=6000
service.call.socketTimeout=6000
... ...
... ... @@ -3,6 +3,9 @@ deposit.prestore=${depositPrestore}
# 保证金充值列表
deposit.recharge.list=${depositRechargeList}
# 芝麻认证开始开关,如果为false,芝麻认知直接返回通过
zhimacert.switch=${zhiMaCertSwitch}
# if true, client_security check may be disabled.
is_debug_enable=${is_debug_enable}
# ******************** service call timeout in mil-seconds ********************
... ...
... ... @@ -42,6 +42,7 @@
<url-pattern>/html/h5Share/css/font/sf-pro-text-medium.woff</url-pattern>
<url-pattern>/html/ios_ufo_shortcut.html</url-pattern>
</servlet-mapping>
<servlet>
<servlet-name>dispatcher</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
... ...