储蓄卡,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; } }