32], [['mall_info', 'remarks_info', 'buyer_info','goods_info','price_info'], 'string', 'max' => 48], [['qrcode_url', 'bottom_info'], 'string', 'max' => 360], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => '商城 ID', 'name' => '打印机名称', 'ticket_nam' => '小票名字', 'head_info' => '头部信息', 'pickup_code' => '头部信息', 'goods_info' => '商品信息', 'price_info' => '商品金额', 'buyer_info' => '买家信息', 'remarks_info' => '备注', 'mall_info' => '商城信息', 'qrcode_url' => '二维码地址', 'bottom_info' => '底部信息', 'status' => '状态[-1:删除;0:禁用;1启用]', 'created_at' => 'Created At', 'updated_at' => 'Updated At', ]; } /** * 获取商城全部打印机模板 * @author huangpei * @param int $mall_id * @return array */ public static function getTemplateAllByMallId($mall_id){ $params = [ 'select' => ['id','name'], 'where' => [['=', 'mall_id', $mall_id],['<>','status',StatusEnum::DELETE]], 'order' => 'id desc' ]; $query = self::find(); self::paramPack($params,$query); return $query->asArray()->all(); } /** * 保存数据 * @author huangpei * @param array $params * @author huangpei * @return bool|object */ public static function setData($params){ try{ if(!empty($params['id'])){ $model = self::findOne(['id' => $params['id']]); if (empty($model) || $model->status == StatusEnum::DELETE) throw new \Exception('模板不存在或者已删除'); }else{ $model = new self(); } if (!$model->load($params, '') || !$model->save()) throw new \Exception($model->getErrorMessage()); return $model; }catch (\Exception $e) { self::$static_error = $e->getMessage(); return false; } } }