Commit 933b48cb authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix:处理新增采购订单数据显示异常,订单支付开通授信支付

parent 49cb48c7
......@@ -103,6 +103,7 @@ export const CREDIT_INNER_STATUS_BADGE_MAP = {
'6': { title: '支付中', type: 'processing' },
'7': { title: '支付失败', type: 'danger' },
'8': { title: '确认到账', type: 'success' },
'9': { title: '支付成功', type: 'success' },
}
// 流转状态
......
......@@ -126,7 +126,7 @@ const PositionSetting:React.FC<PositionSettingProps> = (props) => {
const fetchProductList = async (params) => {
const shopType = addSchemaAction.getFieldValue('shopType')
const res = await PublicApi.getProductCommodityCommonGetCommodityListBySeller({
const res = await PublicApi.getProductCommodityCommonGetCommodityListByStock({
...params,
shopType,
environment: 1,
......@@ -245,12 +245,12 @@ const PositionSetting:React.FC<PositionSettingProps> = (props) => {
const fetchMemberList = async (params) => {
const shopType = addSchemaAction.getFieldValue('shopType');
// 当商城类型为 渠道商城、渠道自由商城和渠道积分商城时,需要带上下面两个参数
const { channelMemberIdList, channelMemberRoleId } = productState;
const { channelMemberIdList, channelMemberRoleIdList } = productState;
const data = {
...params,
shopType: shopType,
memberIds: channelMemberIdList,
// roleId: channelMemberRoleId
roleIds: channelMemberRoleIdList
}
const res = await PublicApi.postMemberManageAllPageByshoptype(data, {ctlType: 'none'});
return res.data
......
......@@ -76,11 +76,15 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => {
const { run, loading } = useHttpRequest(PublicApi.postOrderPendingOrderPay)
const [visible, setVisible] = useState(false)
const [checked, setChecked] = useState<any>({})
const [current, setCurrent] = useState(0) // 0选择方式 1线下支付方式 2授信支付 3余额支付 1000清除
const [current, setCurrent] = useState(0) // 0选择方式 1线下支付方式 2授信支付 3余额支付 4微信支付 1000清除
const [payStep, setPayStep] = useState(0) // 支付模态框的步骤 0选方式 1下一步的具体操作 2输入支付密码
const [code, setCode] = useState('')
const [number, setNumber] = useState([0,1,2,3,4,5])
const { currentRef, confirm } = props
const [currentPayInfo, setCurrentPayInfo] = useState<any>()
const [creditInfo, setCreditInfo] = useState<any>()
const [balanceInfo, setBalanceInfo] = useState<any>()
useEffect(() => {
if (currentRef) {
currentRef.current = {
......@@ -98,19 +102,43 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => {
}
}, [visible])
const handleConfirm = async () => {
const handleConfirm = () => {
console.log(data,'data')
if (current === 0) {
if (checked.id) {
if (checked.id === 5) { // 线下支付
setCurrent(1)
setPayStep(1)
} else if (checked.id === 6) { // 授信额度支付
console.log('选择了授信支付')
PublicApi.getPayCreditGetCredit({parentMemberId: data.supplyMembersId, parentMemberRoleId: data.supplyMembersRoleId}).then(res => {
if(res.code === 1000) {
setCreditInfo(res.data)
} else {
message.error(res.message)
}
})
setCurrent(2)
setPayStep(1)
} else if (checked.id === 4) {
} else if (checked.id === 4) { // 余额支付
console.log('选择了余额支付')
PublicApi.getPayAssetAccountGetUserBalance({parentMemberId: data.supplyMembersId, parentMemberRoleId: data.supplyMembersRoleId}).then(res => {
if(res.code === 1000) {
setBalanceInfo(res.data)
} else {
message.error(res.message)
}
})
setCurrent(3)
setPayStep(1)
} else {
}
// else if(checked.id === 2) {
// console.log('选择了微信支付')
// setCurrent(4)
// setPayStep(1)
// handleSubmitPay()
// }
else {
message.error('暂只支持线下支付、授信额度支付、余额支付方式')
}
} else {
......@@ -118,7 +146,7 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => {
}
return;
}
// console.log(confirm, current, payStep, '119')
let payPrice = data.paymentInformationResponses.filter(item => item.id === Number(currentPayInfoId))[0].payPrice
// 开始提交线下支付数据
if(current === 1) {
const payOrderUrls = formRef.current.urlList
......@@ -131,33 +159,25 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => {
message.error('未选择支付方式')
return;
}
// 当前选中的支付信息
let PayInfoObj = data.paymentInformationResponses.filter(item => item.id === Number(currentPayInfoId))[0]
const params = {
id: Number(id),
payOrderUrls: payOrderUrls.join(','),
paymentInformationId: PayInfoObj.id,
payTypeId: PayInfoObj.channel,
// // 预留
// payPassword,
// remark
}
const { code } = await run(params)
if (code === 1000) {
history.goBack()
}
handleSubmitPay()
} else if (current === 2) {
// 开始提交授信支付数据 (需要输入支付密码)
console.log('开始提交授信支付数据')
setPayStep(2)
setCurrent(1000)
console.log('开始提交授信支付数据', payPrice)
if(payPrice <= creditInfo.canUseQuota){
setPayStep(2)
setCurrent(1000)
} else {
message.error('您的授信可用额度不足')
}
} else if(current === 3) {
// 开始提交余额支付数据 (需要输入支付密码)
console.log('开始提交余额支付数据')
setPayStep(2)
setCurrent(1000)
console.log('开始提交余额支付数据', payPrice)
if(payPrice <= balanceInfo){
setPayStep(2)
setCurrent(1000)
} else {
message.error('您的账户余额不足')
}
}
confirm && confirm()
......@@ -172,6 +192,36 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => {
}
}
const handleSubmitPay = async () => {
const payOrderUrls = formRef.current.urlList
// 当前选中的支付信息
let PayInfoObj = data.paymentInformationResponses.filter(item => item.id === Number(currentPayInfoId))[0]
let params: any = {
id: Number(id),
paymentInformationId: PayInfoObj.id,
payTypeId: checked.id,
}
if(payStep === 2) {
if(code.length != number.length){
return message.error('请输入支付密码')
}
params.payPassword = code
} else if(current === 1) {
params.payOrderUrls = payOrderUrls.join(',')
}
const res = await run(params)
if (res.code === 1000) {
if(current != 4) {
history.goBack()
} else {
console.log(res, '二维码信息')
}
}
}
const handleUploadChange = (e) => {
const { fileList } = e
const urlList = fileList.map(v => v.response && v.response.code === 1000 ? v.response.data : '')
......@@ -193,10 +243,6 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => {
setCode(v)
}
useEffect(() => {
console.log(code)
}, [code])
const renderModalFooter = () => {
let footer = null;
if(current){
......@@ -211,7 +257,7 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => {
]
} else if (payStep === 2) {
footer = [
<Button key="submit" type="primary" loading={loading} onClick={handleConfirm} style={{width: '100%'}}>
<Button key="submit" type="primary" loading={loading} onClick={handleSubmitPay} style={{width: '100%'}}>
确认支付
</Button>
]
......@@ -288,7 +334,7 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => {
可用授信额度(元):
</span>
<span className={style.amount}>
30,000.00
{creditInfo?.canUseQuota?.toFixed(2)}
</span>
</p>
<p>
......@@ -296,7 +342,7 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => {
总授信额度(元):
</span>
<span className={cx(style.amount, style.amount1)}>
500,000.00
{creditInfo?.quota?.toFixed(2)}
</span>
</p>
<p>
......@@ -304,7 +350,7 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => {
已用授信额度(元):
</span>
<span className={cx(style.amount, style.amount1)}>
20,000.00
{creditInfo?.useQuota?.toFixed(2)}
</span>
</p>
<p>
......@@ -312,7 +358,7 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => {
本次需支付(元):
</span>
<span className={cx(style.amount, style.amount2)}>
48,000.00
{data?.paymentInformationResponses?.filter(item => item.id === Number(currentPayInfoId))[0]?.payPrice?.toFixed(2)}
</span>
</p>
</div>
......@@ -327,7 +373,7 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => {
账户可用余额(元):
</span>
<span className={style.amount}>
500,000.00
{balanceInfo?.toFixed(2)}
</span>
</p>
<p>
......@@ -335,11 +381,21 @@ const OrderPayModal: React.FC<OrderPayModalProps> = (props) => {
本次需支付(元):
</span>
<span className={cx(style.amount, style.amount2)}>
48,000.00
{data?.paymentInformationResponses?.filter(item => item.id === Number(currentPayInfoId))[0]?.payPrice?.toFixed(2)}
</span>
</p>
</div>
}
{/* 微信扫码支付 */}
{
current === 4 &&
<div>
<p>微信扫码支付</p>
<div>
</div>
</div>
}
{/* 输入支付密码 payStep===2 */}
{
payStep === 2 &&
......
......@@ -339,8 +339,8 @@ const OrderProductTable:React.FC<OrderProductTableProps> = ({editable}) => {
dataIndex: 'logistics',
align: 'center',
key: 'logistics',
render: (text) => (text && text && text.deliveryType === 2) ?
<AddressPop pickInfo={text}>{DELIVERY_TYPE[text.deliveryType]}</AddressPop> : DELIVERY_TYPE[text.deliveryType]
render: (text) => (text && text.deliveryType && text.deliveryType === 2) ?
<AddressPop pickInfo={text}>{DELIVERY_TYPE[text.deliveryType]}</AddressPop> : DELIVERY_TYPE[text?.deliveryType]
}
]
......
......@@ -393,8 +393,8 @@ const SaleOrderProductTable:React.FC<OrderProductTableProps> = (props) => {
dataIndex: 'logistics',
align: 'center',
key: 'logistics',
render: (text) => (text && text && text.deliveryType === 2) ?
<AddressPop pickInfo={text}>{DELIVERY_TYPE[text.deliveryType]}</AddressPop> : DELIVERY_TYPE[text.deliveryType]
render: (text) => (text && text.deliveryType && text.deliveryType === 2) ?
<AddressPop pickInfo={text}>{DELIVERY_TYPE[text.deliveryType]}</AddressPop> : DELIVERY_TYPE[text?.deliveryType]
},
{
title: '仓位库存扣减记录',
......
......@@ -265,9 +265,9 @@ export const productInfoColumns: any[] = [
},
{
title: '单价(元)',
dataIndex: 'unitPrice',
dataIndex: 'price',
align: 'left',
key: 'unitPrice',
key: 'price',
render: text => <PriceComp priceSection={text}/>
},
{
......@@ -305,7 +305,14 @@ export const productInfoColumns: any[] = [
dataIndex: 'logistics',
align: 'center',
key: 'logistics',
render: text => (text && text.render) || ''
render: (t, r) => {
if(r.logistics?.deliveryType === 1)
return "物流(默认)"
else if(r.logistics?.deliveryType === 2)
return "自提"
else if(r.logistics?.deliveryType === 3)
return "无需配送"
}
},
{
title: '操作',
......
......@@ -87,7 +87,6 @@ export const useEditHideField = () => {
export const useProductTableChangeForPay = (ctx: ISchemaFormActions | ISchemaFormAsyncActions, update) => {
FormEffectHooks.onFieldValueChange$('orderProductRequests').subscribe(state => {
const { value } = state
console.log(value)
const payInfoData = ctx.getFieldValue('paymentInformationResponses')
// 强制渲染一次, 用于触发金额总数
update()
......
......@@ -181,6 +181,7 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
v.isMemberPrice = Number(v.isMemberPrice)
v.memberPrice = parseInt(v.memberPrice)
v.imgUrl = v.mainPic
v.minOrder = v.minOrder
// v.productId = v.id
// v.productName = v.name
// v.category = v.customerCategoryName
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment