master
yuan 7 years ago
parent 7b563647f4
commit 511faafdda

@ -5,6 +5,7 @@ import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper;
import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; import cn.yixblog.support.mybatis.autosql.annotations.AutoSql;
import cn.yixblog.support.mybatis.autosql.annotations.SqlType; import cn.yixblog.support.mybatis.autosql.annotations.SqlType;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import javax.validation.constraints.Max; import javax.validation.constraints.Max;
@ -16,11 +17,9 @@ import java.util.List;
@AutoMapper(tablename = "sys_wx_merchant_apply",pkName = "merchant_app_id") @AutoMapper(tablename = "sys_wx_merchant_apply",pkName = "merchant_app_id")
public interface SysWxMerchantApplyMapper { public interface SysWxMerchantApplyMapper {
@AutoSql(type = SqlType.SELECT) @AutoSql(type = SqlType.SELECT)
List<JSONObject> listWxMerchantApplices(@Param("client_id") int client_id); List<JSONObject> listWxMerchantApplices(@Param("client_id") int client_id, PageBounds pageBounds);
@AutoSql(type = SqlType.INSERT) @AutoSql(type = SqlType.INSERT)
void insertWxMerchantApply(JSONObject params); void insertWxMerchantApply(JSONObject params);
@AutoSql(type = SqlType.UPDATE)
void updateWxMerchantApply(JSONObject params);
} }

@ -17,6 +17,10 @@ public class SubMerchantIdApply {
@JSONField(name = "company_name") @JSONField(name = "company_name")
private String merchant_name; private String merchant_name;
@NotBlank(message = "error.payment.valid.param_missing") @NotBlank(message = "error.payment.valid.param_missing")
@Length(max = 10)
@JSONField(name = "merchant_id")
private String merchant_id;
@NotBlank(message = "error.payment.valid.param_missing")
@Length(max = 20) @Length(max = 20)
@JSONField(name = "short_name") @JSONField(name = "short_name")
private String merchant_shortname; private String merchant_shortname;
@ -84,6 +88,14 @@ public class SubMerchantIdApply {
return this.merchant_name; return this.merchant_name;
} }
public String getMerchant_id() {
return merchant_id;
}
public void setMerchant_id(String merchant_id) {
this.merchant_id = merchant_id;
}
public void setMerchant_name(String merchant_name) { public void setMerchant_name(String merchant_name) {
this.merchant_name = merchant_name; this.merchant_name = merchant_name;
} }

@ -270,5 +270,7 @@ public interface ClientManager {
void subMerchantApplication(String clientMoniker, SubMerchantIdApply subMerchantApply,JSONObject manager); void subMerchantApplication(String clientMoniker, SubMerchantIdApply subMerchantApply,JSONObject manager);
List<JSONObject> listMerchantIds(String clientMoniker,JSONObject manager);
void clearCacheSubMerchantIdApplices(String clientMoniker); void clearCacheSubMerchantIdApplices(String clientMoniker);
} }

@ -1,6 +1,7 @@
package au.com.royalpay.payment.manage.merchants.core.impls; package au.com.royalpay.payment.manage.merchants.core.impls;
import au.com.royalpay.payment.channels.wechat.config.WeChatPayConfig; import au.com.royalpay.payment.channels.wechat.config.WeChatPayConfig;
import au.com.royalpay.payment.channels.wechat.config.WechatPayEnvironment;
import au.com.royalpay.payment.channels.wechat.runtime.MpPaymentApi; import au.com.royalpay.payment.channels.wechat.runtime.MpPaymentApi;
import au.com.royalpay.payment.channels.wechat.runtime.WxPayClient; import au.com.royalpay.payment.channels.wechat.runtime.WxPayClient;
import au.com.royalpay.payment.channels.wechat.runtime.beans.SubMerchantInfo; import au.com.royalpay.payment.channels.wechat.runtime.beans.SubMerchantInfo;
@ -2938,25 +2939,36 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (client == null) { if (client == null) {
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
List<JSONObject> applices = sysWxMerchantApplyMapper.listWxMerchantApplices(client.getInteger("client_id")); checkOrgPermission(manager, client);
List<JSONObject> applices = sysWxMerchantApplyMapper.listWxMerchantApplices(client.getInteger("client_id"),new PageBounds(Order.formString("create_time.desc")));
if(!applices.isEmpty()){ if(!applices.isEmpty()){
return applices; return applices;
}else { }else {
if(StringUtils.isNotEmpty(client.getString("sub_merchant_id")) && StringUtils.isNotEmpty(client.getString("merchant_id"))){ if(StringUtils.isNotEmpty(client.getString("sub_merchant_id")) && StringUtils.isNotEmpty(client.getString("merchant_id"))){
Element elem = wxPayClient.querySubMerchant(client.getString("merchant_id"),client.getString("sub_merchant_id")); Element elem = wxPayClient.querySubMerchant(client.getString("merchant_id"),client.getString("sub_merchant_id"));
String applicesXml = XmlFormatUtils.formatXml(elem); JSONObject object = new JSONObject();
if(applicesXml != null){ object.put("sub_merchant_id",elem.elementText("sub_mch_id_0"));
return null; object.put("client_id",client.getInteger("client_id"));
} object.put("merchant_name",elem.elementText("merchant_name_0"));
object.put("merchant_shortname",elem.elementText("merchant_shortname_0"));
object.put("office_phone",elem.elementText("office_phone_0"));
object.put("contact_name",elem.elementText("contact_name_0"));
object.put("contact_email",elem.elementText("contact_email_0"));
object.put("contact_phone",elem.elementText("contact_phone_0"));
object.put("business_category",elem.elementText("business_category_0"));
object.put("merchant_remark",elem.elementText("merchant_remark_0"));
object.put("website",elem.elementText("website_0"));
object.put("merchant_introduction",elem.elementText("merchant_introduction_0"));
object.put("merchant_id",client.getString("merchant_id"));
object.put("create_time",new Date());
object.put("operator",manager.getString("display_name"));
sysWxMerchantApplyMapper.insertWxMerchantApply(object);
List<JSONObject> applyQuery = sysWxMerchantApplyMapper.listWxMerchantApplices(client.getInteger("client_id"),new PageBounds(Order.formString("create_time.desc")));
return applyQuery;
} }
} }
return null; return null;
} }
@Override
@CacheEvict(value = ":all_sub_merchant_id_applices:", key = "#clientMoniker")
public void clearCacheSubMerchantIdApplices(String clientMoniker) {
}
@Override @Override
@CacheEvict(value = ":all_sub_merchant_id_applices:", key = "#clientMoniker") @CacheEvict(value = ":all_sub_merchant_id_applices:", key = "#clientMoniker")
public void subMerchantApplication(String clientMoniker, SubMerchantIdApply subMerchantApply,JSONObject manager) { public void subMerchantApplication(String clientMoniker, SubMerchantIdApply subMerchantApply,JSONObject manager) {
@ -2964,19 +2976,42 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (client == null) { if (client == null) {
throw new InvalidShortIdException(); throw new InvalidShortIdException();
} }
if(!StringUtils.isNotEmpty(client.getString("merchant_id"))){ checkOrgPermission(manager, client);
throw new BadRequestException("无Merchant_id");
}
JSONObject params = subMerchantApply.insertObject(); JSONObject params = subMerchantApply.insertObject();
SubMerchantInfo subMerchantInfo = JSONObject.toJavaObject(params,SubMerchantInfo.class); SubMerchantInfo subMerchantInfo = JSONObject.toJavaObject(params,SubMerchantInfo.class);
params.put("merchant_id",client.getString("merchant_id")); params.put("merchant_id",client.getString("merchant_id"));
params.put("client_id",client.getString("client_id")); params.put("client_id",client.getString("client_id"));
params.put("create_time",new Date()); params.put("create_time",new Date());
params.put("operator",manager.getString("manager_id")); params.put("operator",manager.getString("display_name"));
Element elem = wxPayClient.subMerchantApplication(client.getString("merchant_id"),subMerchantInfo); Element elem = wxPayClient.subMerchantApplication(subMerchantApply.getMerchant_id(),subMerchantInfo);
String applicesXml = XmlFormatUtils.formatXml(elem); String sub_merchant_id = elem.elementText("sub_mch_id");
params.put("sub_merchant_id",applicesXml); if(StringUtils.isNotEmpty(sub_merchant_id)){
params.put("sub_merchant_id",sub_merchant_id);
sysWxMerchantApplyMapper.insertWxMerchantApply(params); sysWxMerchantApplyMapper.insertWxMerchantApply(params);
clearCacheSubMerchantIdApplices(clientMoniker); clearCacheSubMerchantIdApplices(clientMoniker);
}else {
throw new BadRequestException();
}
}
@Override
public List<JSONObject> listMerchantIds(String clientMoniker,JSONObject manager) {
JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) {
throw new InvalidShortIdException();
}
checkOrgPermission(manager, client);
List<JSONObject> list = new ArrayList<>();
for (WeChatPayConfig.Merchant mch : WechatPayEnvironment.getEnv().getWechatMerchantConfigs()){
JSONObject merchantIds = new JSONObject();
merchantIds.put("merchant_id",mch.getMerchantId());
list.add(merchantIds);
}
return list;
}
@Override
@CacheEvict(value = ":all_sub_merchant_id_applices:", key = "#clientMoniker")
public void clearCacheSubMerchantIdApplices(String clientMoniker) {
} }
} }

@ -492,4 +492,9 @@ public class PartnerManageController {
public void subMerchantApplication(@PathVariable String clientMoniker, @RequestBody SubMerchantIdApply subMerchantIdApply, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { public void subMerchantApplication(@PathVariable String clientMoniker, @RequestBody SubMerchantIdApply subMerchantIdApply, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
clientManager.subMerchantApplication(clientMoniker,subMerchantIdApply,manager); clientManager.subMerchantApplication(clientMoniker,subMerchantIdApply,manager);
} }
@ManagerMapping(value = "/{clientMoniker}/get_merchant_ids",method = RequestMethod.GET,role = {ManagerRole.OPERATOR,ManagerRole.ADMIN})
public List<JSONObject> getMerchantIds(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
return clientManager.listMerchantIds(clientMoniker,manager);
}
} }

@ -2589,7 +2589,10 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter
resolve: { resolve: {
subMerchantInfo:function () { subMerchantInfo:function () {
return $scope.partner; return $scope.partner;
} },
merchantIds: ['$http', '$stateParams', function ($http) {
return $http.get('/sys/partners/'+ $scope.partner.client_moniker +'/get_merchant_ids');
}]
} }
}).result.then(function () { }).result.then(function () {
$scope.loadSubMerchantInfos(); $scope.loadSubMerchantInfos();
@ -2597,9 +2600,10 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter
}; };
$scope.loadSubMerchantInfos(); $scope.loadSubMerchantInfos();
}]); }]);
app.controller('applySubMerchantIdCtrl', ['$scope', '$http', '$uibModal','$state','subMerchantInfo', '$filter', function ($scope, $http, $uibModal, $state, subMerchantInfo,$filter) { app.controller('applySubMerchantIdCtrl', ['$scope', '$http', '$uibModal','$state','subMerchantInfo', '$filter','merchantIds', function ($scope, $http, $uibModal, $state, subMerchantInfo,$filter,merchantIds) {
$scope.wxIndustries = angular.copy(wxMerchantIndustries); $scope.wxIndustries = angular.copy(wxMerchantIndustries);
$scope.subMerchantInfo = angular.copy(subMerchantInfo); $scope.subMerchantInfo = angular.copy(subMerchantInfo);
$scope.merchantIds = merchantIds.data;
$scope.subMerchantInfo.industry = $filter('wxindustries')($scope.subMerchantInfo.industry); $scope.subMerchantInfo.industry = $filter('wxindustries')($scope.subMerchantInfo.industry);
$scope.saveAppliy = function (form) { $scope.saveAppliy = function (form) {
$scope.errmsg = null; $scope.errmsg = null;

@ -19,6 +19,26 @@
</div> </div>
</div> </div>
</div> </div>
<div class="form-group"
ng-class="{'has-error':subForm.merchant_id.$invalid && subForm.merchant_id.$dirty}">
<label class="control-label col-sm-3" for="business_category_input">* Merchant ID</label>
<div class="col-sm-8">
<select class="form-control" name="merchant_id"
ng-model="subMerchantInfo.merchant_id"
id="merchant_id_input" required
ng-options="merchant_id.merchant_id as merchant_id.merchant_id for merchant_id in merchantIds">
<option value="">Please Choose</option>
</select>
<div ng-messages="subForm.merchant_id.$error" ng-if="subForm.merchant_id.$dirty">
<p class="small text-danger" ng-message="required">Required Field</p>
</div>
</div>
<div ng-messages="subForm.business_category.$error" ng-if="subForm.business_category.$dirty">
<p class="small text-danger" ng-message="maxLength">More than 50</p>
</div>
</div>
<div class="form-group" <div class="form-group"
ng-class="{'has-error':subForm.merchant_shortname.$invalid && subForm.merchant_shortname.$dirty}"> ng-class="{'has-error':subForm.merchant_shortname.$invalid && subForm.merchant_shortname.$dirty}">
<label class="control-label col-sm-3" for="merchant_shortname_input">* Merchant Short Name</label> <label class="control-label col-sm-3" for="merchant_shortname_input">* Merchant Short Name</label>

@ -18,8 +18,8 @@
<div class="box-body col-sm-6" ng-repeat="id_apply in subMerchantInfos"> <div class="box-body col-sm-6" ng-repeat="id_apply in subMerchantInfos">
<ul class="list-group"> <ul class="list-group">
<li class="list-group-item list-group-item-success"> <li class="list-group-item list-group-item-success">
Sub Merchant Id <b>Sub Merchant Id</b>
<span style="float: right" ng-bind="id_apply.sub_merchant_id"></span> <b style="float: right" ng-bind="id_apply.sub_merchant_id"></b>
</li> </li>
<li class="list-group-item list-group-item-success"> <li class="list-group-item list-group-item-success">
Apply Time Apply Time

Loading…
Cancel
Save