✨ feat: 新增商户上报
This commit is contained in:
parent
c58c1c4f79
commit
a783378148
|
@ -970,8 +970,13 @@ export const resendCardCode = (data) => {
|
|||
}
|
||||
|
||||
/* 设置开发信息 */
|
||||
export const setResellMerchant = (data) => {
|
||||
return req("post", baseurl + "/reseller/resellMerchant/set", data)
|
||||
export const setResellMerchant = (id, data) => {
|
||||
return req("put", baseurl + `/reseller/merchant/${id}`, data)
|
||||
}
|
||||
|
||||
/* 获取开发信息密钥 */
|
||||
export const generateRsaKey = () => {
|
||||
return req("get", baseurl + "/reseller/merchant/generateRsaKey")
|
||||
}
|
||||
|
||||
/* 设置分销商通知地址 */
|
||||
|
|
|
@ -35,13 +35,13 @@ const Column = [
|
|||
type: "normal",
|
||||
width: "20%"
|
||||
},
|
||||
// {
|
||||
// title: "商户编号",
|
||||
// name: "merchant",
|
||||
// prop: "merchant[merchant_id]",
|
||||
// type: "normal",
|
||||
// width: "20%"
|
||||
// },
|
||||
{
|
||||
title: "商户编号",
|
||||
name: "merchant",
|
||||
prop: "merchant[merchant_id]",
|
||||
type: "normal",
|
||||
width: "20%"
|
||||
},
|
||||
{
|
||||
title: "分销商名称",
|
||||
prop: "name",
|
||||
|
@ -240,7 +240,7 @@ export default class acclist extends React.Component {
|
|||
},
|
||||
{
|
||||
path: "distributor-merchant",
|
||||
name: "开放信息"
|
||||
name: "更新商户"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@ -311,11 +311,18 @@ export default class acclist extends React.Component {
|
|||
}
|
||||
|
||||
onMenuItemClick(e, key, row) {
|
||||
if (key == 1) {
|
||||
//重置密码
|
||||
this.setState({ pwdVisible: true, resellid: row.id })
|
||||
} else if (key == 2) {
|
||||
this.setState({ logVisible: true })
|
||||
switch (Number(key)) {
|
||||
case 1:
|
||||
this.setState({ pwdVisible: true, resellid: row.id })
|
||||
break
|
||||
case 2:
|
||||
this.setState({ logVisible: true })
|
||||
break
|
||||
case 3:
|
||||
this.openInformation(row)
|
||||
break
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -486,15 +493,6 @@ export default class acclist extends React.Component {
|
|||
>
|
||||
编辑
|
||||
</a>
|
||||
{/* <a
|
||||
className="grid-link"
|
||||
onClick={(e) => {
|
||||
this.openInformation(rowData)
|
||||
}}
|
||||
>
|
||||
开放信息
|
||||
</a> */}
|
||||
|
||||
<a
|
||||
className="grid-link"
|
||||
onClick={(e) => {
|
||||
|
@ -517,6 +515,7 @@ export default class acclist extends React.Component {
|
|||
}}
|
||||
>
|
||||
<MenuItem key="1">重置密码</MenuItem>
|
||||
<MenuItem key="3">更新商户</MenuItem>
|
||||
{/* <MenuItem key="2"> 日志</MenuItem> */}
|
||||
</Menu>
|
||||
</DropdownContent>
|
||||
|
|
|
@ -1,33 +1,39 @@
|
|||
import FormItem from "@/components/form-item/main"
|
||||
import Form from "@/components/form/main"
|
||||
import Ipt from "@/components/input/main"
|
||||
import { omit } from "lodash-es"
|
||||
import { cloneDeep, omit } from "lodash-es"
|
||||
import { useEffect, useRef, useState } from "react"
|
||||
import { Button, Card, Checkbox, CopyButton, Input, Notify, Radio, RadioGroup } from "zent"
|
||||
import { setResellMerchant } from "@/assets/api"
|
||||
import { Button, Card, Checkbox, Input, Notify, Radio, RadioGroup } from "zent"
|
||||
import { setResellMerchant, generateRsaKey } from "@/assets/api"
|
||||
import "./index"
|
||||
export default function Merchant() {
|
||||
const [state, setState] = useState({
|
||||
reseller_id: "",
|
||||
merchant_id: "",
|
||||
marketing_notify_url: [""],
|
||||
custom_rsa_public_key: "",
|
||||
encrypt_type: 2,
|
||||
subscribe_event: [],
|
||||
loading: false
|
||||
loading: false,
|
||||
reseller_id: 0 /* 分销商id */,
|
||||
merchant_id: "", //商户号 *
|
||||
pos_id: "", //平台id 目前都是单平台 *
|
||||
app_id: "", //appid。目前都是单应用, *
|
||||
store_id: "", //api mode 为1时不传 为2时必传* 店铺id
|
||||
public_key: "", //私钥 *
|
||||
private_key: "", //公钥 *
|
||||
merchant_public_key: "", //商户公钥 *
|
||||
secret_key: "", //api mode 为1时不传 为2时必传* 偏移量
|
||||
notify_url: "", //事件通知地址 *
|
||||
subscribe_event: [], //事件类型 数组
|
||||
status: 1, //状态 1正常 2禁用 *
|
||||
api_mode: 2 //对接类型 1-RSA+标准接口返回 【默认】2-兴业银行模式 *
|
||||
})
|
||||
const fromRef = useRef()
|
||||
const rules = {
|
||||
merchant_id: [
|
||||
{ type: "required", message: "请输入商户编号" },
|
||||
{
|
||||
type: "regExp",
|
||||
message: "请输入正确的商户号",
|
||||
reg: /^[A-Za-z0-9]+$/
|
||||
}
|
||||
],
|
||||
custom_rsa_public_key: [{ type: "required", message: "请输入商户侧RSA公钥" }],
|
||||
marketing_notify_url: [
|
||||
merchant_id: [{ type: "required", message: "请输入商户编号" }],
|
||||
public_key: [{ type: "required", message: "请输入公钥" }],
|
||||
private_key: [{ type: "required", message: "请输入私钥" }],
|
||||
app_id: [{ type: "required", message: "请输入应用ID" }],
|
||||
pos_id: [{ type: "required", message: "请输入平台ID" }],
|
||||
store_id: [{ type: "required", message: "请输入店铺ID" }],
|
||||
secret_key: [{ type: "required", message: "请输入偏移量" }],
|
||||
merchant_public_key: [{ type: "required", message: "请输入商户公钥" }],
|
||||
notify_url: [
|
||||
{ type: "required", message: "请输入商户回调通知网关地址" },
|
||||
{
|
||||
type: "regExp",
|
||||
|
@ -39,36 +45,44 @@ export default function Merchant() {
|
|||
|
||||
useEffect(() => {
|
||||
const { merchant, id } = JSON.parse(sessionStorage.getItem("merchant"))
|
||||
setState({ ...state, reseller_id: id, ...merchant })
|
||||
const cloneState = cloneDeep(state)
|
||||
for (let key in cloneState) {
|
||||
cloneState[key] = merchant[key]
|
||||
}
|
||||
setState({ ...state, reseller_id: id, ...cloneState })
|
||||
}, [])
|
||||
|
||||
/* 获取密钥 */
|
||||
function getKey() {
|
||||
generateRsaKey().then(({ data }) => {
|
||||
setState({ ...state, ...data })
|
||||
})
|
||||
}
|
||||
|
||||
/* 提交 */
|
||||
function submit() {
|
||||
const valid = fromRef.current.validator()
|
||||
if (valid) {
|
||||
setState({ loading: true })
|
||||
const data = omit(state, [
|
||||
"create_time",
|
||||
"id",
|
||||
"status",
|
||||
"update_time",
|
||||
"rsa_private_key",
|
||||
"rsa_public_key",
|
||||
"loading"
|
||||
])
|
||||
setResellMerchant(data).then(({ code, message }) => {
|
||||
if (code === 200) {
|
||||
const data = omit(state, ["reseller_id", "loading"])
|
||||
setResellMerchant(state.reseller_id, data)
|
||||
.then(({ code, message }) => {
|
||||
if (code === 200) {
|
||||
Notify.success("保存成功")
|
||||
let clr = setTimeout(() => {
|
||||
window.history.go(-1)
|
||||
setState({ loading: false })
|
||||
clearTimeout(clr)
|
||||
}, 1000)
|
||||
} else {
|
||||
setState({ loading: false })
|
||||
Notify.success(message)
|
||||
}
|
||||
})
|
||||
.catch(({ message }) => {
|
||||
setState({ loading: false })
|
||||
Notify.success(message)
|
||||
let clr = null
|
||||
clr = setTimeout(() => {
|
||||
window.history.go(-1)
|
||||
clearTimeout(clr)
|
||||
}, 1000)
|
||||
} else {
|
||||
Notify.success(message)
|
||||
}
|
||||
setState({ loading: false })
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -77,7 +91,7 @@ export default function Merchant() {
|
|||
<Card style={{ width: "100%" }} title={"更新信息"}>
|
||||
<div className="adddistributor merchantForm">
|
||||
<Form model={state} rules={rules} ref={fromRef}>
|
||||
<FormItem labelname="商户编号" required="">
|
||||
<FormItem labelname="商户编号" prop="merchant_id">
|
||||
<Ipt
|
||||
onChange={(value) => setState({ ...state, merchant_id: value })}
|
||||
onClearItem={() => setState({ ...state, merchant_id: "" })}
|
||||
|
@ -91,12 +105,112 @@ export default function Merchant() {
|
|||
alignment={"left"}
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem labelname="商户回调通知网关地址" prop="marketing_notify_url">
|
||||
<FormItem labelname="平台ID" prop="pos_id">
|
||||
<Ipt
|
||||
onChange={(value) => setState({ ...state, marketing_notify_url: value })}
|
||||
onClearItem={() => setState({ ...state, marketing_notify_url: "" })}
|
||||
onChange={(value) => setState({ ...state, pos_id: value })}
|
||||
onClearItem={() => setState({ ...state, pos_id: "" })}
|
||||
countShow={false}
|
||||
value={state.marketing_notify_url}
|
||||
value={state.pos_id}
|
||||
placeholder={"请输入平台ID"}
|
||||
labelWidth={"0px"}
|
||||
maxLength={20}
|
||||
height={"36px"}
|
||||
width={"520px"}
|
||||
alignment={"left"}
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem labelname="APP-ID" prop="app_id">
|
||||
<Ipt
|
||||
onChange={(value) => setState({ ...state, app_id: value })}
|
||||
onClearItem={() => setState({ ...state, app_id: "" })}
|
||||
countShow={false}
|
||||
value={state.app_id}
|
||||
placeholder={"请输入APPID"}
|
||||
labelWidth={"0px"}
|
||||
maxLength={20}
|
||||
height={"36px"}
|
||||
width={"520px"}
|
||||
alignment={"left"}
|
||||
/>
|
||||
</FormItem>
|
||||
|
||||
{state.api_mode === 2 ? (
|
||||
<FormItem labelname="店铺ID" prop="store_id">
|
||||
<Ipt
|
||||
onChange={(value) => setState({ ...state, store_id: value })}
|
||||
onClearItem={() => setState({ ...state, store_id: "" })}
|
||||
countShow={false}
|
||||
value={state.store_id}
|
||||
placeholder={"请输入店铺ID"}
|
||||
labelWidth={"0px"}
|
||||
maxLength={20}
|
||||
height={"36px"}
|
||||
width={"520px"}
|
||||
alignment={"left"}
|
||||
/>
|
||||
</FormItem>
|
||||
) : null}
|
||||
{state.api_mode === 2 ? (
|
||||
<FormItem labelname="偏移量" prop="secret_key">
|
||||
<Ipt
|
||||
onChange={(value) => setState({ ...state, secret_key: value })}
|
||||
onClearItem={() => setState({ ...state, secret_key: "" })}
|
||||
countShow={false}
|
||||
value={state.secret_key}
|
||||
placeholder={"请输入偏移量"}
|
||||
labelWidth={"0px"}
|
||||
maxLength={20}
|
||||
height={"36px"}
|
||||
width={"520px"}
|
||||
alignment={"left"}
|
||||
/>
|
||||
</FormItem>
|
||||
) : null}
|
||||
|
||||
<FormItem labelname="私钥" prop="private_key">
|
||||
<Input
|
||||
type="textarea"
|
||||
onChange={({ target }) => setState({ ...state, private_key: target.value })}
|
||||
value={state.private_key}
|
||||
placeholder={"请输入私钥"}
|
||||
labelWidth={"0px"}
|
||||
width={"520px"}
|
||||
alignment={"left"}
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem labelname="公钥" prop="public_key">
|
||||
<Input
|
||||
type="textarea"
|
||||
onChange={({ target }) => setState({ ...state, public_key: target.value })}
|
||||
value={state.public_key}
|
||||
placeholder={"请输入公钥"}
|
||||
labelWidth={"0px"}
|
||||
width={"520px"}
|
||||
alignment={"left"}
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem labelname="" required="">
|
||||
<Button type="primary" onClick={getKey}>
|
||||
重新获取密钥
|
||||
</Button>
|
||||
</FormItem>
|
||||
<FormItem labelname="商户公钥" prop="merchant_public_key">
|
||||
<Input
|
||||
type="textarea"
|
||||
onChange={({ target }) => setState({ ...state, merchant_public_key: target.value })}
|
||||
value={state.merchant_public_key}
|
||||
placeholder={"请输入商户公钥"}
|
||||
labelWidth={"0px"}
|
||||
width={"520px"}
|
||||
alignment={"left"}
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem labelname="商户回调通知网关地址" prop="notify_url">
|
||||
<Ipt
|
||||
onChange={(value) => setState({ ...state, notify_url: value })}
|
||||
onClearItem={() => setState({ ...state, notify_url: "" })}
|
||||
countShow={false}
|
||||
value={state.notify_url}
|
||||
placeholder={"请输入网关地址"}
|
||||
labelWidth={"0px"}
|
||||
height={"36px"}
|
||||
|
@ -104,77 +218,22 @@ export default function Merchant() {
|
|||
alignment={"left"}
|
||||
/>
|
||||
</FormItem>
|
||||
{state.rsa_public_key ? (
|
||||
<FormItem labelname="营销系统RSA公钥" prop="rsa_public_key">
|
||||
<div className="phonet">
|
||||
<Ipt
|
||||
countShow={false}
|
||||
value={state.rsa_public_key}
|
||||
disabled
|
||||
labelWidth={"0px"}
|
||||
height={"36px"}
|
||||
width={"520px"}
|
||||
alignment={"left"}
|
||||
/>
|
||||
<CopyButton
|
||||
text={state.rsa_public_key}
|
||||
onCopySuccess={() => {
|
||||
Notify.clear()
|
||||
Notify.success("复制成功!")
|
||||
}}
|
||||
>
|
||||
<Button type="info">复制RSA公钥</Button>
|
||||
</CopyButton>
|
||||
</div>
|
||||
</FormItem>
|
||||
) : null}
|
||||
{state.rsa_private_key ? (
|
||||
<FormItem labelname="营销系统RSA私钥" prop="rsa_private_key">
|
||||
<div className="phonet">
|
||||
<Ipt
|
||||
countShow={false}
|
||||
value={state.rsa_private_key}
|
||||
disabled
|
||||
labelWidth={"0px"}
|
||||
height={"36px"}
|
||||
width={"520px"}
|
||||
alignment={"left"}
|
||||
/>
|
||||
{state.rsa_private_key ? (
|
||||
<CopyButton
|
||||
text={state.rsa_private_key}
|
||||
onCopySuccess={() => {
|
||||
Notify.clear()
|
||||
Notify.success("复制成功!")
|
||||
}}
|
||||
>
|
||||
<Button type="info">复制RSA私钥</Button>
|
||||
</CopyButton>
|
||||
) : null}
|
||||
</div>
|
||||
</FormItem>
|
||||
) : null}
|
||||
<FormItem labelname="商户侧RSA公钥" prop="custom_rsa_public_key">
|
||||
<Input
|
||||
type="textarea"
|
||||
autoSize
|
||||
onChange={({ target }) =>
|
||||
setState({ ...state, custom_rsa_public_key: target.value })
|
||||
}
|
||||
value={state.custom_rsa_public_key}
|
||||
placeholder={"请输入商户侧RSA公钥"}
|
||||
labelWidth={"0px"}
|
||||
width={"520px"}
|
||||
alignment={"left"}
|
||||
/>
|
||||
</FormItem>
|
||||
<FormItem labelname="加密算法" prop="encrypt_type">
|
||||
<FormItem labelname="商户状态">
|
||||
<RadioGroup
|
||||
onChange={({ target }) => setState({ ...state, encrypt_type: target.value })}
|
||||
value={state.encrypt_type}
|
||||
onChange={({ target }) => setState({ ...state, status: target.value })}
|
||||
value={state.status}
|
||||
>
|
||||
<Radio value={2}>RSA</Radio>
|
||||
<Radio value={1}>定制算法</Radio>
|
||||
<Radio value={1}>正常</Radio>
|
||||
<Radio value={2}>禁用</Radio>
|
||||
</RadioGroup>
|
||||
</FormItem>
|
||||
<FormItem labelname="对接类型" prop="api_mode">
|
||||
<RadioGroup
|
||||
onChange={({ target }) => setState({ ...state, api_mode: target.value })}
|
||||
value={state.api_mode}
|
||||
>
|
||||
<Radio value={2}>兴业银行模式</Radio>
|
||||
<Radio value={1}>RSA模式</Radio>
|
||||
</RadioGroup>
|
||||
</FormItem>
|
||||
<FormItem labelname="订阅事件" prop="subscribe_event" required="">
|
||||
|
|
Loading…
Reference in New Issue