"支付成功", self::PAY_FAIL => "支付失败", self::PAY_WAIT => "待支付", self::PAY_CLOSE => "交易关闭", ]; /** * {@inheritdoc} */ public static function tableName() { return '{{%addons_sicpay_order}}'; } /** * {@inheritdoc} */ public function rules() { return [ [['mall_id', 'agencyId', 'created_at', 'updated_at'], 'integer'], [['amount'], 'number'], [['order_no','amount'], 'required'], [['pay_time','pay_result','type'], 'safe'], [['response_json', 'request_json'], 'string'], [['order_no','pay_no','agencyId','mall_order_no'], 'string', 'max' => 64], [['type'], 'string', 'max' => 32], [['product_name', 'token_id'], 'string', 'max' => 255], [['pay_result'], 'string', 'max' => 4], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => 'Mall ID', 'mall_order_no' => 'Mall ID', 'order_no' => 'Order No', 'pay_no' => 'Order No', 'agencyId' => '商户号', 'amount' => 'Amount', 'product_name' => 'Product Name', 'pay_result' => '1⽀付成功,0未⽀付,2⽀付失败,6已关闭', 'pay_time' => 'Pay Time', 'created_at' => 'Created At', 'updated_at' => 'Updated At', 'token_id' => 'Token ID', 'response_json' => 'Response Json', 'request_json' => 'Request Json', ]; } /** * 支付成功 * @param $pay_no 支付单号 * @param $pay_time 支付时间 */ public static function pay_success($order_id,$pay_no,$pay_time,$resp = []){ $update = [ 'pay_result'=>self::PAY_SUCCESS, 'pay_no'=>$pay_no, 'pay_time'=>$pay_time, 'updated_at'=>time() ]; if(!empty($resp)){ $update['response_json'] = json_encode($resp); } return self::updateAll($update,['id'=>$order_id]); } public static function pay_fail($order_id,$err_msg,$resp = []){ $update = [ 'pay_result'=>self::PAY_FAIL, 'err_msg'=>$err_msg, 'updated_at'=>time() ]; if(!empty($resp)){ $update['response_json'] = json_encode($resp); } return self::updateAll($update,['id'=>$order_id]); } public static function pay_close($order_id,$err_msg,$resp = []){ $update = [ 'pay_result'=>self::PAY_CLOSE, 'err_msg'=>$err_msg, 'updated_at'=>time() ]; if(!empty($resp)){ $update['response_json'] = json_encode($resp); } return self::updateAll($update,['id'=>$order_id]); } public static function getPayText(){ $list = []; foreach (self::$pay_text as $key=>$val){ $list[] = [ 'label'=>$val, 'value'=>$key, ]; } return $list; } }