Commit 06a5db57 authored by GuanHua's avatar GuanHua

fix: 生成电子合同接口添加参数

parent 0e814124
import React from 'react'
import styles from './index.less'
import { LAYOUT_TYPE } from '@/constants'
import ImageBox from '@/components/ImageBox'
import { GlobalConfig } from '@/global/config'
interface ShopHeaderPropsType {
......@@ -35,7 +36,7 @@ const CommonHeader: React.FC<ShopHeaderPropsType> = (props) => {
<div className={styles.common_header_container}>
<div className={styles.logo}>
<a href={getLink()}>
<img src={logoUrl} />
<ImageBox width={145} height={50} imgUrl={logoUrl} />
</a>
</div>
<div className={styles.common_header_split}></div>
......
......@@ -4,4 +4,9 @@
&:hover {
color: var(--mall_main_color);
}
}
\ No newline at end of file
}
.errorText {
color: #D32F2F;
padding: 16px 0;
}
......@@ -6,12 +6,13 @@ import styles from './index.less'
interface ContractPropsType {
state: boolean;
onChange: Function;
contractInfo: any
contractInfo: any;
errorInfo?: any,
}
const Contract: React.FC<ContractPropsType> = (props) => {
const { state, onChange, contractInfo } = props
const { state, onChange, contractInfo, errorInfo } = props
return (
<div className={styles.contract}>
......@@ -21,14 +22,17 @@ const Contract: React.FC<ContractPropsType> = (props) => {
<QuestionCircleOutlined className={styles.common_title_icon} />
</Tooltip>
</div>
<div className={styles.checkbox}>
<Checkbox checked={state} onChange={(e) => onChange(e.target.checked)}>
<span>我同意签订:</span>
</Checkbox>
{
contractInfo && <a href={contractInfo?.contractUrl} download rel="noreferrer" target="_blank" className={styles.checkbox_contract_text}>{contractInfo?.contractName}</a>
}
</div>
{
contractInfo && (
<div className={styles.checkbox}>
<Checkbox checked={state} onChange={(e) => onChange(e.target.checked)}>
<span>我同意签订:</span>
</Checkbox>
<a href={contractInfo?.contractUrl} download rel="noreferrer" target="_blank" className={styles.checkbox_contract_text}>{contractInfo?.contractName}</a>
</div>
)
}
{ (errorInfo && !contractInfo) && <span className={styles.errorText}>{errorInfo}</span> }
</div>
)
}
......
......@@ -144,9 +144,9 @@
height: 50px;
outline: none;
font-size: 16px;
border-color: #D32F2F;
border-color: var(--mall_main_color);
border-radius: 0;
background-color: #D32F2F;
background-color: var(--mall_main_color);
cursor: pointer;
&:hover {
......@@ -156,4 +156,4 @@
}
}
}
}
\ No newline at end of file
}
......@@ -8,7 +8,6 @@ import { numFormat, priceFormat } from '@/utils/numberFomat'
import cx from 'classnames'
import Address from './address'
import PayWay from './payway'
// import Delivery from './delivery'
import Contract from './contract'
import Invoice from './invoice'
import styles from './index.less'
......@@ -68,6 +67,7 @@ const Order: React.FC<OrderPropsType> = (props) => {
const [logisticsFee, setLogisticsFee] = useState<number>(0)
const [isElectronicContract, setIsElectronicContract] = useState<boolean>(false) // 是否选用电子合同
const [contractInfo, setContractInfo] = useState<any>()
const [contracErrorInfo, setContracErrorInfo] = useState<any>()
const [electronicContractId, setElectronicContractId] = useState<number>()
const [agreeSingLoading, setAgreeSignLoading] = useState<boolean>(false)
const [btnDisabled] = useState<boolean>(false)
......@@ -95,36 +95,32 @@ const Order: React.FC<OrderPropsType> = (props) => {
}
}, [storeId])
const initOrderInfo = async () => {
const result = []
const sessionOrderInfo: any = await getOrderInfo(spam_id)
for (const item of sessionOrderInfo.orderList) {
const tempOrderList = []
for (const orderItem of item.orderList) {
let resData: any = {}
if (orderItem.logistics?.sendAddress) {
try {
resData = await PublicApi.getLogisticsShipperAddressGet({ id: orderItem.logistics.sendAddress })
} catch (error) {
console.log(error)
}
useEffect(() => {
getLogisticsFeeAnync()
}, [selectAddressInfo])
useEffect(() => {
if(orderInfo) {
if (orderInfo.logistics.deliveryType === 1) {
if(selectAddressInfo) {
fetchElectronicContractInfo()
}
message.destroy()
orderItem.logisticsInfo = resData.data || {}
tempOrderList.push(orderItem)
} else {
fetchElectronicContractInfo()
}
item.orderList = tempOrderList
result.push(item)
}
const productId = sessionOrderInfo?.orderList[0]?.orderList[0].id
// 根据商品ID获取工作流信息,判断是否需要签署合同
}, [orderInfo, selectAddressInfo])
const fetchElectronicContractInfo = async () => {
const productId = orderInfo?.orderList[0]?.orderList[0].id
// 根据商品ID获取工作流信息,判断是否需要签署合同
if (productId) {
try {
const param: any = {
productId,
shopId: storeId,
memberId: sessionOrderInfo.supplyMembersId,
memberRoleId: sessionOrderInfo.supplyMembersRoleId,
memberId: orderInfo.supplyMembersId,
memberRoleId: orderInfo.supplyMembersRoleId,
}
const rulesRes = await PublicApi.getOrderTradingRulesByProductId(param)
const { data } = rulesRes
......@@ -138,19 +134,27 @@ const Order: React.FC<OrderPropsType> = (props) => {
} else {
// 根据电子合同模板id获取生成电子合同
const param: any = {
orderModel: getOrderMode(), // 下单模式
contractTemplateId: data.electronicContractId,
signMemberId: userInfo?.memberId,
orderNo: new Date().getTime()
signMemberId: orderInfo.supplyMembersId,
signRoleId: orderInfo.supplyMembersRoleId,
orderProductRequests: getOrderProductRequests().orderProductRequests,
}
if (orderInfo.logistics.deliveryType === 1 && selectAddressInfo) {
param.deliveryAddresId = selectAddressInfo.id
}
const signRes = await PublicApi.postOrderSignatureSignContractCreate(param)
const signData: any = signRes.data
message.destroy()
if (signRes.code === 1000) {
message.destroy()
setContractInfo(signData)
sessionStorage.setItem(`contract${spam_id}`, JSON.stringify(signData))
setIsElectronicContract(true)
} else {
setContracErrorInfo(signRes.message)
}
setIsElectronicContract(true)
}
}
}
......@@ -158,6 +162,79 @@ const Order: React.FC<OrderPropsType> = (props) => {
console.log("获取交易规则失败")
}
}
}
const initOrderInfo = async () => {
const result = []
const sessionOrderInfo: any = await getOrderInfo(spam_id)
for (const item of sessionOrderInfo.orderList) {
const tempOrderList = []
for (const orderItem of item.orderList) {
let resData: any = {}
if (orderItem.logistics?.sendAddress) {
try {
resData = await PublicApi.getLogisticsShipperAddressGet({ id: orderItem.logistics.sendAddress })
} catch (error) {
console.log(error)
}
}
message.destroy()
orderItem.logisticsInfo = resData.data || {}
tempOrderList.push(orderItem)
}
item.orderList = tempOrderList
result.push(item)
}
// const productId = sessionOrderInfo?.orderList[0]?.orderList[0].id
// // 根据商品ID获取工作流信息,判断是否需要签署合同
// if (productId) {
// try {
// const param: any = {
// productId,
// shopId: storeId,
// memberId: sessionOrderInfo.supplyMembersId,
// memberRoleId: sessionOrderInfo.supplyMembersRoleId,
// }
// const rulesRes = await PublicApi.getOrderTradingRulesByProductId(param)
// const { data } = rulesRes
// if (data) {
// // 是否选用电子合同
// if (data.isElectronicContract) {
// setElectronicContractId(data.electronicContractId)
// if (sessionStorage.getItem(`contract${spam_id}`)) {
// setContractInfo(JSON.parse(sessionStorage.getItem(`contract${spam_id}`)))
// setIsElectronicContract(true)
// } else {
// // 根据电子合同模板id获取生成电子合同
// const param: any = {
// orderModel: getOrderMode(), // 下单模式
// contractTemplateId: data.electronicContractId,
// signMemberId: sessionOrderInfo.supplyMembersId,
// signRoleId: sessionOrderInfo.supplyMembersRoleId,
// orderProductRequests: getOrderProductRequests().orderProductRequests,
// }
// if (sessionOrderInfo.logistics.deliveryType === 1 && selectAddressInfo) {
// param.deliveryAddresId = selectAddressInfo.id
// }
// const signRes = await PublicApi.postOrderSignatureSignContractCreate(param)
// const signData: any = signRes.data
// message.destroy()
// if (signRes.code === 1000) {
// setContractInfo(signData)
// sessionStorage.setItem(`contract${spam_id}`, JSON.stringify(signData))
// } else {
// setContracErrorInfo(signRes.message)
// }
// setIsElectronicContract(true)
// }
// }
// }
// } catch (error) {
// console.log("获取交易规则失败")
// }
// }
setOrderList(result)
setOrderInfo(sessionOrderInfo)
setSpinningState(false)
......@@ -210,9 +287,7 @@ const Order: React.FC<OrderPropsType> = (props) => {
return amount
}
useEffect(() => {
getLogisticsFeeAnync()
}, [selectAddressInfo])
const getLogisticsFeeAnync = async () => {
if (selectAddressInfo) {
......@@ -299,28 +374,7 @@ const Order: React.FC<OrderPropsType> = (props) => {
return productName
}
/**
* 提交订单
*/
const submitOrder = (signatureLogId?: number, contractUrl?: string) => {
const params: any = {
orderModel: getOrderMode(), // 下单模式
needTheInvoice: needTheInvoice ? 1 : 0,
shopId: storeId
}
if (orderInfo.logistics.deliveryType === 1 && !!selectAddressInfo) {
params.deliveryAddresId = selectAddressInfo.id
params.receiverName = selectAddressInfo.receiverName
params.isDefault = selectAddressInfo.isDefault
params.fullAddress = selectAddressInfo.fullAddress
params.phone = selectAddressInfo.phone
// params.province = selectAddressInfo.provinceName
// params.city = selectAddressInfo.cityName
// params.area = selectAddressInfo.districtName
// params.addres = selectAddressInfo.address
}
const getOrderProductRequests = () => {
const orderProductRequests = []
const purchaseIds = []
for (const item of orderList) {
......@@ -346,11 +400,35 @@ const Order: React.FC<OrderPropsType> = (props) => {
orderProductRequests.push(temp)
}
}
return {
orderProductRequests,
purchaseIds
}
}
/**
* 提交订单
*/
const submitOrder = (signatureLogId?: number, contractUrl?: string) => {
const params: any = {
orderModel: getOrderMode(), // 下单模式
needTheInvoice: needTheInvoice ? 1 : 0,
shopId: storeId
}
if (orderInfo.logistics.deliveryType === 1 && !!selectAddressInfo) {
params.deliveryAddresId = selectAddressInfo.id
params.receiverName = selectAddressInfo.receiverName
params.isDefault = selectAddressInfo.isDefault
params.fullAddress = selectAddressInfo.fullAddress
params.phone = selectAddressInfo.phone
}
params.supplyMembersName = orderInfo.supplyMembersName
params.supplyMembersId = orderInfo.supplyMembersId
params.supplyMembersRoleId = orderInfo.supplyMembersRoleId
params.deliveryType = orderInfo.logistics.deliveryType
params.orderProductRequests = orderProductRequests
params.orderProductRequests = getOrderProductRequests().orderProductRequests
params.paymentInformationResponses = [{
payPrice: 1,
payWay: selectPayWay.payType,
......@@ -361,7 +439,7 @@ const Order: React.FC<OrderPropsType> = (props) => {
params.theInvoiceInfo = selectInvoiceInfo
}
if (orderInfo.purchaseOrder) {
params.idList = purchaseIds
params.idList = getOrderProductRequests().purchaseIds
params.productType = (layoutType === LAYOUT_TYPE.channel || layoutType === LAYOUT_TYPE.ichannel) ? 2 : 1
}
......@@ -507,7 +585,7 @@ const Order: React.FC<OrderPropsType> = (props) => {
orderInfo.isInvoice && <Invoice state={needTheInvoice} onChange={(val) => setNeedTheInvoice(val)} onSelect={(val) => setSelectInvoiceInfo(val)} />
}
{
isElectronicContract && <Contract contractInfo={contractInfo} state={needTheContract} onChange={(val) => setneedTheContract(val)} />
isElectronicContract && <Contract errorInfo={contracErrorInfo} contractInfo={contractInfo} state={needTheContract} onChange={(val) => setneedTheContract(val)} />
}
<div className={styles.common_title}>
<span>订单信息</span>
......
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