Explorar o código

第三方支付

qin %!s(int64=2) %!d(string=hai) anos
pai
achega
753648e9b7

+ 3 - 1
src/main/java/com/poteviohealth/ym/ipos/controller/BankController.java

@@ -1,6 +1,7 @@
 package com.poteviohealth.ym.ipos.controller;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.poteviohealth.cgp.common.controller.BaseWebController;
 import com.poteviohealth.cgp.common.integrated.StringParams;
 import com.poteviohealth.cgp.common.model.IntegerParams;
@@ -48,6 +49,7 @@ public class BankController extends BaseWebController {
     @PostMapping("/listBankBranch")
     @ApiOperation(httpMethod = "POST", value = "查询分行列表")
     public VaultsResponse<List<BankBranch>> listBankBranch(@RequestBody BankDto params) {
+        Page<BankBranch> page = new Page<>(1,500);
         QueryWrapper<BankBranch> queryWrapper = new QueryWrapper<>();
         if(params.getId() != null){
             queryWrapper.eq("bank_id",params.getId());
@@ -55,6 +57,6 @@ public class BankController extends BaseWebController {
         if(StringUtils.isNotEmpty(params.getName())){
             queryWrapper.like("name",params.getName());
         }
-        return VaultsResponse.success(bankBranchService.list(queryWrapper));
+        return VaultsResponse.success(bankBranchService.page(page,queryWrapper).getRecords());
     }
 }

+ 0 - 16
src/main/java/com/poteviohealth/ym/ipos/controller/MerchantController.java

@@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
-import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
 
@@ -38,25 +37,10 @@ public class MerchantController  extends BaseWebController {
         return merchantService.merchantCreateOpen(userDto);
     }
 
-    @PostMapping("/merchantPicture")
-    @ApiOperation(value = "上传图片")
-    @OperationLog(type = OperateType.ADD, description ="上传图片")
-    public VaultsResponse merchantPicture(@RequestBody ImageDto dto) {
-        return merchantService.merchantPicture(dto);
-    }
-
     @PostMapping("/merchantQuery")
     @ApiOperation(value = "分账商户查询")
     @OperationLog(type = OperateType.SELECT, description ="分账商户查询")
     public VaultsResponse<UserSearchBack> merchantQuery(@RequestBody SearchDto dto) {
         return merchantService.merchantQuery(dto.getPhone(),dto.getMerchantId());
     }
-
-
-    @PostMapping("/test")
-    @ApiOperation(value = "测试")
-    @OperationLog(type = OperateType.SELECT, description ="测试")
-    public VaultsResponse test() {
-        return VaultsResponse.success();
-    }
 }

+ 1 - 0
src/main/java/com/poteviohealth/ym/ipos/model/merchant/back/UserSearchBack.java

@@ -2,6 +2,7 @@ package com.poteviohealth.ym.ipos.model.merchant.back;
 
 import com.poteviohealth.ym.ipos.model.back.BaseBack;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.Builder;
 import lombok.Data;
 
 import java.util.List;

+ 8 - 23
src/main/java/com/poteviohealth/ym/ipos/model/merchant/dto/UserDto.java

@@ -63,10 +63,10 @@ public class UserDto {
     private String contact_phone;
 
     @ApiModelProperty(value = "证件照正面")
-    private String cert_photo_a;
+    private ImageDto cert_photo_a;
 
     @ApiModelProperty(value = "证件照反面,证件类型为身份证时必填")
-    private String cert_photo_b;
+    private ImageDto cert_photo_b;
 
     @ApiModelProperty(value = "营业执照/统一社会信用证(三证合一)")
     private String license_code;
@@ -80,14 +80,8 @@ public class UserDto {
     @ApiModelProperty(value = "营业执照永久有效标识,1:永久,0:非永久,默认0")
     private String license_validity_type;
 
-    @ApiModelProperty(value = "营业执照注册地 省码,营业执照注册地 省码,地区编码参考《地区编码》")
-    private String license_province_code;
-
-    @ApiModelProperty(value = "营业执照注册地 市码,营业执照注册地 省码,地区编码参考《地区编码》")
-    private String license_city_code;
-
     @ApiModelProperty(value = "营业执照注册地 区县码,营业执照注册地 省码,地区编码参考《地区编码》")
-    private String license_area_code;
+    private Integer license_area;
 
     @ApiModelProperty(value = "营业执照地址")
     private String license_address;
@@ -96,7 +90,7 @@ public class UserDto {
     private String contact_name;
 
     @ApiModelProperty(value = "营业执照/统一社会信用证(三证合一)")
-    private String license_photo;
+    private ImageDto license_photo;
 
     @ApiModelProperty(value = "1:对公,2:对私法人,3:对私非法人;个人用户仅支持传2")
     private Integer settle_type;
@@ -107,12 +101,6 @@ public class UserDto {
     @ApiModelProperty(value = "提现方式1:手动提现,2:自动提现;当结算方式填0时,才需填写此项,不填默认为1")
     private Integer withdraw_way;
 
-    @ApiModelProperty(value = "提现类型1:周期提现,2:账期提现;当提现方式填2时,此项为必填")
-    private Integer withdraw_type;
-
-    @ApiModelProperty(value = "提现间隔时间,当有填写提现类型时此项必填,到达该时间后系统会进行自动提现,单位为自然日,取值范围[1,120]; 示例值: 1")
-    private Integer nature_day_num;
-
     @ApiModelProperty(value = "银行卡号")
     private String card_no;
 
@@ -122,11 +110,8 @@ public class UserDto {
     @ApiModelProperty(value = "结算开户银行号,结算开户银行号,编码参考《银行编码》")
     private String parent_bank_code;
 
-    @ApiModelProperty(value = "开户行所在省,开户行所在省,开户行所在市必须同时上送,地区编码参考《地区编码》")
-    private String province;
-
     @ApiModelProperty(value = "开户行所在市,开户行所在市,开户行所在市必须同时上送,地区编码参考《地区编码》")
-    private String city;
+    private Integer bank_area;
 
     @ApiModelProperty(value = "支付行号,对公时支付行号、开户支行名称二选一必填,参考《支行编码》中完整支行编码")
     private String branch_bank_code;
@@ -135,10 +120,10 @@ public class UserDto {
     private String branch_bank_name;
 
     @ApiModelProperty(value = "结算卡正面")
-    private String settle_photo_a;
+    private ImageDto settle_photo_a;
 
     @ApiModelProperty(value = "结算卡背面")
-    private String settle_photo_b;
+    private ImageDto settle_photo_b;
 
     @ApiModelProperty(value = "留存金额,小于等于该金额不会结算,单位为分,取值范围[0,9999999999];手动提现时无需填写")
     private Long remained_amt;
@@ -146,6 +131,6 @@ public class UserDto {
     @ApiModelProperty(value = "结算摘要,如果需要自定义结算打款备注,请使用此字段传入,默认为空。示例值:业务收款;手动提现时无需填写")
     private String settle_abstract;
 
-    @ApiModelProperty(value = "商户状态,0:待进件,-1:进件失败,2:进件成功(开户并且业务入驻成功),3:通道开户成功")
+    @ApiModelProperty(value = "商户状态,0:待进件,-1:进件失败(开户失败),2:进件成功(开户并且业务入驻成功),3:通道开户成功(已开户,但未做业务入驻或业务入驻失败)")
     private String incoming_status;
 }

+ 2 - 2
src/main/java/com/poteviohealth/ym/ipos/model/payment/detail/PayDetail.java

@@ -13,10 +13,10 @@ import java.util.List;
 public class PayDetail {
 
     @ApiModelProperty(value = "515:微信小程序",required = true)
-    private String pay_type;
+    private String pay_type="515";
 
     @ApiModelProperty(value = "交易类型,微信小程序取值如下:JSAPI",required = true)
-    private String trade_type;
+    private String trade_type="JSAPI";
 
     @ApiModelProperty(value = "用户标识:微信小程序:用户在商户appid下的唯一标识(openid)")
     private String buyer_id;

+ 10 - 0
src/main/java/com/poteviohealth/ym/ipos/service/IAreaService.java

@@ -3,10 +3,20 @@ package com.poteviohealth.ym.ipos.service;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.poteviohealth.ym.ipos.model.Area;
 
+import java.util.List;
+
 /**
  * 区域
  * @author Qin
  */
 public interface IAreaService extends IService<Area> {
 
+
+    /**
+     * 根据Id,获取对应code
+     * @param id
+     * @return
+     */
+    List<String> getAreaCode(Integer id);
+
 }

+ 1 - 1
src/main/java/com/poteviohealth/ym/ipos/service/IMerchantService.java

@@ -17,7 +17,7 @@ public interface IMerchantService {
      * @param dto
      * @return
      */
-     VaultsResponse merchantPicture(ImageDto dto);
+     VaultsResponse<String> merchantPicture(ImageDto dto);
 
     /**
      * 商户新增/修改开户入驻

+ 9 - 1
src/main/java/com/poteviohealth/ym/ipos/service/impl/AreaServiceImpl.java

@@ -1,11 +1,15 @@
 package com.poteviohealth.ym.ipos.service.impl;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.google.common.collect.Lists;
 import com.poteviohealth.ym.ipos.mapper.AreaMapper;
 import com.poteviohealth.ym.ipos.model.Area;
 import com.poteviohealth.ym.ipos.service.IAreaService;
 import org.springframework.stereotype.Service;
 
+import java.util.Arrays;
+import java.util.List;
+
 /**
  * 区域
  * @author Qin
@@ -13,5 +17,9 @@ import org.springframework.stereotype.Service;
 @Service
 public class AreaServiceImpl extends ServiceImpl<AreaMapper, Area> implements IAreaService {
 
-
+    @Override
+    public List<String> getAreaCode(Integer id) {
+        Area area = this.getById(id);
+        return  Arrays.asList(area.getCodePath().split(","));
+    }
 }

+ 138 - 44
src/main/java/com/poteviohealth/ym/ipos/service/impl/MerchantServiceImpl.java

@@ -1,28 +1,33 @@
 package com.poteviohealth.ym.ipos.service.impl;
 
-import cn.hutool.core.codec.Base64Encoder;
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.TypeReference;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.poteviohealth.cgp.common.integrated.OperatorIdParams;
 import com.poteviohealth.cgp.common.integrated.customer.CustomerFeignClient;
 import com.poteviohealth.cgp.common.integrated.partner.PartnerFeignClient;
 import com.poteviohealth.cgp.common.model.VaultsResponse;
+import com.poteviohealth.ym.ipos.model.Area;
 import com.poteviohealth.ym.ipos.model.back.BaseBack;
 import com.poteviohealth.ym.ipos.model.merchant.*;
+import com.poteviohealth.ym.ipos.model.merchant.back.ImageListBack;
 import com.poteviohealth.ym.ipos.model.merchant.detail.*;
 import com.poteviohealth.ym.ipos.model.merchant.dto.ImageDto;
 import com.poteviohealth.ym.ipos.model.merchant.dto.UserDto;
 import com.poteviohealth.ym.ipos.model.merchant.back.PictureBack;
 import com.poteviohealth.ym.ipos.model.merchant.back.UserBack;
 import com.poteviohealth.ym.ipos.model.merchant.back.UserSearchBack;
+import com.poteviohealth.ym.ipos.service.IAreaService;
 import com.poteviohealth.ym.ipos.service.IMerchantService;
 import com.poteviohealth.ym.ipos.utils.YmUtil;
 import lombok.extern.log4j.Log4j2;
 import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.lang3.time.DateFormatUtils;
 import org.springframework.stereotype.Service;
-import org.springframework.web.multipart.MultipartFile;
 
 import javax.annotation.Resource;
-import java.io.IOException;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 商户入驻接口实现
@@ -38,6 +43,8 @@ public class MerchantServiceImpl implements IMerchantService {
     private PartnerFeignClient partnerFeignClient;
     @Resource
     private CustomerFeignClient customerFeignClient;
+    @Resource
+    private IAreaService areaService;
 
     /**
      * 上传图片
@@ -45,7 +52,7 @@ public class MerchantServiceImpl implements IMerchantService {
      * @return
      */
     @Override
-    public VaultsResponse merchantPicture(ImageDto dto){
+    public VaultsResponse<String> merchantPicture(ImageDto dto){
         Picture p = new Picture();
         PictureDetail detail = new PictureDetail();
         detail.setType(dto.getType());
@@ -53,7 +60,13 @@ public class MerchantServiceImpl implements IMerchantService {
         detail.setImage_content(dto.getBase64Str());
         p.setMerchant_picture_request(detail);
 
-        PictureBack back = (PictureBack) YmUtil.resultBack(p,new PictureBack());
+        PictureBack back = null;
+        try {
+            back = (PictureBack) YmUtil.resultBack(p,new PictureBack());
+        } catch (IllegalAccessException e) {
+            e.printStackTrace();
+            return VaultsResponse.failed(e.getMessage());
+        }
 
         if(SUCCESS.equals(back.getResult().getId())){
             return VaultsResponse.success(back.getId());
@@ -69,13 +82,34 @@ public class MerchantServiceImpl implements IMerchantService {
      */
     @Override
     public VaultsResponse merchantCreateOpen(UserDto dto) {
+        VaultsResponse<UserSearchBack> vaultsResponse = this.merchantQuery(dto.getPhone(),null);
+        if(!vaultsResponse.validate()){
+            return vaultsResponse;
+        }
+        UserSearchBack searchBack = vaultsResponse.getData();
+        Integer status = 0;
+        if(searchBack != null){
+             status = Integer.parseInt(searchBack.getIncoming_status());
+        }
+
+        if(StringUtils.isEmpty(dto.getIncoming_status())){
+            dto.setIncoming_status(status.toString());
+        }
+
         if(StringUtils.isEmpty(dto.getMerchant_id())){
+            if(searchBack != null){
+                return VaultsResponse.failed("手机号码已被注册");
+            }
             //添加商户
             VaultsResponse<String> createVault = this.merchantCreate(dto);
             if(!createVault.validate()){
                 return createVault;
             }
             dto.setMerchant_id(createVault.getData());
+        }else{
+            if(searchBack != null && !searchBack.getMerchant_id().equals(dto.getMerchant_id())){
+                return VaultsResponse.failed("手机号码已被注册");
+            }
         }
 
         if(dto.getIncoming_status().equals("2")){
@@ -102,6 +136,7 @@ public class MerchantServiceImpl implements IMerchantService {
                         return entregisterVault;
                     }
                 }
+                updateMerchantId(dto.getId(), dto.getSourceId(), dto.getMerchant_id(),3);
             }else{
                 VaultsResponse<String> indvmodifyVault = this.modifyVault(dto);
                 if(!indvmodifyVault.validate()){
@@ -114,6 +149,9 @@ public class MerchantServiceImpl implements IMerchantService {
             if(!openVault.validate()){
                 return openVault;
             }
+            if(status != 2){
+                updateMerchantId(dto.getId(), dto.getSourceId(), dto.getMerchant_id(),2);
+            }
         }
         return VaultsResponse.success();
     }
@@ -143,12 +181,6 @@ public class MerchantServiceImpl implements IMerchantService {
      */
     private VaultsResponse merchantCreate(UserDto dto) {
 
-        VaultsResponse<UserSearchBack> vaultsResponse = this.merchantQuery(dto.getPhone(),null);
-        if(vaultsResponse.validate()){
-            String merchantId = vaultsResponse.getData().getMerchant_id();
-            return updateMerchantId(dto.getId(), dto.getSourceId(), merchantId);
-        }
-
         User user = new User();
         UserDetail detail = new UserDetail();
         detail.setType(dto.getType());
@@ -156,20 +188,27 @@ public class MerchantServiceImpl implements IMerchantService {
         detail.setMerchant_name(dto.getMerchant_name());
         detail.setPhone(dto.getPhone());
         user.setMerchant_create_request(detail);
-        UserBack back = (UserBack) YmUtil.resultBack(user,new UserBack());
+        UserBack back = null;
+        try {
+            back = (UserBack) YmUtil.resultBack(user,new UserBack());
+        } catch (IllegalAccessException e) {
+            e.printStackTrace();
+            return VaultsResponse.failed(e.getMessage());
+        }
 
         if(SUCCESS.equals(back.getResult().getId())){
-            return updateMerchantId(dto.getId(), dto.getSourceId(), back.getMerchant_id());
+            return updateMerchantId(dto.getId(), dto.getSourceId(), back.getMerchant_id(),0);
         }
         return VaultsResponse.failed(back.getResult().getComment());
     }
 
-    private VaultsResponse updateMerchantId(Integer id, Integer source, String merchantId) {
+    private VaultsResponse updateMerchantId(Integer id, Integer source, String merchantId,Integer status) {
         VaultsResponse vaultsResponse = VaultsResponse.success(merchantId);
         OperatorIdParams operatorIdParams = new OperatorIdParams();
         operatorIdParams.setOperatorId(id);
         operatorIdParams.setId(merchantId);
         operatorIdParams.setSource(source);
+        operatorIdParams.setStatus(status);
         if(source.equals(3)){
             VaultsResponse cus =  customerFeignClient.updateMerchantId(operatorIdParams);
             if(!cus.validate()){
@@ -201,14 +240,20 @@ public class MerchantServiceImpl implements IMerchantService {
         }
         detail.setIdentity_validity_type(dto.getIdentity_validity_type());
         detail.setContact_phone(dto.getContact_phone());
-        detail.setCert_photo_a(dto.getCert_photo_a());
-        detail.setCert_photo_b(dto.getCert_photo_b());
+        detail.setCert_photo_a(this.merchantPicture(dto.getCert_photo_a()).getData());
+        detail.setCert_photo_b(this.merchantPicture(dto.getCert_photo_b()).getData());
         detail.setLegal_name(dto.getLegal_name());
         detail.setIdentity_no(dto.getIdentity_no());
         detail.setMerchant_name(dto.getMerchant_name());
         detail.setIdentity_type(dto.getIdentity_type());
         iAdd.setMerchant_indvregister_request(detail);
-        BaseBack back = (BaseBack) YmUtil.resultBack(iAdd,new BaseBack());
+        BaseBack back = null;
+        try {
+            back = (BaseBack) YmUtil.resultBack(iAdd,new BaseBack());
+        } catch (IllegalAccessException e) {
+            e.printStackTrace();
+            return VaultsResponse.failed(e.getMessage());
+        }
 
         if(SUCCESS.equals(back.getResult().getId())){
             return VaultsResponse.success();
@@ -231,11 +276,17 @@ public class MerchantServiceImpl implements IMerchantService {
         }
         iUpdateDetail.setIdentity_validity_type(dto.getIdentity_validity_type());
         iUpdateDetail.setContact_phone(dto.getContact_phone());
-        iUpdateDetail.setCert_photo_a(dto.getCert_photo_a());
-        iUpdateDetail.setCert_photo_b(dto.getCert_photo_b());
+        iUpdateDetail.setCert_photo_a(this.merchantPicture(dto.getCert_photo_a()).getData());
+        iUpdateDetail.setCert_photo_b(this.merchantPicture(dto.getCert_photo_b()).getData());
 
         iUpdate.setMerchant_indvmodify_request(iUpdateDetail);
-        BaseBack back = (BaseBack) YmUtil.resultBack(iUpdate,new BaseBack());
+        BaseBack back = null;
+        try {
+            back = (BaseBack) YmUtil.resultBack(iUpdate,new BaseBack());
+        } catch (IllegalAccessException e) {
+            e.printStackTrace();
+            return VaultsResponse.failed(e.getMessage());
+        }
 
         if(SUCCESS.equals(back.getResult().getId())){
             return VaultsResponse.success();
@@ -257,9 +308,10 @@ public class MerchantServiceImpl implements IMerchantService {
             detail.setLicense_end_date(dto.getLicense_end_date());
         }
         detail.setLicense_validity_type(dto.getLicense_validity_type());
-        detail.setLicense_province_code(dto.getLicense_province_code());
-        detail.setLicense_city_code(dto.getLicense_city_code());
-        detail.setLicense_area_code(dto.getLicense_area_code());
+        List<String> areaList = areaService.getAreaCode(dto.getLicense_area());
+        detail.setLicense_province_code(areaList.get(0));
+        detail.setLicense_city_code(areaList.get(1));
+        detail.setLicense_area_code(areaList.get(2));
         detail.setLicense_address(dto.getLicense_address());
         detail.setLegal_name(dto.getLegal_name());
         detail.setIdentity_no(dto.getIdentity_no());
@@ -270,14 +322,20 @@ public class MerchantServiceImpl implements IMerchantService {
         detail.setIdentity_validity_type(dto.getIdentity_validity_type());
         detail.setContact_name(dto.getContact_name());
         detail.setContact_phone(dto.getContact_phone());
-        detail.setLicense_photo(dto.getLicense_photo());
-        detail.setCert_photo_a(dto.getCert_photo_a());
-        detail.setCert_photo_b(dto.getCert_photo_b());
+        detail.setLicense_photo(this.merchantPicture(dto.getLicense_photo()).getData());
+        detail.setCert_photo_a(this.merchantPicture(dto.getCert_photo_a()).getData());
+        detail.setCert_photo_b(this.merchantPicture(dto.getCert_photo_b()).getData());
         detail.setMerchant_name(dto.getMerchant_name());
         detail.setLicense_code(dto.getLicense_code());
         detail.setIdentity_type(dto.getIdentity_type());
         iAdd.setMerchant_entregister_request(detail);
-        BaseBack back = (BaseBack) YmUtil.resultBack(iAdd,new BaseBack());
+        BaseBack back = null;
+        try {
+            back = (BaseBack) YmUtil.resultBack(iAdd,new BaseBack());
+        } catch (IllegalAccessException e) {
+            e.printStackTrace();
+            return VaultsResponse.failed(e.getMessage());
+        }
 
         if(SUCCESS.equals(back.getResult().getId())){
             return VaultsResponse.success();
@@ -299,9 +357,10 @@ public class MerchantServiceImpl implements IMerchantService {
             iUpdateDetail.setLicense_end_date(dto.getLicense_end_date());
         }
         iUpdateDetail.setLicense_validity_type(dto.getLicense_validity_type());
-        iUpdateDetail.setLicense_province_code(dto.getLicense_province_code());
-        iUpdateDetail.setLicense_city_code(dto.getLicense_city_code());
-        iUpdateDetail.setLicense_area_code(dto.getLicense_area_code());
+        List<String> areaList = areaService.getAreaCode(dto.getLicense_area());
+        iUpdateDetail.setLicense_province_code(areaList.get(0));
+        iUpdateDetail.setLicense_city_code(areaList.get(1));
+        iUpdateDetail.setLicense_area_code(areaList.get(2));
         iUpdateDetail.setLicense_address(dto.getLicense_address());
         iUpdateDetail.setLegal_name(dto.getLegal_name());
         iUpdateDetail.setIdentity_no(dto.getIdentity_no());
@@ -312,12 +371,18 @@ public class MerchantServiceImpl implements IMerchantService {
         iUpdateDetail.setIdentity_validity_type(dto.getIdentity_validity_type());
         iUpdateDetail.setContact_name(dto.getContact_name());
         iUpdateDetail.setContact_phone(dto.getContact_phone());
-        iUpdateDetail.setLicense_photo(dto.getLicense_photo());
-        iUpdateDetail.setCert_photo_a(dto.getCert_photo_a());
-        iUpdateDetail.setCert_photo_b(dto.getCert_photo_b());
+        iUpdateDetail.setLicense_photo(this.merchantPicture(dto.getLicense_photo()).getData());
+        iUpdateDetail.setCert_photo_a(this.merchantPicture(dto.getCert_photo_a()).getData());
+        iUpdateDetail.setCert_photo_b(this.merchantPicture(dto.getCert_photo_b()).getData());
 
         iUpdate.setMerchant_entmodify_request(iUpdateDetail);
-        BaseBack back = (BaseBack) YmUtil.resultBack(iUpdate,new BaseBack());
+        BaseBack back = null;
+        try {
+            back = (BaseBack) YmUtil.resultBack(iUpdate,new BaseBack());
+        } catch (IllegalAccessException e) {
+            e.printStackTrace();
+            return VaultsResponse.failed(e.getMessage());
+        }
 
         if(SUCCESS.equals(back.getResult().getId())){
             return VaultsResponse.success();
@@ -333,7 +398,13 @@ public class MerchantServiceImpl implements IMerchantService {
     private VaultsResponse merchantOpen(UserDto dto){
         OpenAdd openAdd = new OpenAdd();
         openAdd.setMerchant_open_request(this.fill(dto));
-        BaseBack back = (BaseBack) YmUtil.resultBack(openAdd,new BaseBack());
+        BaseBack back = null;
+        try {
+            back = (BaseBack) YmUtil.resultBack(openAdd,new BaseBack());
+        } catch (IllegalAccessException e) {
+            e.printStackTrace();
+            return VaultsResponse.failed(e.getMessage());
+        }
 
         if(SUCCESS.equals(back.getResult().getId())){
             return VaultsResponse.success(back);
@@ -352,17 +423,16 @@ public class MerchantServiceImpl implements IMerchantService {
         detail.setSettle_type(dto.getSettle_type());
         detail.setSettlement_way(dto.getSettlement_way());
         detail.setWithdraw_way(dto.getWithdraw_way());
-        detail.setWithdraw_type(dto.getWithdraw_type());
-        detail.setNature_day_num(dto.getNature_day_num());
         detail.setCard_no(dto.getCard_no());
         detail.setParent_bank_name(dto.getParent_bank_name());
         detail.setParent_bank_code(dto.getParent_bank_code());
-        detail.setProvince(dto.getProvince());
-        detail.setCity(dto.getCity());
+        List<String> areaList = areaService.getAreaCode(dto.getBank_area());
+        detail.setProvince(areaList.get(0));
+        detail.setCity(areaList.get(1));
         detail.setBranch_bank_code(dto.getBranch_bank_code());
         detail.setBranch_bank_name(dto.getBranch_bank_name());
-        detail.setSettle_photo_a(dto.getSettle_photo_a());
-        detail.setSettle_photo_b(dto.getSettle_photo_b());
+        detail.setSettle_photo_a(this.merchantPicture(dto.getSettle_photo_a()).getData());
+        detail.setSettle_photo_b(this.merchantPicture(dto.getSettle_photo_b()).getData());
         detail.setRemained_amt(dto.getRemained_amt());
         detail.setSettle_abstract(dto.getSettle_abstract());
         return detail;
@@ -376,7 +446,13 @@ public class MerchantServiceImpl implements IMerchantService {
     private VaultsResponse merchantOpenModify(UserDto dto){
         OpenUpdate openUpdate = new OpenUpdate();
         openUpdate.setMerchant_openmodify_request(this.fill(dto));
-        BaseBack back = (BaseBack) YmUtil.resultBack(openUpdate,new BaseBack());
+        BaseBack back = null;
+        try {
+            back = (BaseBack) YmUtil.resultBack(openUpdate,new BaseBack());
+        } catch (IllegalAccessException e) {
+            e.printStackTrace();
+            return VaultsResponse.failed(e.getMessage());
+        }
 
         if(SUCCESS.equals(back.getResult().getId())){
             return VaultsResponse.success(back);
@@ -398,11 +474,29 @@ public class MerchantServiceImpl implements IMerchantService {
         detail.setPhone(phone);
         detail.setMerchant_id(merchantId);
         userSearch.setMerchant_query_request(detail);
-        UserSearchBack back = (UserSearchBack) YmUtil.resultBack(userSearch,new UserSearchBack());
+        UserSearchBack back = null;
+        try {
+            String val = (String) YmUtil.resultBack(userSearch,new UserSearchBack());
+            JSONObject jsonObject = new JSONObject(JSON.parseObject(val));
+            if(val.contains("image_list")){
+                List<ImageListBack> list = jsonObject.getJSONArray("image_list").stream().map(item -> JSON.parseObject(item.toString(), new TypeReference<ImageListBack>() {})).collect(Collectors.toList());
+                jsonObject.put("image_list",list);
+            }
+            back = JSONObject.toJavaObject(jsonObject, UserSearchBack.class);
+
+        } catch (IllegalAccessException e) {
+            e.printStackTrace();
+            return VaultsResponse.failed(e.getMessage());
+        }
 
         if(SUCCESS.equals(back.getResult().getId())){
             return VaultsResponse.success(back);
+        }else if("9990".equals(back.getResult().getId())){
+            return VaultsResponse.success(null);
         }
         return VaultsResponse.failed();
     }
+
+
+
 }

+ 49 - 11
src/main/java/com/poteviohealth/ym/ipos/utils/YmUtil.java

@@ -1,36 +1,52 @@
 package com.poteviohealth.ym.ipos.utils;
 
+import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.alibaba.fastjson.TypeReference;
 import com.google.common.collect.Maps;
+import com.google.gson.internal.LinkedHashTreeMap;
+import com.poteviohealth.cgp.common.model.VaultsResponse;
 import com.poteviohealth.cgp.common.utils.HttpUtils;
+import com.poteviohealth.ym.ipos.model.merchant.Picture;
+import com.poteviohealth.ym.ipos.model.merchant.UserSearch;
+import com.poteviohealth.ym.ipos.model.merchant.back.ImageListBack;
+import com.poteviohealth.ym.ipos.model.merchant.back.PictureBack;
+import com.poteviohealth.ym.ipos.model.merchant.back.UserSearchBack;
+import com.poteviohealth.ym.ipos.model.merchant.detail.PictureDetail;
+import com.poteviohealth.ym.ipos.model.merchant.detail.UserSearchDetail;
+import lombok.extern.log4j.Log4j2;
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.lang3.ArrayUtils;
 
 import java.lang.reflect.Field;
+import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 /**
  * 请求返回类封装
  * @author Qin
  */
+@Log4j2
 public class YmUtil {
 
     private static final  String SECRETKEY = "test";
 
     private static final  String URL = "https://ipos-sa.imageco.cn";
 
-    public static <T> Object resultBack(T obj, T clazz){
-        try {
+    public static <T> Object resultBack(T obj, T clazz) throws IllegalAccessException {
             Map<String,Object> maps =  YmUtil.findObjectFields(obj,false);
             String sign = generateSign(obj);
-            maps.put("sign", sign);
-            System.out.println(JSONObject.toJSONString(maps));
-            String val = HttpUtils.post(URL, JSONObject.toJSONString(maps));
+            JSONObject object = (JSONObject) JSONObject.toJSON(maps);
+            object.put("sign", sign);
+            String jsonObject = JSONObject.toJSONString(object);
+        log.info(clazz.getClass()+"===="+jsonObject);
+            String val = HttpUtils.post(URL,jsonObject);
+            log.info(clazz.getClass()+"==return=="+val);
+            if(clazz.getClass().toString().contains("UserSearchBack")){
+                return val;
+            }
             return JSONObject.parseObject(val, clazz.getClass());
-        } catch (IllegalAccessException e) {
-            e.printStackTrace();
-        }
-        return null;
     }
 
     private static <T> String generateSign(T obj){
@@ -50,7 +66,7 @@ public class YmUtil {
 
 
     private static <T> Map<String,Object> findObjectFields(T obj,boolean isType) throws IllegalAccessException {
-        Map<String,Object> returnMaps = Maps.newTreeMap();
+        Map<String,Object> returnMaps =Maps.newTreeMap();
         Class clazz = obj.getClass();
 
         Field[] fields = new Field[0];
@@ -65,7 +81,7 @@ public class YmUtil {
             if(fieldValue =="" || fieldValue == null){
                 continue;
             }else if(isType){
-                if(f.getGenericType().getTypeName().contains("com.poteviohealth.ym.model")){
+                if(f.getGenericType().getTypeName().contains("com.poteviohealth.ym.ipos.model")){
                     continue;
                 }
             }
@@ -74,4 +90,26 @@ public class YmUtil {
 
         return returnMaps;
     }
+
+    public static void main(String[] args) {
+
+        UserSearch userSearch = new UserSearch();
+        UserSearchDetail detail = new UserSearchDetail();
+        detail.setPhone("18010031183");
+        userSearch.setMerchant_query_request(detail);
+        UserSearchBack back = null;
+        try {
+            String val = (String) YmUtil.resultBack(userSearch,new UserSearchBack());
+            JSONObject jsonObject = new JSONObject(JSON.parseObject(val));
+            if(val.contains("image_list")){
+                List<ImageListBack> list = jsonObject.getJSONArray("image_list").stream().map(item -> JSON.parseObject(item.toString(), new TypeReference<ImageListBack>() {})).collect(Collectors.toList());
+                jsonObject.put("image_list",list);
+            }
+
+            back = JSONObject.toJavaObject(jsonObject, UserSearchBack.class);
+        } catch (IllegalAccessException e) {
+            e.printStackTrace();
+        }
+        System.out.println(JSONObject.toJSONString(back));
+    }
 }