From 9c3050240ccc8aa8f9424d69afde39cd032bafca Mon Sep 17 00:00:00 2001 From: xuanchen <122383162@qq.com> Date: Wed, 14 Oct 2020 10:35:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/unionpay/config/unionpay.php | 333 +++++++++++++++++- packages/unionpay/src/Action/Query.php | 3 +- packages/unionpay/src/Action/Redemption.php | 15 +- packages/unionpay/src/Action/Reversal.php | 3 +- ...CheckCouponContracts.php => Contracts.php} | 4 +- .../src/Contracts/CouponContracts.php | 30 -- packages/unionpay/src/Traits/Log.php | 47 --- 7 files changed, 342 insertions(+), 93 deletions(-) rename packages/unionpay/src/Contracts/{CheckCouponContracts.php => Contracts.php} (76%) delete mode 100644 packages/unionpay/src/Contracts/CouponContracts.php delete mode 100644 packages/unionpay/src/Traits/Log.php diff --git a/packages/unionpay/config/unionpay.php b/packages/unionpay/config/unionpay.php index 56587a2..b0eb83d 100644 --- a/packages/unionpay/config/unionpay.php +++ b/packages/unionpay/config/unionpay.php @@ -1,14 +1,339 @@ [ + //分配的渠道号 + 'msg_sender' => '660134', + //打印在小票上,由活动标题、优惠金额、原始金额组合而成 + 'pos_receipt' => '本时生活,优惠生活', + //广告,用于打印在小票上 + 'pos_ad' => '', + //营销联盟广告,用于打印在小票上 + 'pos_mkt_ad' => '本时生活,优惠生活', + //银联渠道id + 'agent_id' => '299', + //银联网点id + 'outlet_id' => '2009300919918', + //用于银商与sp分润的金额(是佣金的一部分), 以分为单位 + 'serv_chg' => 0, + //佣金 + 'commission' => 0, + //证书 + 'check' => [ 'self' => [ - 'private' => storage_path('cert/self/private_rsa.pem'), - 'public' => storage_path('cert/self/public_rsa.pem'), + 'private' => storage_path('cert/unionpay/self/private_rsa.pem'), + 'public' => storage_path('cert/unionpay/self/public_rsa.pem'), ], 'unionpay' => [ 'public' => storage_path('cert/unionpay/public_rsa.pem'), ], ], + 'type' => [ + '002025' => '查询', + '002100' => '交易', + '002101' => '冲正', + '002102' => '撤销', + ], + 'log_type' => [ + '002025' => 'query', + '002100' => 'freezecoupon', + '002101' => 'reversal', + '002102' => 'annul', + ], + //需要校验的数据 + 'validator' => [ + '002025' => [ + "msg_type", + "msg_txn_code", + "msg_crrltn_id", + "msg_flg", + "msg_sender", + "msg_time", + "msg_ver", + "msg_sys_sn", + "req_serial_no", + "mkt_code", + "amount", + "avl_amt", + ], + '002100' => [ + "msg_type", + "msg_txn_code", + "msg_crrltn_id", + "msg_flg", + "msg_sender", + "msg_time", + "msg_sys_sn", + "msg_ver", + "req_serial_no", + "orig_req_serial_no", + "sett_date", + "txn_date", + "txn_time", + "orig_amt", + "discount_amt", + ], + '002101' => [ + "msg_type", + "msg_txn_code", + "msg_crrltn_id", + "msg_flg", + "msg_sender", + "msg_time", + "msg_sys_sn", + "msg_ver", + "req_serial_no", + "orig_req_serial_no", + ], + '002102' => [ + "msg_type", + "msg_txn_code", + "msg_crrltn_id", + "msg_flg", + "msg_sender", + "msg_time", + "msg_sys_sn", + "msg_ver", + "req_serial_no", + "orig_req_serial_no", + ], + ], + //入库基础数据 + 'regular' => [ + '002025' => [ + "msg_type", + "msg_txn_code", + "msg_crrltn_id", + "msg_flg", + "msg_sender", + "msg_time", + "msg_ver", + "msg_sys_sn",//自己添加的基础数据 + "req_serial_no",//自己添加的基础数据 + "mkt_code",//自己添加的基础数据 + ], + '002100' => [ + "msg_type", + "msg_txn_code", + "msg_crrltn_id", + "msg_flg", + "msg_sender", + "msg_time", + "msg_sys_sn", + "msg_ver", + "req_serial_no",//自己添加的基础数据 + "orig_req_serial_no",//自己添加的基础数据 + "sett_date",//自己添加的基础数据 + ], + '002101' => [ + "msg_type", + "msg_txn_code", + "msg_crrltn_id", + "msg_flg", + "msg_sender", + "msg_time", + "msg_sys_sn", + "msg_ver", + "req_serial_no",//自己添加的基础数据 + "orig_req_serial_no",//自己添加的基础数据 + ], + '002102' => [ + "msg_type", + "msg_txn_code", + "msg_crrltn_id", + "msg_flg", + "msg_sender", + "msg_time", + "msg_sys_sn", + "msg_ver", + "req_serial_no",//自己添加的基础数据 + "orig_req_serial_no",//自己添加的基础数据 + ], + ], + 'fields' => [ + //聚合营销优惠查询接口 + '002025' => [ + 'in' => [ + "msg_type" => "报文类型", + "msg_txn_code" => "交易代码", + "msg_crrltn_id" => "报文流水号", + "msg_flg" => "报文请求应答标志", + "msg_sender" => "报文发送方", + "msg_time" => "报文日期", + "msg_sys_sn" => "平台流水号", + "msg_ver" => "报文版本号", + "req_serial_no" => "查询流水号", + "shop_no" => "门店号", + "term_no" => "受理终端号", + "service_code" => "受理方式", + "voucher_no" => "受理凭证号", + "mkt_code" => "聚合营销码", + "mkt_mode" => "聚合营销类型", + "embedded_mchnt_no" => "发起渠道商户号", + "currency_code" => "货币代码", + "amount" => "消费金额", + "avl_amt" => "可优惠金额", + "term_sp_chnl_no" => "终端指定SP渠道号", + "func_code" => "功能码", + "times" => "次数", + "pay_mode" => "支付方式", + //用户附加信息 + "user_ext_info" => [ + "mobile_no" => "手机号", + "user_code" => "用户号", + "user_code_type" => "用户号类型", + "dev_id" => "设备id", + ], + "sign" => "签名域", + ], + 'out' => [ + "msg_type" => "报文类型", + "msg_txn_code" => "交易代码", + "msg_crrltn_id" => "报文流水号", + "msg_flg" => "报文请求应答标志", + "msg_sender" => "报文发送方", + "msg_time" => "报文日期", + "msg_sys_sn" => "平台流水号", + "msg_rsp_code" => "响应码", + "msg_rsp_desc" => "响应码描述", + "discount" => "折扣金额", + "actual_amt" => "折后应收金额", + "pos_display" => "POS显示", + "pos_receipt" => "POS小票", + "pos_ad" => "POS广告", + "pos_mkt_ad" => "Pos_营销联盟广告", + "sign" => "签名域", + ], + ], + //销账交易接口 + '002100' => [ + 'in' => [ + "msg_type" => "报文类型", + "msg_txn_code" => "交易代码", + "msg_crrltn_id" => "消息关联号", + "msg_flg" => "报文请求应答标志", + "msg_sender" => "报文发送方", + "msg_time" => "报文日期", + "msg_sys_sn" => "平台流水号", + "msg_ver" => "报文版本号", + "shop_no" => "门店号", + "term_no" => "终端号", + "req_serial_no" => "销券流水号", + "orig_req_serial_no" => "原查询流水号", + "enc_card_no" => "加密卡号", + "part_card_no" => "部分卡号", + "acq_term_sn" => "受理终端流水号", + "refer_no" => "检索参考号", + "sett_date" => "清算日期", + "txn_date" => "交易日期", + "txn_time" => "交易时间", + "orig_amt" => "原始金额", + "discount_amt" => "优惠的金额", + "pay_amt" => "支付金额", + "pay_mode" => "支付方式", + "order_no" => "订单号", + "trans_crrltn_no" => "交易关联流水号", + "equity_no" => "权益号", + "card_no" => "全卡号", + "sign" => "签名数据", + ], + 'out' => [ + "msg_type" => "报文类型", + "msg_txn_code" => "交易代码", + "msg_crrltn_id" => "消息关联号", + "msg_flg" => "报文请求应答标志", + "msg_sender" => "报文发送方", + "msg_time" => "报文日期", + "msg_sys_sn" => "平台流水号", + "msg_ver" => "报文版本号", + "msg_rsp_code" => "响应码", + "msg_rsp_desc" => "响应码描述", + "orig_amt" => "原始金额", + "discount_amt" => "折扣金额", + "pay_amt" => "支付金额", + "serv_chg" => "服务费", + "commission" => "佣金", + "ad" => "广告", + "pos_receipt" => "POS优惠", + "coupon_no" => "凭证号", + "coupon_type" => "凭证类型", + "sp_biz_code" => "SP统计码", + "charge_code" => "计费码", + "pos_event_title" => "SP活动主题", + "sp_contact" => "SP联系电话", + "sp_name" => "SP名称", + "event_no" => "活动号", + "td_code" => "二维码", + "memo" => "附言", + "mkt_sp_chnl_no" => "营销渠道号", + "point_amt" => "积分抵扣金额", + "sign" => "签名数据", + ], + ], + //销账冲正通知接口 + '002101' => [ + 'in' => [ + "msg_type" => "报文类型", + "msg_txn_code" => "交易代码", + "msg_crrltn_id" => "消息关联号", + "msg_flg" => "报文请求应答标志", + "msg_sender" => "报文发送方", + "msg_time" => "报文日期", + "msg_sys_sn" => "平台流水号", + "msg_ver" => "报文版本号", + "shop_no" => "门店号", + "term_no" => "终端号", + "req_serial_no" => "冲正流水号", + "orig_req_serial_no" => "原始销账流水号", + "trans_crrltn_no" => "交易关联流水号", + "sign" => "签名数据", + ], + 'out' => [ + "msg_type" => "报文类型", + "msg_txn_code" => "交易代码", + "msg_crrltn_id" => "消息关联号", + "msg_flg" => "报文请求应答标志", + "msg_sender" => "报文发送方", + "msg_time" => "报文日期", + "msg_sys_sn" => "平台流水号", + "msg_ver" => "报文版本号", + "msg_rsp_code" => "响应码", + "msg_rsp_desc" => "响应码描述", + "sign" => "签名数据", + ], + ], + '002102' => [ + 'in' => [ + "msg_type" => "报文类型", + "msg_txn_code" => "交易代码", + "msg_crrltn_id" => "消息关联号", + "msg_flg" => "报文请求应答标志", + "msg_sender" => "报文发送方", + "msg_time" => "报文日期", + "msg_sys_sn" => "平台流水号", + "msg_ver" => "报文版本号", + "shop_no" => "门店号", + "term_no" => "终端号", + "req_serial_no" => "撤销流水号", + "orig_req_serial_no" => "原始销账流水号", + "trans_crrltn_no" => "交易关联流水号", + "sign" => "签名数据", + ], + 'out' => [ + "msg_type" => "报文类型", + "msg_txn_code" => "交易代码", + "msg_crrltn_id" => "消息关联号", + "msg_flg" => "报文请求应答标志", + "msg_sender" => "报文发送方", + "msg_time" => "报文日期", + "msg_sys_sn" => "平台流水号", + "msg_ver" => "报文版本号", + "msg_rsp_code" => "响应码", + "msg_rsp_desc" => "响应码描述", + "ad" => "广告", + "td_code" => "二维码", + "sign" => "签名数据", + ], + ], + + ], ]; diff --git a/packages/unionpay/src/Action/Query.php b/packages/unionpay/src/Action/Query.php index 755f393..4a1b511 100644 --- a/packages/unionpay/src/Action/Query.php +++ b/packages/unionpay/src/Action/Query.php @@ -3,8 +3,9 @@ namespace XuanChen\UnionPay\Action; use XuanChen\Coupon\Coupon; +use XuanChen\UnionPay\Contracts\Contracts; -class Query +class Query implements Contracts { public $outlet_id; diff --git a/packages/unionpay/src/Action/Redemption.php b/packages/unionpay/src/Action/Redemption.php index e7b3246..5a7736d 100644 --- a/packages/unionpay/src/Action/Redemption.php +++ b/packages/unionpay/src/Action/Redemption.php @@ -6,8 +6,9 @@ use App\Models\ActivityCoupon; use App\Models\UnionpayLog; use App\Models\User; use XuanChen\Coupon\Coupon; +use XuanChen\UnionPay\Contracts\Contracts; -class Redemption +class Redemption implements Contracts { public $outlet_id; @@ -36,16 +37,12 @@ class Redemption //获取银联渠道 $user = User::find($this->agent_id); - if ($query) { - $coupon = Coupon::Redemption($user, $query->mkt_code, $this->params['orig_amt'] / 100, $this->outlet_id, ''); - if (!is_array($coupon)) { - $this->outdata['msg_rsp_code'] = '9999'; - $this->outdata['msg_rsp_desc'] = $coupon; - } - } else { + $coupon = Coupon::Redemption($user, $query->mkt_code, $this->params['orig_amt'] / 100, $this->outlet_id, ''); + if (!is_array($coupon)) { $this->outdata['msg_rsp_code'] = '9999'; - $this->outdata['msg_rsp_desc'] = '未查询到前置接口,获取券码失败。'; + $this->outdata['msg_rsp_desc'] = $coupon; } + } } diff --git a/packages/unionpay/src/Action/Reversal.php b/packages/unionpay/src/Action/Reversal.php index 460de6c..e41f55a 100644 --- a/packages/unionpay/src/Action/Reversal.php +++ b/packages/unionpay/src/Action/Reversal.php @@ -5,8 +5,9 @@ namespace XuanChen\UnionPay\Action; use App\Models\UnionpayLog; use XuanChen\Coupon\Coupon; use App\Models\Coupon as CouponModel; +use XuanChen\UnionPay\Contracts\Contracts; -class Reversal +class Reversal implements Contracts { public $outlet_id; diff --git a/packages/unionpay/src/Contracts/CheckCouponContracts.php b/packages/unionpay/src/Contracts/Contracts.php similarity index 76% rename from packages/unionpay/src/Contracts/CheckCouponContracts.php rename to packages/unionpay/src/Contracts/Contracts.php index 7d17256..c87b633 100644 --- a/packages/unionpay/src/Contracts/CheckCouponContracts.php +++ b/packages/unionpay/src/Contracts/Contracts.php @@ -2,7 +2,7 @@ namespace XuanChen\UnionPay\Contracts; -interface CheckCouponContracts +interface Contracts { /** @@ -11,4 +11,6 @@ interface CheckCouponContracts */ function start(); + function back(); + } diff --git a/packages/unionpay/src/Contracts/CouponContracts.php b/packages/unionpay/src/Contracts/CouponContracts.php deleted file mode 100644 index 1bfbdab..0000000 --- a/packages/unionpay/src/Contracts/CouponContracts.php +++ /dev/null @@ -1,30 +0,0 @@ - $url, - 'method' => $method, - 'type' => $type, - 'in_source' => $params, - ]; - - $info = LogModel::create($data); - - return $info; - } - - /** - * Notes: 更新日志 - * @Author: 玄尘 - * @Date : 2020/6/30 10:29 - * @param $log - * @param $params - */ - public static function updateLog($log, $params) - { - $log->out_source = $params; - $log->save(); - } - -}