255], [['clerk_code'], 'string', 'max' => 12], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => 'Mall ID', 'user_id' => '会员id', 'secondary_card_id' => '次卡id', 'use_type' => '使用范围:0:全部店铺;1:指定店铺', 'order_no' => '次卡号', 'clerk_code' => '核销码', 'order_status' => '状态:0:待核销;1:已失效;2:已过期;3:已退款;4:已停卡', 'open_time' => '开卡时间:需要支付时,支付时间', 'open_type' => '开卡方式:1:下单购买;2:兑换码兑换', 'pay_money' => '购卡实收金额', 'pay_type' => '支付方式:1=微信支付,2=货到付款,3=余额支付,4=支付宝支付,5=银联支付,6=汇聚聚合支付,7=汇聚快捷支付', 'start_time' => '有效期开始时间', 'expire_time' => '有效期结束时间,过期时间', 'refund_source' => '退款来源:1:会员申请;2:过期,后台操作退款', 'refund_money' => '退款金额', 'refund_time' => '退款时间', 'verifiable_times' => '可核销次数', 'code' => '兑换码', 'status' => '状态[-1:删除;0:禁用;1启用;]', 'created_at' => '创建时间', 'updated_at' => 'Updated At', 'trade_id' => 'trade_id', 'create_source_type' => '创建来源类型:0:平台;1:门店', 'create_source_id' => '创建来源id', ]; } public static function getExportFields() { return [ 'order_no' => '卡号', 'nickname' => '开卡用户', 'order_status' => '次卡状态', 'open_time' => '开卡时间', 'open_type' => '开卡方式', 'pay_money' => '购卡实收金额', 'expire_time' => '到期时间', 'refund_money' => '退款金额', 'refund_time' => '退款时间', ]; } public function getSecondaryCard() { return $this->hasOne(SecondaryCard::class, ['id' => 'secondary_card_id']); } public function getUser() { return $this->hasOne(User::class, ['id' => 'user_id']); } public static function setData(array $params) { try { if (!empty($params['id'])) { $model = self::findOne(['mall_id' => $params['mall_id'], 'id' => $params['id'], 'status' => [StatusEnum::ENABLED, StatusEnum::DISABLED]]); if (empty($model)) throw new \Exception('服务不存在或已删除'); } else { $model = new self(); $model->loadDefaultValues(); } if (!$model->load($params, '')) throw new \Exception($model->getErrorMessage()); if (!$model->save()) throw new \Exception($model->getErrorMessage()); return $model; } catch (\Exception $e) { self::$static_error = $e->getMessage(); return false; } } /** * * @Author:hua * @Date:2024-03-08 14:35 * @Copyright:copyright(c)2024 广东七件事集团 * @param int $len * @return false|string */ public static function getOrderNo() { while (true) { $order_no = StringHelper::generateRandCode(10); $rand = mt_rand(10000, 99999); $order_no = $rand . $order_no; $res = SecondaryCardOrder::findOne(['order_no' => $order_no, 'status' => StatusEnum::ENABLED]); if (empty($res)) { break; } } return $order_no; } }