| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- <?php
- /*
- * @Descripttion:
- * @version:
- * @Author: ewgof
- * @Date: 2022-04-08 15:34:51
- * @LastEditors: ewgof
- * @LastEditTime: 2022-04-08 16:17:29
- */
- namespace addons\JoinPay\common\models;
- use common\enums\StatusEnum;
- use Yii;
- /**
- * This is the model class for table "{{%addons_joinpay_user_bankcard}}".
- *
- * @property int $id
- * @property int $mall_id 商城id
- * @property int $user_id 用户id
- * @property int $card_id 银行卡id,qimall_user_bank_card 表的id
- * @property string $payer_name 持卡人姓名
- * @property int $id_type 持卡人证件类型:1-身份证,2-军官证,3-士兵证,4-护照等
- * @property string $id_no 持卡人证件号码
- * @property string $bank_name 银行名称
- * @property string $bank_code 银行简码
- * @property string $bank_card_no 银行卡号
- * @property string $mobile_no 银行卡绑定的手机号
- * @property string $expire_date 信用卡有效期,格式:yy/mm格式
- * @property string $cvv 信用卡cvv安全码
- * @property string $sign_no 快捷支付-签约id
- * @property int $is_sign 是否开通快捷支付
- * @property string $card_type 银行卡类型,dc->储蓄卡,cc->信用卡
- * @property string $card_type_name 银行卡类型名称
- * @property int $status 状态[-1:删除;0:禁用;1启用]
- * @property int $created_at 添加时间戳
- * @property int $updated_at 更新时间戳
- */
- class JoinPayUserBankcard extends \common\models\base\BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_joinpay_user_bankcard}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mall_id', 'user_id'], 'required'],
- [['mall_id', 'user_id', 'card_id', 'id_type', 'is_sign', 'status', 'created_at', 'updated_at'], 'integer'],
- [['payer_name', 'id_no', 'bank_name'], 'string', 'max' => 50],
- [['bank_code', 'mobile_no', 'expire_date', 'cvv', 'sign_no', 'card_type', 'card_type_name'], 'string', 'max' => 32],
- [['bank_card_no'], 'string', 'max' => 64],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mall_id' => '商城id',
- 'user_id' => '用户id',
- 'card_id' => '银行卡id,qimall_user_bank_card 表的id',
- 'payer_name' => '持卡人姓名',
- 'id_type' => '持卡人证件类型:1-身份证,2-军官证,3-士兵证,4-护照等',
- 'id_no' => '持卡人证件号码',
- 'bank_name' => '银行名称',
- 'bank_code' => '银行简码',
- 'bank_card_no' => '银行卡号',
- 'mobile_no' => '银行卡绑定的手机号',
- 'expire_date' => '信用卡有效期,格式:yy/mm格式',
- 'cvv' => '信用卡cvv安全码',
- 'sign_no' => '快捷支付-签约id',
- 'is_sign' => '是否开通快捷支付',
- 'card_type' => '银行卡类型,dc->储蓄卡,cc->信用卡',
- 'card_type_name' => '银行卡类型名称',
- 'status' => '状态[-1:删除;0:禁用;1启用]',
- 'created_at' => '添加时间戳',
- 'updated_at' => '更新时间戳',
- ];
- }
- public static function setData(int $mall_id, array $data)
- {
- if (empty($data['id'])) {
- $model = self::findOne([
- 'mall_id' => $mall_id,
- 'card_id' => $data['card_id'],
- 'payer_name' => $data['payer_name'],
- 'bank_card_no' => $data['bank_card_no'],
- 'status' => StatusEnum::ENABLED
- ]);
- if (empty($model)) {
- $model = new self();
- $model->loadDefaultValues();
- $model->mall_id = $mall_id;
- }
- unset($data['id']);
- } else {
- $model = self::findOne(['mall_id' => $mall_id, 'id' => $data['id'], 'status' => StatusEnum::ENABLED]);
- if (empty($model)) throw new \Exception('数据记录异常');
- }
- foreach ($data as $key => $val) {
- $model->$key = $val;
- }
- if (!$model->save()) {
- self::$static_error = '保存数据失败:' . $model->getErrorMessage();
- return false;
- }
- return $model;
- }
- }
|