64], [['fail_msg'], 'string', 'max' => 255], ]; } /** * {@inheritdoc} */ public function attributeLabels() { return [ 'id' => 'ID', 'mall_id' => 'Mall ID', 'msg_id' => 'Msg ID', 'tenant_id' => 'Tenant ID', 'enum_num' => 'Enum Num', 'content' => 'Content', 'status' => 'Status', 'fail_msg' => 'Fail Msg', 'create_time' => 'Create Time', 'handled_at' => 'Handled At', ]; } /** * 新增消息 * * @param array $list * @param int $mall_id * @return int */ public static function addMsg($mall_id, $list) { $list = array_map(function ($item) use ($mall_id) { return [ 'msg_id' => $item['id'], 'mall_id' => $mall_id, 'tenant_id' => $item['tenantId'], 'enum_num' => $item['enumNum'], 'content' => $item['content'], 'create_time' => strtotime($item['createTime']), ]; }, $list); return self::batchInsert($list, false); } /** * 设置消息为已处理 * * @param array $msg_ids * @return int */ public static function setHandled($msg_ids) { return self::updateAll( [ 'handled_at' => time(), 'status' => static::SUCCESS, ], [ 'msg_id' => $msg_ids, ] ); } /** * 设置消息为处理失败 * * @return int */ public static function setHandledFail($msg_ids, string $fail_msg) { return static::updateAll( [ 'handled_at' => time(), 'status' => static::FAIL, 'fail_msg' => $fail_msg, ], [ 'msg_id' => $msg_ids, ] ); } }