| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- <?php
- namespace addons\Printer\common\models;
- use common\models\base\BaseActiveRecord;
- use PHPUnit\Util\Exception;
- /**
- * This is the model class for table "addons_printer_log".
- *
- * @property int $id ID
- * @property int $mch_id 多商户id,0表示商城订单
- * @property int $store_id 门店id
- * @property int $mall_id 商城id
- * @property int $order_id 订单id
- * @property int $type 打印类型,1: 下单,2: 支付,3: 确认收货,4: 后台
- * @property int $status 打印状态,0: 失败,1: 成功
- * @property int $msg 备注信息
- * @property int $created_at 创建时间
- * @property int $updated_at 上次更新数据时间
- */
- class Log extends BaseActiveRecord
- {
- /**
- * {@inheritdoc}
- */
- public static function tableName()
- {
- return '{{%addons_printer_log}}';
- }
- /**
- * {@inheritdoc}
- */
- public function rules()
- {
- return [
- [['mch_id', 'store_id', 'mall_id', 'order_id', 'type', 'status', 'created_at', 'updated_at'], 'integer'],
- [['msg'], 'string'],
- ];
- }
- /**
- * {@inheritdoc}
- */
- public function attributeLabels()
- {
- return [
- 'id' => 'ID',
- 'mch_id' => '多商户id,0表示商城订单',
- 'store_id' => '门店id',
- 'mall_id' => '商城id',
- 'order_id' => '订单id',
- 'type' => '打印类型,1: 下单,2: 支付,3: 确认收货,4: 后台',
- 'status' => '打印状态,0: 失败,1: 成功',
- 'msg' => '备注信息',
- 'created_at' => '创建时间',
- 'updated_at' => '上次更新数据时间',
- ];
- }
- /**
- * 保存数据
- * @param array $params
- * @return bool|PrintLog
- */
- public static function setData(array $params)
- {
- try {
- $model = new self();
- $model->loadDefaultValues();
- empty($fail_counts) ? $param['status'] = 1 : $param['status'] = 2;
- if (!$model->load($params, '') || !$model->save()) throw new Exception($model->getErrorMessage());
- return $model;
- } catch (Exception $e) {
- self::$static_error = $e->getMessage();
- return false;
- }
- }
- /**
- * 获取订单日志数据
- */
- public static function getOrderAction(array $cond = [], array $with = [], bool $is_array = true, string $select = '*')
- {
- $default_cond = [];
- $cond = array_merge($default_cond, $cond);
- $query = self::find()->select($select);
- self::paramPack(['where' => $cond, 'with' => $with], $query);
- $data = $query->orderBy('id desc')->asArray($is_array)->all();
- return $data;
- }
- }
|