You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
172 lines
7.2 KiB
172 lines
7.2 KiB
<?php
|
|
|
|
namespace Tansilu\HfPayLib\factory\object\trade;
|
|
|
|
use Tansilu\HfPayLib\Constant;
|
|
use Tansilu\HfPayLib\exception\ParamsException;
|
|
use Tansilu\HfPayLib\factory\object\RequestObj;
|
|
use Tansilu\HfPayLib\utils\StrFilterHelper;
|
|
|
|
/**
|
|
* 统一下单请求参数配置
|
|
*
|
|
* @property string $order_date 订单日期
|
|
* @property string $order_id 订单号
|
|
* @property string $user_cust_id 用户客户号
|
|
* @property string $user_name 用户姓名
|
|
* @property string $id_card_type 用户证件类型
|
|
* @property string $id_card 用户证件号
|
|
* @property string $div_type 分账区分
|
|
* @property array $div_details 分账账户串
|
|
* @property string $trans_amt 交易金额
|
|
* @property string $order_expire_time 订单超时时间
|
|
* @property string $ret_url 前台返回地址
|
|
* @property string $bg_ret_url 后台返回地址
|
|
* @property string $mer_priv 商户私有域
|
|
* @property string $extension 扩展域
|
|
* @property string $goods_tag 商品标记
|
|
* @property string $attach_info 附加信息
|
|
* @property string $goods_desc 商品描述
|
|
* @property string $goods_type 商品类型
|
|
* @property DeviceInfo $dev_info_json 设备信息
|
|
* @property ObjectInfo $object_info 藏品信息
|
|
* @property string $wx_app_id 微信公众号appId
|
|
* @property string $wx_applet_app_id 微信小程序appId
|
|
* @property string $ali_app_id 支付宝appId
|
|
* @property string $term_type 终端类型
|
|
* @property string $limit_pay 禁用贷记卡
|
|
* @property string $face_license_key 人脸licenseKey
|
|
*/
|
|
class UnifiedOrderRequest
|
|
{
|
|
use RequestObj;
|
|
|
|
|
|
/**
|
|
* @return array
|
|
* @throws ParamsException
|
|
*/
|
|
public function toParams(): array
|
|
{
|
|
$params = [];
|
|
if(empty($this->data['order_date'])) {
|
|
throw new ParamsException('订单日期不能为空', 'order_date');
|
|
}
|
|
$params['order_date'] = $this->data['order_date'];
|
|
|
|
if(empty($this->data['order_id'])) {
|
|
throw new ParamsException('订单号不能为空', 'order_id');
|
|
}
|
|
$params['order_id'] = $this->data['order_id'];
|
|
if(empty($this->data['object_info'])) {
|
|
throw new ParamsException('藏品信息不能为空', 'object_info');
|
|
}
|
|
$objectInfo = $this->data['object_info'];
|
|
if($objectInfo->marketType == null) {
|
|
throw new ParamsException('藏品交易市场类型不正确', 'object_info.marketType');
|
|
}
|
|
if($objectInfo->marketType == Constant::MARKET_MASTER) {
|
|
if((empty($this->data['user_name'])) && empty($this->data['user_cust_id'])) {
|
|
throw new ParamsException('付款人信息不能为空', 'user_name|user_cust_id');
|
|
}
|
|
//证件信息
|
|
if(empty($this->data['user_cust_id'])) {
|
|
if(empty($this->data['id_card_type'])) {
|
|
throw new ParamsException('用户证件信息不能为空', 'id_card_type');
|
|
}
|
|
if(empty($this->data['id_card'])) {
|
|
throw new ParamsException('用户证件号不能为空', 'id_card');
|
|
}
|
|
}
|
|
} else if($objectInfo->marketType == Constant::MARKET_SUB) {
|
|
if(empty($this->data['user_cust_id'])) {
|
|
throw new ParamsException('用户客户号不能为空', 'user_cust_id');
|
|
}
|
|
}
|
|
if(!empty($this->data['user_name'])) {
|
|
$params['user_name'] = $this->data['user_name'];
|
|
}
|
|
if(!empty($this->data['user_cust_id'])) {
|
|
$params['user_cust_id'] = $this->data['user_cust_id'];
|
|
}
|
|
if(!empty($this->data['id_card_type'])) {
|
|
$params['id_card_type'] = $this->data['id_card_type'];
|
|
}
|
|
if(!empty($this->data['id_card'])) {
|
|
$params['id_card'] = $this->data['id_card'];
|
|
}
|
|
if(!empty($this->data['div_type'])) {
|
|
$params['div_type'] = $this->data['div_type'];
|
|
}
|
|
|
|
if(!empty($this->data['div_details'])) {
|
|
//分账
|
|
$params['div_details'] = json_encode($this->data['div_details']);
|
|
}
|
|
if(empty($this->data['trans_amt'])) {
|
|
throw new ParamsException('交易金额不能为空', 'trans_amt');
|
|
}
|
|
if(!empty($this->data['order_expire_time'])) {
|
|
$params['order_expire_time'] = $this->data['order_expire_time'];
|
|
}
|
|
if(!empty($this->data['ret_url'])) {
|
|
$params['ret_url'] = $this->data['ret_url'];
|
|
}
|
|
if(!empty($this->data['bg_ret_url'])) {
|
|
$params['bg_ret_url'] = StrFilterHelper::fileUrl($this->data['bg_ret_url']);
|
|
}
|
|
if(!empty($this->data['mer_priv'])) {
|
|
$params['mer_priv'] = $this->data['mer_priv'];
|
|
}
|
|
if(!empty($this->data['extension'])) {
|
|
$params['extension'] = $this->data['extension'];
|
|
}
|
|
if(!empty($this->data['goods_tag'])) {
|
|
$params['goods_tag'] = $this->data['goods_tag'];
|
|
}
|
|
if(!empty($this->data['attach_info'])) {
|
|
$params['attach_info'] = $this->data['attach_info'];
|
|
}
|
|
if(!empty($this->data['goods_desc'])) {
|
|
$params['goods_desc'] = $this->data['goods_desc'];
|
|
}
|
|
if(!empty($this->data['goods_tag'])) {
|
|
$params['goods_tag'] = $this->data['goods_tag'];
|
|
}
|
|
if(!empty($this->data['goods_type'])) {
|
|
$params['goods_type'] = $this->data['goods_type'];
|
|
}
|
|
if(empty($this->data['dev_info_json'])) {
|
|
throw new ParamsException('设备信息不能为了', 'dev_info_json');
|
|
}
|
|
$devInfoJson = $this->data['dev_info_json'];
|
|
$devInfoStr = $devInfoJson->toJSON();
|
|
$params['dev_info_json'] = $devInfoStr;
|
|
|
|
//藏品
|
|
if(empty($this->data['object_info'])) {
|
|
throw new ParamsException('藏品信息不能为空', 'object_info');
|
|
}
|
|
$params['object_info'] = $this->data['object_info']->toJSON();
|
|
if(!empty($this->data['wx_app_id'])) {
|
|
$params['wx_app_id'] = $this->data['wx_app_id'];
|
|
}
|
|
if(!empty($this->data['wx_applet_app_id'])) {
|
|
$params['wx_applet_app_id'] = $this->data['wx_applet_app_id'];
|
|
}
|
|
if(!empty($this->data['ali_app_id'])) {
|
|
$params['ali_app_id'] = $this->data['ali_app_id'];
|
|
}
|
|
if(!empty($this->data['term_type'])) {
|
|
$params['term_type'] = $this->data['term_type'];
|
|
}
|
|
if(!empty($this->data['limit_pay'])) {
|
|
$params['limit_pay'] = $this->data['limit_pay'];
|
|
}
|
|
if(!empty($this->data['face_license_key'])) {
|
|
$params['face_license_key'] = $this->data['face_license_key'];
|
|
}
|
|
|
|
return $params;
|
|
}
|
|
} |